babylon.module.d.ts 5.0 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134
  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 Vector3 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/Misc/performanceMonitor" {
  5234. /**
  5235. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5236. */
  5237. export class PerformanceMonitor {
  5238. private _enabled;
  5239. private _rollingFrameTime;
  5240. private _lastFrameTimeMs;
  5241. /**
  5242. * constructor
  5243. * @param frameSampleSize The number of samples required to saturate the sliding window
  5244. */
  5245. constructor(frameSampleSize?: number);
  5246. /**
  5247. * Samples current frame
  5248. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5249. */
  5250. sampleFrame(timeMs?: number): void;
  5251. /**
  5252. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5253. */
  5254. readonly averageFrameTime: number;
  5255. /**
  5256. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5257. */
  5258. readonly averageFrameTimeVariance: number;
  5259. /**
  5260. * Returns the frame time of the most recent frame
  5261. */
  5262. readonly instantaneousFrameTime: number;
  5263. /**
  5264. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5265. */
  5266. readonly averageFPS: number;
  5267. /**
  5268. * Returns the average framerate in frames per second using the most recent frame time
  5269. */
  5270. readonly instantaneousFPS: number;
  5271. /**
  5272. * Returns true if enough samples have been taken to completely fill the sliding window
  5273. */
  5274. readonly isSaturated: boolean;
  5275. /**
  5276. * Enables contributions to the sliding window sample set
  5277. */
  5278. enable(): void;
  5279. /**
  5280. * Disables contributions to the sliding window sample set
  5281. * Samples will not be interpolated over the disabled period
  5282. */
  5283. disable(): void;
  5284. /**
  5285. * Returns true if sampling is enabled
  5286. */
  5287. readonly isEnabled: boolean;
  5288. /**
  5289. * Resets performance monitor
  5290. */
  5291. reset(): void;
  5292. }
  5293. /**
  5294. * RollingAverage
  5295. *
  5296. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5297. */
  5298. export class RollingAverage {
  5299. /**
  5300. * Current average
  5301. */
  5302. average: number;
  5303. /**
  5304. * Current variance
  5305. */
  5306. variance: number;
  5307. protected _samples: Array<number>;
  5308. protected _sampleCount: number;
  5309. protected _pos: number;
  5310. protected _m2: number;
  5311. /**
  5312. * constructor
  5313. * @param length The number of samples required to saturate the sliding window
  5314. */
  5315. constructor(length: number);
  5316. /**
  5317. * Adds a sample to the sample set
  5318. * @param v The sample value
  5319. */
  5320. add(v: number): void;
  5321. /**
  5322. * Returns previously added values or null if outside of history or outside the sliding window domain
  5323. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5324. * @return Value previously recorded with add() or null if outside of range
  5325. */
  5326. history(i: number): number;
  5327. /**
  5328. * Returns true if enough samples have been taken to completely fill the sliding window
  5329. * @return true if sample-set saturated
  5330. */
  5331. isSaturated(): boolean;
  5332. /**
  5333. * Resets the rolling average (equivalent to 0 samples taken so far)
  5334. */
  5335. reset(): void;
  5336. /**
  5337. * Wraps a value around the sample range boundaries
  5338. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5339. * @return Wrapped position in sample range
  5340. */
  5341. protected _wrapPosition(i: number): number;
  5342. }
  5343. }
  5344. declare module "babylonjs/Misc/stringDictionary" {
  5345. import { Nullable } from "babylonjs/types";
  5346. /**
  5347. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5348. * The underlying implementation relies on an associative array to ensure the best performances.
  5349. * The value can be anything including 'null' but except 'undefined'
  5350. */
  5351. export class StringDictionary<T> {
  5352. /**
  5353. * This will clear this dictionary and copy the content from the 'source' one.
  5354. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5355. * @param source the dictionary to take the content from and copy to this dictionary
  5356. */
  5357. copyFrom(source: StringDictionary<T>): void;
  5358. /**
  5359. * Get a value based from its key
  5360. * @param key the given key to get the matching value from
  5361. * @return the value if found, otherwise undefined is returned
  5362. */
  5363. get(key: string): T | undefined;
  5364. /**
  5365. * Get a value from its key or add it if it doesn't exist.
  5366. * This method will ensure you that a given key/data will be present in the dictionary.
  5367. * @param key the given key to get the matching value from
  5368. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5369. * The factory will only be invoked if there's no data for the given key.
  5370. * @return the value corresponding to the key.
  5371. */
  5372. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5373. /**
  5374. * Get a value from its key if present in the dictionary otherwise add it
  5375. * @param key the key to get the value from
  5376. * @param val if there's no such key/value pair in the dictionary add it with this value
  5377. * @return the value corresponding to the key
  5378. */
  5379. getOrAdd(key: string, val: T): T;
  5380. /**
  5381. * Check if there's a given key in the dictionary
  5382. * @param key the key to check for
  5383. * @return true if the key is present, false otherwise
  5384. */
  5385. contains(key: string): boolean;
  5386. /**
  5387. * Add a new key and its corresponding value
  5388. * @param key the key to add
  5389. * @param value the value corresponding to the key
  5390. * @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
  5391. */
  5392. add(key: string, value: T): boolean;
  5393. /**
  5394. * Update a specific value associated to a key
  5395. * @param key defines the key to use
  5396. * @param value defines the value to store
  5397. * @returns true if the value was updated (or false if the key was not found)
  5398. */
  5399. set(key: string, value: T): boolean;
  5400. /**
  5401. * Get the element of the given key and remove it from the dictionary
  5402. * @param key defines the key to search
  5403. * @returns the value associated with the key or null if not found
  5404. */
  5405. getAndRemove(key: string): Nullable<T>;
  5406. /**
  5407. * Remove a key/value from the dictionary.
  5408. * @param key the key to remove
  5409. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5410. */
  5411. remove(key: string): boolean;
  5412. /**
  5413. * Clear the whole content of the dictionary
  5414. */
  5415. clear(): void;
  5416. /**
  5417. * Gets the current count
  5418. */
  5419. readonly count: number;
  5420. /**
  5421. * Execute a callback on each key/val of the dictionary.
  5422. * Note that you can remove any element in this dictionary in the callback implementation
  5423. * @param callback the callback to execute on a given key/value pair
  5424. */
  5425. forEach(callback: (key: string, val: T) => void): void;
  5426. /**
  5427. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5428. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5429. * Note that you can remove any element in this dictionary in the callback implementation
  5430. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5431. * @returns the first item
  5432. */
  5433. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5434. private _count;
  5435. private _data;
  5436. }
  5437. }
  5438. declare module "babylonjs/Misc/promise" {
  5439. /**
  5440. * Helper class that provides a small promise polyfill
  5441. */
  5442. export class PromisePolyfill {
  5443. /**
  5444. * Static function used to check if the polyfill is required
  5445. * If this is the case then the function will inject the polyfill to window.Promise
  5446. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5447. */
  5448. static Apply(force?: boolean): void;
  5449. }
  5450. }
  5451. declare module "babylonjs/Meshes/buffer" {
  5452. import { Nullable, DataArray } from "babylonjs/types";
  5453. /**
  5454. * Class used to store data that will be store in GPU memory
  5455. */
  5456. export class Buffer {
  5457. private _engine;
  5458. private _buffer;
  5459. /** @hidden */
  5460. _data: Nullable<DataArray>;
  5461. private _updatable;
  5462. private _instanced;
  5463. /**
  5464. * Gets the byte stride.
  5465. */
  5466. readonly byteStride: number;
  5467. /**
  5468. * Constructor
  5469. * @param engine the engine
  5470. * @param data the data to use for this buffer
  5471. * @param updatable whether the data is updatable
  5472. * @param stride the stride (optional)
  5473. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5474. * @param instanced whether the buffer is instanced (optional)
  5475. * @param useBytes set to true if the stride in in bytes (optional)
  5476. */
  5477. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5478. /**
  5479. * Create a new VertexBuffer based on the current buffer
  5480. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5481. * @param offset defines offset in the buffer (0 by default)
  5482. * @param size defines the size in floats of attributes (position is 3 for instance)
  5483. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5484. * @param instanced defines if the vertex buffer contains indexed data
  5485. * @param useBytes defines if the offset and stride are in bytes
  5486. * @returns the new vertex buffer
  5487. */
  5488. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5489. /**
  5490. * Gets a boolean indicating if the Buffer is updatable?
  5491. * @returns true if the buffer is updatable
  5492. */
  5493. isUpdatable(): boolean;
  5494. /**
  5495. * Gets current buffer's data
  5496. * @returns a DataArray or null
  5497. */
  5498. getData(): Nullable<DataArray>;
  5499. /**
  5500. * Gets underlying native buffer
  5501. * @returns underlying native buffer
  5502. */
  5503. getBuffer(): Nullable<WebGLBuffer>;
  5504. /**
  5505. * Gets the stride in float32 units (i.e. byte stride / 4).
  5506. * May not be an integer if the byte stride is not divisible by 4.
  5507. * DEPRECATED. Use byteStride instead.
  5508. * @returns the stride in float32 units
  5509. */
  5510. getStrideSize(): number;
  5511. /**
  5512. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5513. * @param data defines the data to store
  5514. */
  5515. create(data?: Nullable<DataArray>): void;
  5516. /** @hidden */
  5517. _rebuild(): void;
  5518. /**
  5519. * Update current buffer data
  5520. * @param data defines the data to store
  5521. */
  5522. update(data: DataArray): void;
  5523. /**
  5524. * Updates the data directly.
  5525. * @param data the new data
  5526. * @param offset the new offset
  5527. * @param vertexCount the vertex count (optional)
  5528. * @param useBytes set to true if the offset is in bytes
  5529. */
  5530. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5531. /**
  5532. * Release all resources
  5533. */
  5534. dispose(): void;
  5535. }
  5536. /**
  5537. * Specialized buffer used to store vertex data
  5538. */
  5539. export class VertexBuffer {
  5540. /** @hidden */
  5541. _buffer: Buffer;
  5542. private _kind;
  5543. private _size;
  5544. private _ownsBuffer;
  5545. private _instanced;
  5546. private _instanceDivisor;
  5547. /**
  5548. * The byte type.
  5549. */
  5550. static readonly BYTE: number;
  5551. /**
  5552. * The unsigned byte type.
  5553. */
  5554. static readonly UNSIGNED_BYTE: number;
  5555. /**
  5556. * The short type.
  5557. */
  5558. static readonly SHORT: number;
  5559. /**
  5560. * The unsigned short type.
  5561. */
  5562. static readonly UNSIGNED_SHORT: number;
  5563. /**
  5564. * The integer type.
  5565. */
  5566. static readonly INT: number;
  5567. /**
  5568. * The unsigned integer type.
  5569. */
  5570. static readonly UNSIGNED_INT: number;
  5571. /**
  5572. * The float type.
  5573. */
  5574. static readonly FLOAT: number;
  5575. /**
  5576. * Gets or sets the instance divisor when in instanced mode
  5577. */
  5578. instanceDivisor: number;
  5579. /**
  5580. * Gets the byte stride.
  5581. */
  5582. readonly byteStride: number;
  5583. /**
  5584. * Gets the byte offset.
  5585. */
  5586. readonly byteOffset: number;
  5587. /**
  5588. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5589. */
  5590. readonly normalized: boolean;
  5591. /**
  5592. * Gets the data type of each component in the array.
  5593. */
  5594. readonly type: number;
  5595. /**
  5596. * Constructor
  5597. * @param engine the engine
  5598. * @param data the data to use for this vertex buffer
  5599. * @param kind the vertex buffer kind
  5600. * @param updatable whether the data is updatable
  5601. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5602. * @param stride the stride (optional)
  5603. * @param instanced whether the buffer is instanced (optional)
  5604. * @param offset the offset of the data (optional)
  5605. * @param size the number of components (optional)
  5606. * @param type the type of the component (optional)
  5607. * @param normalized whether the data contains normalized data (optional)
  5608. * @param useBytes set to true if stride and offset are in bytes (optional)
  5609. */
  5610. 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);
  5611. /** @hidden */
  5612. _rebuild(): void;
  5613. /**
  5614. * Returns the kind of the VertexBuffer (string)
  5615. * @returns a string
  5616. */
  5617. getKind(): string;
  5618. /**
  5619. * Gets a boolean indicating if the VertexBuffer is updatable?
  5620. * @returns true if the buffer is updatable
  5621. */
  5622. isUpdatable(): boolean;
  5623. /**
  5624. * Gets current buffer's data
  5625. * @returns a DataArray or null
  5626. */
  5627. getData(): Nullable<DataArray>;
  5628. /**
  5629. * Gets underlying native buffer
  5630. * @returns underlying native buffer
  5631. */
  5632. getBuffer(): Nullable<WebGLBuffer>;
  5633. /**
  5634. * Gets the stride in float32 units (i.e. byte stride / 4).
  5635. * May not be an integer if the byte stride is not divisible by 4.
  5636. * DEPRECATED. Use byteStride instead.
  5637. * @returns the stride in float32 units
  5638. */
  5639. getStrideSize(): number;
  5640. /**
  5641. * Returns the offset as a multiple of the type byte length.
  5642. * DEPRECATED. Use byteOffset instead.
  5643. * @returns the offset in bytes
  5644. */
  5645. getOffset(): number;
  5646. /**
  5647. * Returns the number of components per vertex attribute (integer)
  5648. * @returns the size in float
  5649. */
  5650. getSize(): number;
  5651. /**
  5652. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5653. * @returns true if this buffer is instanced
  5654. */
  5655. getIsInstanced(): boolean;
  5656. /**
  5657. * Returns the instancing divisor, zero for non-instanced (integer).
  5658. * @returns a number
  5659. */
  5660. getInstanceDivisor(): number;
  5661. /**
  5662. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5663. * @param data defines the data to store
  5664. */
  5665. create(data?: DataArray): void;
  5666. /**
  5667. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5668. * This function will create a new buffer if the current one is not updatable
  5669. * @param data defines the data to store
  5670. */
  5671. update(data: DataArray): void;
  5672. /**
  5673. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5674. * Returns the directly updated WebGLBuffer.
  5675. * @param data the new data
  5676. * @param offset the new offset
  5677. * @param useBytes set to true if the offset is in bytes
  5678. */
  5679. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5680. /**
  5681. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5682. */
  5683. dispose(): void;
  5684. /**
  5685. * Enumerates each value of this vertex buffer as numbers.
  5686. * @param count the number of values to enumerate
  5687. * @param callback the callback function called for each value
  5688. */
  5689. forEach(count: number, callback: (value: number, index: number) => void): void;
  5690. /**
  5691. * Positions
  5692. */
  5693. static readonly PositionKind: string;
  5694. /**
  5695. * Normals
  5696. */
  5697. static readonly NormalKind: string;
  5698. /**
  5699. * Tangents
  5700. */
  5701. static readonly TangentKind: string;
  5702. /**
  5703. * Texture coordinates
  5704. */
  5705. static readonly UVKind: string;
  5706. /**
  5707. * Texture coordinates 2
  5708. */
  5709. static readonly UV2Kind: string;
  5710. /**
  5711. * Texture coordinates 3
  5712. */
  5713. static readonly UV3Kind: string;
  5714. /**
  5715. * Texture coordinates 4
  5716. */
  5717. static readonly UV4Kind: string;
  5718. /**
  5719. * Texture coordinates 5
  5720. */
  5721. static readonly UV5Kind: string;
  5722. /**
  5723. * Texture coordinates 6
  5724. */
  5725. static readonly UV6Kind: string;
  5726. /**
  5727. * Colors
  5728. */
  5729. static readonly ColorKind: string;
  5730. /**
  5731. * Matrix indices (for bones)
  5732. */
  5733. static readonly MatricesIndicesKind: string;
  5734. /**
  5735. * Matrix weights (for bones)
  5736. */
  5737. static readonly MatricesWeightsKind: string;
  5738. /**
  5739. * Additional matrix indices (for bones)
  5740. */
  5741. static readonly MatricesIndicesExtraKind: string;
  5742. /**
  5743. * Additional matrix weights (for bones)
  5744. */
  5745. static readonly MatricesWeightsExtraKind: string;
  5746. /**
  5747. * Deduces the stride given a kind.
  5748. * @param kind The kind string to deduce
  5749. * @returns The deduced stride
  5750. */
  5751. static DeduceStride(kind: string): number;
  5752. /**
  5753. * Gets the byte length of the given type.
  5754. * @param type the type
  5755. * @returns the number of bytes
  5756. */
  5757. static GetTypeByteLength(type: number): number;
  5758. /**
  5759. * Enumerates each value of the given parameters as numbers.
  5760. * @param data the data to enumerate
  5761. * @param byteOffset the byte offset of the data
  5762. * @param byteStride the byte stride of the data
  5763. * @param componentCount the number of components per element
  5764. * @param componentType the type of the component
  5765. * @param count the total number of components
  5766. * @param normalized whether the data is normalized
  5767. * @param callback the callback function called for each value
  5768. */
  5769. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5770. private static _GetFloatValue;
  5771. }
  5772. }
  5773. declare module "babylonjs/Maths/sphericalPolynomial" {
  5774. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5775. /**
  5776. * Class representing spherical polynomial coefficients to the 3rd degree
  5777. */
  5778. export class SphericalPolynomial {
  5779. /**
  5780. * The x coefficients of the spherical polynomial
  5781. */
  5782. x: Vector3;
  5783. /**
  5784. * The y coefficients of the spherical polynomial
  5785. */
  5786. y: Vector3;
  5787. /**
  5788. * The z coefficients of the spherical polynomial
  5789. */
  5790. z: Vector3;
  5791. /**
  5792. * The xx coefficients of the spherical polynomial
  5793. */
  5794. xx: Vector3;
  5795. /**
  5796. * The yy coefficients of the spherical polynomial
  5797. */
  5798. yy: Vector3;
  5799. /**
  5800. * The zz coefficients of the spherical polynomial
  5801. */
  5802. zz: Vector3;
  5803. /**
  5804. * The xy coefficients of the spherical polynomial
  5805. */
  5806. xy: Vector3;
  5807. /**
  5808. * The yz coefficients of the spherical polynomial
  5809. */
  5810. yz: Vector3;
  5811. /**
  5812. * The zx coefficients of the spherical polynomial
  5813. */
  5814. zx: Vector3;
  5815. /**
  5816. * Adds an ambient color to the spherical polynomial
  5817. * @param color the color to add
  5818. */
  5819. addAmbient(color: Color3): void;
  5820. /**
  5821. * Scales the spherical polynomial by the given amount
  5822. * @param scale the amount to scale
  5823. */
  5824. scale(scale: number): void;
  5825. /**
  5826. * Gets the spherical polynomial from harmonics
  5827. * @param harmonics the spherical harmonics
  5828. * @returns the spherical polynomial
  5829. */
  5830. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5831. /**
  5832. * Constructs a spherical polynomial from an array.
  5833. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5834. * @returns the spherical polynomial
  5835. */
  5836. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5837. }
  5838. /**
  5839. * Class representing spherical harmonics coefficients to the 3rd degree
  5840. */
  5841. export class SphericalHarmonics {
  5842. /**
  5843. * The l0,0 coefficients of the spherical harmonics
  5844. */
  5845. l00: Vector3;
  5846. /**
  5847. * The l1,-1 coefficients of the spherical harmonics
  5848. */
  5849. l1_1: Vector3;
  5850. /**
  5851. * The l1,0 coefficients of the spherical harmonics
  5852. */
  5853. l10: Vector3;
  5854. /**
  5855. * The l1,1 coefficients of the spherical harmonics
  5856. */
  5857. l11: Vector3;
  5858. /**
  5859. * The l2,-2 coefficients of the spherical harmonics
  5860. */
  5861. l2_2: Vector3;
  5862. /**
  5863. * The l2,-1 coefficients of the spherical harmonics
  5864. */
  5865. l2_1: Vector3;
  5866. /**
  5867. * The l2,0 coefficients of the spherical harmonics
  5868. */
  5869. l20: Vector3;
  5870. /**
  5871. * The l2,1 coefficients of the spherical harmonics
  5872. */
  5873. l21: Vector3;
  5874. /**
  5875. * The l2,2 coefficients of the spherical harmonics
  5876. */
  5877. lL22: Vector3;
  5878. /**
  5879. * Adds a light to the spherical harmonics
  5880. * @param direction the direction of the light
  5881. * @param color the color of the light
  5882. * @param deltaSolidAngle the delta solid angle of the light
  5883. */
  5884. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5885. /**
  5886. * Scales the spherical harmonics by the given amount
  5887. * @param scale the amount to scale
  5888. */
  5889. scale(scale: number): void;
  5890. /**
  5891. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5892. *
  5893. * ```
  5894. * E_lm = A_l * L_lm
  5895. * ```
  5896. *
  5897. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5898. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5899. * the scaling factors are given in equation 9.
  5900. */
  5901. convertIncidentRadianceToIrradiance(): void;
  5902. /**
  5903. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5904. *
  5905. * ```
  5906. * L = (1/pi) * E * rho
  5907. * ```
  5908. *
  5909. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5910. */
  5911. convertIrradianceToLambertianRadiance(): void;
  5912. /**
  5913. * Gets the spherical harmonics from polynomial
  5914. * @param polynomial the spherical polynomial
  5915. * @returns the spherical harmonics
  5916. */
  5917. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5918. /**
  5919. * Constructs a spherical harmonics from an array.
  5920. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5921. * @returns the spherical harmonics
  5922. */
  5923. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5924. }
  5925. }
  5926. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  5927. import { Nullable } from "babylonjs/types";
  5928. /**
  5929. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5930. */
  5931. export interface CubeMapInfo {
  5932. /**
  5933. * The pixel array for the front face.
  5934. * This is stored in format, left to right, up to down format.
  5935. */
  5936. front: Nullable<ArrayBufferView>;
  5937. /**
  5938. * The pixel array for the back face.
  5939. * This is stored in format, left to right, up to down format.
  5940. */
  5941. back: Nullable<ArrayBufferView>;
  5942. /**
  5943. * The pixel array for the left face.
  5944. * This is stored in format, left to right, up to down format.
  5945. */
  5946. left: Nullable<ArrayBufferView>;
  5947. /**
  5948. * The pixel array for the right face.
  5949. * This is stored in format, left to right, up to down format.
  5950. */
  5951. right: Nullable<ArrayBufferView>;
  5952. /**
  5953. * The pixel array for the up face.
  5954. * This is stored in format, left to right, up to down format.
  5955. */
  5956. up: Nullable<ArrayBufferView>;
  5957. /**
  5958. * The pixel array for the down face.
  5959. * This is stored in format, left to right, up to down format.
  5960. */
  5961. down: Nullable<ArrayBufferView>;
  5962. /**
  5963. * The size of the cubemap stored.
  5964. *
  5965. * Each faces will be size * size pixels.
  5966. */
  5967. size: number;
  5968. /**
  5969. * The format of the texture.
  5970. *
  5971. * RGBA, RGB.
  5972. */
  5973. format: number;
  5974. /**
  5975. * The type of the texture data.
  5976. *
  5977. * UNSIGNED_INT, FLOAT.
  5978. */
  5979. type: number;
  5980. /**
  5981. * Specifies whether the texture is in gamma space.
  5982. */
  5983. gammaSpace: boolean;
  5984. }
  5985. /**
  5986. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5987. */
  5988. export class PanoramaToCubeMapTools {
  5989. private static FACE_FRONT;
  5990. private static FACE_BACK;
  5991. private static FACE_RIGHT;
  5992. private static FACE_LEFT;
  5993. private static FACE_DOWN;
  5994. private static FACE_UP;
  5995. /**
  5996. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5997. *
  5998. * @param float32Array The source data.
  5999. * @param inputWidth The width of the input panorama.
  6000. * @param inputHeight The height of the input panorama.
  6001. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6002. * @return The cubemap data
  6003. */
  6004. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6005. private static CreateCubemapTexture;
  6006. private static CalcProjectionSpherical;
  6007. }
  6008. }
  6009. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  6010. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6011. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6012. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  6013. /**
  6014. * Helper class dealing with the extraction of spherical polynomial dataArray
  6015. * from a cube map.
  6016. */
  6017. export class CubeMapToSphericalPolynomialTools {
  6018. private static FileFaces;
  6019. /**
  6020. * Converts a texture to the according Spherical Polynomial data.
  6021. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6022. *
  6023. * @param texture The texture to extract the information from.
  6024. * @return The Spherical Polynomial data.
  6025. */
  6026. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6027. /**
  6028. * Converts a cubemap to the according Spherical Polynomial data.
  6029. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6030. *
  6031. * @param cubeInfo The Cube map to extract the information from.
  6032. * @return The Spherical Polynomial data.
  6033. */
  6034. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6035. }
  6036. }
  6037. declare module "babylonjs/Engines/engineStore" {
  6038. import { Nullable } from "babylonjs/types";
  6039. import { Engine } from "babylonjs/Engines/engine";
  6040. import { Scene } from "babylonjs/scene";
  6041. /**
  6042. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6043. * during the life time of the application.
  6044. */
  6045. export class EngineStore {
  6046. /** Gets the list of created engines */
  6047. static Instances: import("babylonjs/Engines/engine").Engine[];
  6048. /**
  6049. * Gets the latest created engine
  6050. */
  6051. static readonly LastCreatedEngine: Nullable<Engine>;
  6052. /**
  6053. * Gets the latest created scene
  6054. */
  6055. static readonly LastCreatedScene: Nullable<Scene>;
  6056. }
  6057. }
  6058. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  6059. /**
  6060. * Define options used to create a render target texture
  6061. */
  6062. export class RenderTargetCreationOptions {
  6063. /**
  6064. * Specifies is mipmaps must be generated
  6065. */
  6066. generateMipMaps?: boolean;
  6067. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6068. generateDepthBuffer?: boolean;
  6069. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6070. generateStencilBuffer?: boolean;
  6071. /** Defines texture type (int by default) */
  6072. type?: number;
  6073. /** Defines sampling mode (trilinear by default) */
  6074. samplingMode?: number;
  6075. /** Defines format (RGBA by default) */
  6076. format?: number;
  6077. }
  6078. }
  6079. declare module "babylonjs/States/alphaCullingState" {
  6080. /**
  6081. * @hidden
  6082. **/
  6083. export class _AlphaState {
  6084. private _isAlphaBlendDirty;
  6085. private _isBlendFunctionParametersDirty;
  6086. private _isBlendEquationParametersDirty;
  6087. private _isBlendConstantsDirty;
  6088. private _alphaBlend;
  6089. private _blendFunctionParameters;
  6090. private _blendEquationParameters;
  6091. private _blendConstants;
  6092. /**
  6093. * Initializes the state.
  6094. */
  6095. constructor();
  6096. readonly isDirty: boolean;
  6097. alphaBlend: boolean;
  6098. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6099. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6100. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6101. reset(): void;
  6102. apply(gl: WebGLRenderingContext): void;
  6103. }
  6104. }
  6105. declare module "babylonjs/States/depthCullingState" {
  6106. import { Nullable } from "babylonjs/types";
  6107. /**
  6108. * @hidden
  6109. **/
  6110. export class _DepthCullingState {
  6111. private _isDepthTestDirty;
  6112. private _isDepthMaskDirty;
  6113. private _isDepthFuncDirty;
  6114. private _isCullFaceDirty;
  6115. private _isCullDirty;
  6116. private _isZOffsetDirty;
  6117. private _isFrontFaceDirty;
  6118. private _depthTest;
  6119. private _depthMask;
  6120. private _depthFunc;
  6121. private _cull;
  6122. private _cullFace;
  6123. private _zOffset;
  6124. private _frontFace;
  6125. /**
  6126. * Initializes the state.
  6127. */
  6128. constructor();
  6129. readonly isDirty: boolean;
  6130. zOffset: number;
  6131. cullFace: Nullable<number>;
  6132. cull: Nullable<boolean>;
  6133. depthFunc: Nullable<number>;
  6134. depthMask: boolean;
  6135. depthTest: boolean;
  6136. frontFace: Nullable<number>;
  6137. reset(): void;
  6138. apply(gl: WebGLRenderingContext): void;
  6139. }
  6140. }
  6141. declare module "babylonjs/States/stencilState" {
  6142. /**
  6143. * @hidden
  6144. **/
  6145. export class _StencilState {
  6146. /** 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 */
  6147. static readonly ALWAYS: number;
  6148. /** Passed to stencilOperation to specify that stencil value must be kept */
  6149. static readonly KEEP: number;
  6150. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6151. static readonly REPLACE: number;
  6152. private _isStencilTestDirty;
  6153. private _isStencilMaskDirty;
  6154. private _isStencilFuncDirty;
  6155. private _isStencilOpDirty;
  6156. private _stencilTest;
  6157. private _stencilMask;
  6158. private _stencilFunc;
  6159. private _stencilFuncRef;
  6160. private _stencilFuncMask;
  6161. private _stencilOpStencilFail;
  6162. private _stencilOpDepthFail;
  6163. private _stencilOpStencilDepthPass;
  6164. readonly isDirty: boolean;
  6165. stencilFunc: number;
  6166. stencilFuncRef: number;
  6167. stencilFuncMask: number;
  6168. stencilOpStencilFail: number;
  6169. stencilOpDepthFail: number;
  6170. stencilOpStencilDepthPass: number;
  6171. stencilMask: number;
  6172. stencilTest: boolean;
  6173. constructor();
  6174. reset(): void;
  6175. apply(gl: WebGLRenderingContext): void;
  6176. }
  6177. }
  6178. declare module "babylonjs/States/index" {
  6179. export * from "babylonjs/States/alphaCullingState";
  6180. export * from "babylonjs/States/depthCullingState";
  6181. export * from "babylonjs/States/stencilState";
  6182. }
  6183. declare module "babylonjs/Instrumentation/timeToken" {
  6184. import { Nullable } from "babylonjs/types";
  6185. /**
  6186. * @hidden
  6187. **/
  6188. export class _TimeToken {
  6189. _startTimeQuery: Nullable<WebGLQuery>;
  6190. _endTimeQuery: Nullable<WebGLQuery>;
  6191. _timeElapsedQuery: Nullable<WebGLQuery>;
  6192. _timeElapsedQueryEnded: boolean;
  6193. }
  6194. }
  6195. declare module "babylonjs/Materials/Textures/internalTexture" {
  6196. import { Observable } from "babylonjs/Misc/observable";
  6197. import { Nullable, int } from "babylonjs/types";
  6198. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6199. import { Engine } from "babylonjs/Engines/engine";
  6200. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6201. /**
  6202. * Class used to store data associated with WebGL texture data for the engine
  6203. * This class should not be used directly
  6204. */
  6205. export class InternalTexture {
  6206. /** hidden */
  6207. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6208. /**
  6209. * The source of the texture data is unknown
  6210. */
  6211. static DATASOURCE_UNKNOWN: number;
  6212. /**
  6213. * Texture data comes from an URL
  6214. */
  6215. static DATASOURCE_URL: number;
  6216. /**
  6217. * Texture data is only used for temporary storage
  6218. */
  6219. static DATASOURCE_TEMP: number;
  6220. /**
  6221. * Texture data comes from raw data (ArrayBuffer)
  6222. */
  6223. static DATASOURCE_RAW: number;
  6224. /**
  6225. * Texture content is dynamic (video or dynamic texture)
  6226. */
  6227. static DATASOURCE_DYNAMIC: number;
  6228. /**
  6229. * Texture content is generated by rendering to it
  6230. */
  6231. static DATASOURCE_RENDERTARGET: number;
  6232. /**
  6233. * Texture content is part of a multi render target process
  6234. */
  6235. static DATASOURCE_MULTIRENDERTARGET: number;
  6236. /**
  6237. * Texture data comes from a cube data file
  6238. */
  6239. static DATASOURCE_CUBE: number;
  6240. /**
  6241. * Texture data comes from a raw cube data
  6242. */
  6243. static DATASOURCE_CUBERAW: number;
  6244. /**
  6245. * Texture data come from a prefiltered cube data file
  6246. */
  6247. static DATASOURCE_CUBEPREFILTERED: number;
  6248. /**
  6249. * Texture content is raw 3D data
  6250. */
  6251. static DATASOURCE_RAW3D: number;
  6252. /**
  6253. * Texture content is a depth texture
  6254. */
  6255. static DATASOURCE_DEPTHTEXTURE: number;
  6256. /**
  6257. * Texture data comes from a raw cube data encoded with RGBD
  6258. */
  6259. static DATASOURCE_CUBERAW_RGBD: number;
  6260. /**
  6261. * Defines if the texture is ready
  6262. */
  6263. isReady: boolean;
  6264. /**
  6265. * Defines if the texture is a cube texture
  6266. */
  6267. isCube: boolean;
  6268. /**
  6269. * Defines if the texture contains 3D data
  6270. */
  6271. is3D: boolean;
  6272. /**
  6273. * Defines if the texture contains multiview data
  6274. */
  6275. isMultiview: boolean;
  6276. /**
  6277. * Gets the URL used to load this texture
  6278. */
  6279. url: string;
  6280. /**
  6281. * Gets the sampling mode of the texture
  6282. */
  6283. samplingMode: number;
  6284. /**
  6285. * Gets a boolean indicating if the texture needs mipmaps generation
  6286. */
  6287. generateMipMaps: boolean;
  6288. /**
  6289. * Gets the number of samples used by the texture (WebGL2+ only)
  6290. */
  6291. samples: number;
  6292. /**
  6293. * Gets the type of the texture (int, float...)
  6294. */
  6295. type: number;
  6296. /**
  6297. * Gets the format of the texture (RGB, RGBA...)
  6298. */
  6299. format: number;
  6300. /**
  6301. * Observable called when the texture is loaded
  6302. */
  6303. onLoadedObservable: Observable<InternalTexture>;
  6304. /**
  6305. * Gets the width of the texture
  6306. */
  6307. width: number;
  6308. /**
  6309. * Gets the height of the texture
  6310. */
  6311. height: number;
  6312. /**
  6313. * Gets the depth of the texture
  6314. */
  6315. depth: number;
  6316. /**
  6317. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6318. */
  6319. baseWidth: number;
  6320. /**
  6321. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6322. */
  6323. baseHeight: number;
  6324. /**
  6325. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6326. */
  6327. baseDepth: number;
  6328. /**
  6329. * Gets a boolean indicating if the texture is inverted on Y axis
  6330. */
  6331. invertY: boolean;
  6332. /** @hidden */
  6333. _invertVScale: boolean;
  6334. /** @hidden */
  6335. _associatedChannel: number;
  6336. /** @hidden */
  6337. _dataSource: number;
  6338. /** @hidden */
  6339. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6340. /** @hidden */
  6341. _bufferView: Nullable<ArrayBufferView>;
  6342. /** @hidden */
  6343. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6344. /** @hidden */
  6345. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6346. /** @hidden */
  6347. _size: number;
  6348. /** @hidden */
  6349. _extension: string;
  6350. /** @hidden */
  6351. _files: Nullable<string[]>;
  6352. /** @hidden */
  6353. _workingCanvas: HTMLCanvasElement;
  6354. /** @hidden */
  6355. _workingContext: CanvasRenderingContext2D;
  6356. /** @hidden */
  6357. _framebuffer: Nullable<WebGLFramebuffer>;
  6358. /** @hidden */
  6359. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6360. /** @hidden */
  6361. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6362. /** @hidden */
  6363. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6364. /** @hidden */
  6365. _attachments: Nullable<number[]>;
  6366. /** @hidden */
  6367. _cachedCoordinatesMode: Nullable<number>;
  6368. /** @hidden */
  6369. _cachedWrapU: Nullable<number>;
  6370. /** @hidden */
  6371. _cachedWrapV: Nullable<number>;
  6372. /** @hidden */
  6373. _cachedWrapR: Nullable<number>;
  6374. /** @hidden */
  6375. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6376. /** @hidden */
  6377. _isDisabled: boolean;
  6378. /** @hidden */
  6379. _compression: Nullable<string>;
  6380. /** @hidden */
  6381. _generateStencilBuffer: boolean;
  6382. /** @hidden */
  6383. _generateDepthBuffer: boolean;
  6384. /** @hidden */
  6385. _comparisonFunction: number;
  6386. /** @hidden */
  6387. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6388. /** @hidden */
  6389. _lodGenerationScale: number;
  6390. /** @hidden */
  6391. _lodGenerationOffset: number;
  6392. /** @hidden */
  6393. _colorTextureArray: Nullable<WebGLTexture>;
  6394. /** @hidden */
  6395. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6396. /** @hidden */
  6397. _lodTextureHigh: BaseTexture;
  6398. /** @hidden */
  6399. _lodTextureMid: BaseTexture;
  6400. /** @hidden */
  6401. _lodTextureLow: BaseTexture;
  6402. /** @hidden */
  6403. _isRGBD: boolean;
  6404. /** @hidden */
  6405. _webGLTexture: Nullable<WebGLTexture>;
  6406. /** @hidden */
  6407. _references: number;
  6408. private _engine;
  6409. /**
  6410. * Gets the Engine the texture belongs to.
  6411. * @returns The babylon engine
  6412. */
  6413. getEngine(): Engine;
  6414. /**
  6415. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6416. */
  6417. readonly dataSource: number;
  6418. /**
  6419. * Creates a new InternalTexture
  6420. * @param engine defines the engine to use
  6421. * @param dataSource defines the type of data that will be used
  6422. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6423. */
  6424. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6425. /**
  6426. * Increments the number of references (ie. the number of Texture that point to it)
  6427. */
  6428. incrementReferences(): void;
  6429. /**
  6430. * Change the size of the texture (not the size of the content)
  6431. * @param width defines the new width
  6432. * @param height defines the new height
  6433. * @param depth defines the new depth (1 by default)
  6434. */
  6435. updateSize(width: int, height: int, depth?: int): void;
  6436. /** @hidden */
  6437. _rebuild(): void;
  6438. /** @hidden */
  6439. _swapAndDie(target: InternalTexture): void;
  6440. /**
  6441. * Dispose the current allocated resources
  6442. */
  6443. dispose(): void;
  6444. }
  6445. }
  6446. declare module "babylonjs/Animations/easing" {
  6447. /**
  6448. * This represents the main contract an easing function should follow.
  6449. * Easing functions are used throughout the animation system.
  6450. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6451. */
  6452. export interface IEasingFunction {
  6453. /**
  6454. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6455. * of the easing function.
  6456. * The link below provides some of the most common examples of easing functions.
  6457. * @see https://easings.net/
  6458. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6459. * @returns the corresponding value on the curve defined by the easing function
  6460. */
  6461. ease(gradient: number): number;
  6462. }
  6463. /**
  6464. * Base class used for every default easing function.
  6465. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6466. */
  6467. export class EasingFunction implements IEasingFunction {
  6468. /**
  6469. * Interpolation follows the mathematical formula associated with the easing function.
  6470. */
  6471. static readonly EASINGMODE_EASEIN: number;
  6472. /**
  6473. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6474. */
  6475. static readonly EASINGMODE_EASEOUT: number;
  6476. /**
  6477. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6478. */
  6479. static readonly EASINGMODE_EASEINOUT: number;
  6480. private _easingMode;
  6481. /**
  6482. * Sets the easing mode of the current function.
  6483. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6484. */
  6485. setEasingMode(easingMode: number): void;
  6486. /**
  6487. * Gets the current easing mode.
  6488. * @returns the easing mode
  6489. */
  6490. getEasingMode(): number;
  6491. /**
  6492. * @hidden
  6493. */
  6494. easeInCore(gradient: number): number;
  6495. /**
  6496. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6497. * of the easing function.
  6498. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6499. * @returns the corresponding value on the curve defined by the easing function
  6500. */
  6501. ease(gradient: number): number;
  6502. }
  6503. /**
  6504. * Easing function with a circle shape (see link below).
  6505. * @see https://easings.net/#easeInCirc
  6506. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6507. */
  6508. export class CircleEase extends EasingFunction implements IEasingFunction {
  6509. /** @hidden */
  6510. easeInCore(gradient: number): number;
  6511. }
  6512. /**
  6513. * Easing function with a ease back shape (see link below).
  6514. * @see https://easings.net/#easeInBack
  6515. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6516. */
  6517. export class BackEase extends EasingFunction implements IEasingFunction {
  6518. /** Defines the amplitude of the function */
  6519. amplitude: number;
  6520. /**
  6521. * Instantiates a back ease easing
  6522. * @see https://easings.net/#easeInBack
  6523. * @param amplitude Defines the amplitude of the function
  6524. */
  6525. constructor(
  6526. /** Defines the amplitude of the function */
  6527. amplitude?: number);
  6528. /** @hidden */
  6529. easeInCore(gradient: number): number;
  6530. }
  6531. /**
  6532. * Easing function with a bouncing shape (see link below).
  6533. * @see https://easings.net/#easeInBounce
  6534. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6535. */
  6536. export class BounceEase extends EasingFunction implements IEasingFunction {
  6537. /** Defines the number of bounces */
  6538. bounces: number;
  6539. /** Defines the amplitude of the bounce */
  6540. bounciness: number;
  6541. /**
  6542. * Instantiates a bounce easing
  6543. * @see https://easings.net/#easeInBounce
  6544. * @param bounces Defines the number of bounces
  6545. * @param bounciness Defines the amplitude of the bounce
  6546. */
  6547. constructor(
  6548. /** Defines the number of bounces */
  6549. bounces?: number,
  6550. /** Defines the amplitude of the bounce */
  6551. bounciness?: number);
  6552. /** @hidden */
  6553. easeInCore(gradient: number): number;
  6554. }
  6555. /**
  6556. * Easing function with a power of 3 shape (see link below).
  6557. * @see https://easings.net/#easeInCubic
  6558. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6559. */
  6560. export class CubicEase extends EasingFunction implements IEasingFunction {
  6561. /** @hidden */
  6562. easeInCore(gradient: number): number;
  6563. }
  6564. /**
  6565. * Easing function with an elastic shape (see link below).
  6566. * @see https://easings.net/#easeInElastic
  6567. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6568. */
  6569. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6570. /** Defines the number of oscillations*/
  6571. oscillations: number;
  6572. /** Defines the amplitude of the oscillations*/
  6573. springiness: number;
  6574. /**
  6575. * Instantiates an elastic easing function
  6576. * @see https://easings.net/#easeInElastic
  6577. * @param oscillations Defines the number of oscillations
  6578. * @param springiness Defines the amplitude of the oscillations
  6579. */
  6580. constructor(
  6581. /** Defines the number of oscillations*/
  6582. oscillations?: number,
  6583. /** Defines the amplitude of the oscillations*/
  6584. springiness?: number);
  6585. /** @hidden */
  6586. easeInCore(gradient: number): number;
  6587. }
  6588. /**
  6589. * Easing function with an exponential shape (see link below).
  6590. * @see https://easings.net/#easeInExpo
  6591. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6592. */
  6593. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6594. /** Defines the exponent of the function */
  6595. exponent: number;
  6596. /**
  6597. * Instantiates an exponential easing function
  6598. * @see https://easings.net/#easeInExpo
  6599. * @param exponent Defines the exponent of the function
  6600. */
  6601. constructor(
  6602. /** Defines the exponent of the function */
  6603. exponent?: number);
  6604. /** @hidden */
  6605. easeInCore(gradient: number): number;
  6606. }
  6607. /**
  6608. * Easing function with a power shape (see link below).
  6609. * @see https://easings.net/#easeInQuad
  6610. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6611. */
  6612. export class PowerEase extends EasingFunction implements IEasingFunction {
  6613. /** Defines the power of the function */
  6614. power: number;
  6615. /**
  6616. * Instantiates an power base easing function
  6617. * @see https://easings.net/#easeInQuad
  6618. * @param power Defines the power of the function
  6619. */
  6620. constructor(
  6621. /** Defines the power of the function */
  6622. power?: number);
  6623. /** @hidden */
  6624. easeInCore(gradient: number): number;
  6625. }
  6626. /**
  6627. * Easing function with a power of 2 shape (see link below).
  6628. * @see https://easings.net/#easeInQuad
  6629. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6630. */
  6631. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6632. /** @hidden */
  6633. easeInCore(gradient: number): number;
  6634. }
  6635. /**
  6636. * Easing function with a power of 4 shape (see link below).
  6637. * @see https://easings.net/#easeInQuart
  6638. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6639. */
  6640. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6641. /** @hidden */
  6642. easeInCore(gradient: number): number;
  6643. }
  6644. /**
  6645. * Easing function with a power of 5 shape (see link below).
  6646. * @see https://easings.net/#easeInQuint
  6647. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6648. */
  6649. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6650. /** @hidden */
  6651. easeInCore(gradient: number): number;
  6652. }
  6653. /**
  6654. * Easing function with a sin shape (see link below).
  6655. * @see https://easings.net/#easeInSine
  6656. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6657. */
  6658. export class SineEase extends EasingFunction implements IEasingFunction {
  6659. /** @hidden */
  6660. easeInCore(gradient: number): number;
  6661. }
  6662. /**
  6663. * Easing function with a bezier shape (see link below).
  6664. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6665. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6666. */
  6667. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6668. /** Defines the x component of the start tangent in the bezier curve */
  6669. x1: number;
  6670. /** Defines the y component of the start tangent in the bezier curve */
  6671. y1: number;
  6672. /** Defines the x component of the end tangent in the bezier curve */
  6673. x2: number;
  6674. /** Defines the y component of the end tangent in the bezier curve */
  6675. y2: number;
  6676. /**
  6677. * Instantiates a bezier function
  6678. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6679. * @param x1 Defines the x component of the start tangent in the bezier curve
  6680. * @param y1 Defines the y component of the start tangent in the bezier curve
  6681. * @param x2 Defines the x component of the end tangent in the bezier curve
  6682. * @param y2 Defines the y component of the end tangent in the bezier curve
  6683. */
  6684. constructor(
  6685. /** Defines the x component of the start tangent in the bezier curve */
  6686. x1?: number,
  6687. /** Defines the y component of the start tangent in the bezier curve */
  6688. y1?: number,
  6689. /** Defines the x component of the end tangent in the bezier curve */
  6690. x2?: number,
  6691. /** Defines the y component of the end tangent in the bezier curve */
  6692. y2?: number);
  6693. /** @hidden */
  6694. easeInCore(gradient: number): number;
  6695. }
  6696. }
  6697. declare module "babylonjs/Animations/animationKey" {
  6698. /**
  6699. * Defines an interface which represents an animation key frame
  6700. */
  6701. export interface IAnimationKey {
  6702. /**
  6703. * Frame of the key frame
  6704. */
  6705. frame: number;
  6706. /**
  6707. * Value at the specifies key frame
  6708. */
  6709. value: any;
  6710. /**
  6711. * The input tangent for the cubic hermite spline
  6712. */
  6713. inTangent?: any;
  6714. /**
  6715. * The output tangent for the cubic hermite spline
  6716. */
  6717. outTangent?: any;
  6718. /**
  6719. * The animation interpolation type
  6720. */
  6721. interpolation?: AnimationKeyInterpolation;
  6722. }
  6723. /**
  6724. * Enum for the animation key frame interpolation type
  6725. */
  6726. export enum AnimationKeyInterpolation {
  6727. /**
  6728. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6729. */
  6730. STEP = 1
  6731. }
  6732. }
  6733. declare module "babylonjs/Animations/animationRange" {
  6734. /**
  6735. * Represents the range of an animation
  6736. */
  6737. export class AnimationRange {
  6738. /**The name of the animation range**/
  6739. name: string;
  6740. /**The starting frame of the animation */
  6741. from: number;
  6742. /**The ending frame of the animation*/
  6743. to: number;
  6744. /**
  6745. * Initializes the range of an animation
  6746. * @param name The name of the animation range
  6747. * @param from The starting frame of the animation
  6748. * @param to The ending frame of the animation
  6749. */
  6750. constructor(
  6751. /**The name of the animation range**/
  6752. name: string,
  6753. /**The starting frame of the animation */
  6754. from: number,
  6755. /**The ending frame of the animation*/
  6756. to: number);
  6757. /**
  6758. * Makes a copy of the animation range
  6759. * @returns A copy of the animation range
  6760. */
  6761. clone(): AnimationRange;
  6762. }
  6763. }
  6764. declare module "babylonjs/Animations/animationEvent" {
  6765. /**
  6766. * Composed of a frame, and an action function
  6767. */
  6768. export class AnimationEvent {
  6769. /** The frame for which the event is triggered **/
  6770. frame: number;
  6771. /** The event to perform when triggered **/
  6772. action: (currentFrame: number) => void;
  6773. /** Specifies if the event should be triggered only once**/
  6774. onlyOnce?: boolean | undefined;
  6775. /**
  6776. * Specifies if the animation event is done
  6777. */
  6778. isDone: boolean;
  6779. /**
  6780. * Initializes the animation event
  6781. * @param frame The frame for which the event is triggered
  6782. * @param action The event to perform when triggered
  6783. * @param onlyOnce Specifies if the event should be triggered only once
  6784. */
  6785. constructor(
  6786. /** The frame for which the event is triggered **/
  6787. frame: number,
  6788. /** The event to perform when triggered **/
  6789. action: (currentFrame: number) => void,
  6790. /** Specifies if the event should be triggered only once**/
  6791. onlyOnce?: boolean | undefined);
  6792. /** @hidden */
  6793. _clone(): AnimationEvent;
  6794. }
  6795. }
  6796. declare module "babylonjs/Behaviors/behavior" {
  6797. import { Nullable } from "babylonjs/types";
  6798. /**
  6799. * Interface used to define a behavior
  6800. */
  6801. export interface Behavior<T> {
  6802. /** gets or sets behavior's name */
  6803. name: string;
  6804. /**
  6805. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6806. */
  6807. init(): void;
  6808. /**
  6809. * Called when the behavior is attached to a target
  6810. * @param target defines the target where the behavior is attached to
  6811. */
  6812. attach(target: T): void;
  6813. /**
  6814. * Called when the behavior is detached from its target
  6815. */
  6816. detach(): void;
  6817. }
  6818. /**
  6819. * Interface implemented by classes supporting behaviors
  6820. */
  6821. export interface IBehaviorAware<T> {
  6822. /**
  6823. * Attach a behavior
  6824. * @param behavior defines the behavior to attach
  6825. * @returns the current host
  6826. */
  6827. addBehavior(behavior: Behavior<T>): T;
  6828. /**
  6829. * Remove a behavior from the current object
  6830. * @param behavior defines the behavior to detach
  6831. * @returns the current host
  6832. */
  6833. removeBehavior(behavior: Behavior<T>): T;
  6834. /**
  6835. * Gets a behavior using its name to search
  6836. * @param name defines the name to search
  6837. * @returns the behavior or null if not found
  6838. */
  6839. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6840. }
  6841. }
  6842. declare module "babylonjs/Collisions/intersectionInfo" {
  6843. import { Nullable } from "babylonjs/types";
  6844. /**
  6845. * @hidden
  6846. */
  6847. export class IntersectionInfo {
  6848. bu: Nullable<number>;
  6849. bv: Nullable<number>;
  6850. distance: number;
  6851. faceId: number;
  6852. subMeshId: number;
  6853. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6854. }
  6855. }
  6856. declare module "babylonjs/Culling/boundingSphere" {
  6857. import { DeepImmutable } from "babylonjs/types";
  6858. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6859. /**
  6860. * Class used to store bounding sphere information
  6861. */
  6862. export class BoundingSphere {
  6863. /**
  6864. * Gets the center of the bounding sphere in local space
  6865. */
  6866. readonly center: Vector3;
  6867. /**
  6868. * Radius of the bounding sphere in local space
  6869. */
  6870. radius: number;
  6871. /**
  6872. * Gets the center of the bounding sphere in world space
  6873. */
  6874. readonly centerWorld: Vector3;
  6875. /**
  6876. * Radius of the bounding sphere in world space
  6877. */
  6878. radiusWorld: number;
  6879. /**
  6880. * Gets the minimum vector in local space
  6881. */
  6882. readonly minimum: Vector3;
  6883. /**
  6884. * Gets the maximum vector in local space
  6885. */
  6886. readonly maximum: Vector3;
  6887. private _worldMatrix;
  6888. private static readonly TmpVector3;
  6889. /**
  6890. * Creates a new bounding sphere
  6891. * @param min defines the minimum vector (in local space)
  6892. * @param max defines the maximum vector (in local space)
  6893. * @param worldMatrix defines the new world matrix
  6894. */
  6895. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6896. /**
  6897. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6898. * @param min defines the new minimum vector (in local space)
  6899. * @param max defines the new maximum vector (in local space)
  6900. * @param worldMatrix defines the new world matrix
  6901. */
  6902. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6903. /**
  6904. * Scale the current bounding sphere by applying a scale factor
  6905. * @param factor defines the scale factor to apply
  6906. * @returns the current bounding box
  6907. */
  6908. scale(factor: number): BoundingSphere;
  6909. /**
  6910. * Gets the world matrix of the bounding box
  6911. * @returns a matrix
  6912. */
  6913. getWorldMatrix(): DeepImmutable<Matrix>;
  6914. /** @hidden */
  6915. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6916. /**
  6917. * Tests if the bounding sphere is intersecting the frustum planes
  6918. * @param frustumPlanes defines the frustum planes to test
  6919. * @returns true if there is an intersection
  6920. */
  6921. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6922. /**
  6923. * Tests if the bounding sphere center is in between the frustum planes.
  6924. * Used for optimistic fast inclusion.
  6925. * @param frustumPlanes defines the frustum planes to test
  6926. * @returns true if the sphere center is in between the frustum planes
  6927. */
  6928. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6929. /**
  6930. * Tests if a point is inside the bounding sphere
  6931. * @param point defines the point to test
  6932. * @returns true if the point is inside the bounding sphere
  6933. */
  6934. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6935. /**
  6936. * Checks if two sphere intersct
  6937. * @param sphere0 sphere 0
  6938. * @param sphere1 sphere 1
  6939. * @returns true if the speres intersect
  6940. */
  6941. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6942. }
  6943. }
  6944. declare module "babylonjs/Culling/boundingBox" {
  6945. import { DeepImmutable } from "babylonjs/types";
  6946. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6947. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6948. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6949. /**
  6950. * Class used to store bounding box information
  6951. */
  6952. export class BoundingBox implements ICullable {
  6953. /**
  6954. * Gets the 8 vectors representing the bounding box in local space
  6955. */
  6956. readonly vectors: Vector3[];
  6957. /**
  6958. * Gets the center of the bounding box in local space
  6959. */
  6960. readonly center: Vector3;
  6961. /**
  6962. * Gets the center of the bounding box in world space
  6963. */
  6964. readonly centerWorld: Vector3;
  6965. /**
  6966. * Gets the extend size in local space
  6967. */
  6968. readonly extendSize: Vector3;
  6969. /**
  6970. * Gets the extend size in world space
  6971. */
  6972. readonly extendSizeWorld: Vector3;
  6973. /**
  6974. * Gets the OBB (object bounding box) directions
  6975. */
  6976. readonly directions: Vector3[];
  6977. /**
  6978. * Gets the 8 vectors representing the bounding box in world space
  6979. */
  6980. readonly vectorsWorld: Vector3[];
  6981. /**
  6982. * Gets the minimum vector in world space
  6983. */
  6984. readonly minimumWorld: Vector3;
  6985. /**
  6986. * Gets the maximum vector in world space
  6987. */
  6988. readonly maximumWorld: Vector3;
  6989. /**
  6990. * Gets the minimum vector in local space
  6991. */
  6992. readonly minimum: Vector3;
  6993. /**
  6994. * Gets the maximum vector in local space
  6995. */
  6996. readonly maximum: Vector3;
  6997. private _worldMatrix;
  6998. private static readonly TmpVector3;
  6999. /**
  7000. * @hidden
  7001. */
  7002. _tag: number;
  7003. /**
  7004. * Creates a new bounding box
  7005. * @param min defines the minimum vector (in local space)
  7006. * @param max defines the maximum vector (in local space)
  7007. * @param worldMatrix defines the new world matrix
  7008. */
  7009. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7010. /**
  7011. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7012. * @param min defines the new minimum vector (in local space)
  7013. * @param max defines the new maximum vector (in local space)
  7014. * @param worldMatrix defines the new world matrix
  7015. */
  7016. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7017. /**
  7018. * Scale the current bounding box by applying a scale factor
  7019. * @param factor defines the scale factor to apply
  7020. * @returns the current bounding box
  7021. */
  7022. scale(factor: number): BoundingBox;
  7023. /**
  7024. * Gets the world matrix of the bounding box
  7025. * @returns a matrix
  7026. */
  7027. getWorldMatrix(): DeepImmutable<Matrix>;
  7028. /** @hidden */
  7029. _update(world: DeepImmutable<Matrix>): void;
  7030. /**
  7031. * Tests if the bounding box is intersecting the frustum planes
  7032. * @param frustumPlanes defines the frustum planes to test
  7033. * @returns true if there is an intersection
  7034. */
  7035. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7036. /**
  7037. * Tests if the bounding box is entirely inside the frustum planes
  7038. * @param frustumPlanes defines the frustum planes to test
  7039. * @returns true if there is an inclusion
  7040. */
  7041. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7042. /**
  7043. * Tests if a point is inside the bounding box
  7044. * @param point defines the point to test
  7045. * @returns true if the point is inside the bounding box
  7046. */
  7047. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7048. /**
  7049. * Tests if the bounding box intersects with a bounding sphere
  7050. * @param sphere defines the sphere to test
  7051. * @returns true if there is an intersection
  7052. */
  7053. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7054. /**
  7055. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7056. * @param min defines the min vector to use
  7057. * @param max defines the max vector to use
  7058. * @returns true if there is an intersection
  7059. */
  7060. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7061. /**
  7062. * Tests if two bounding boxes are intersections
  7063. * @param box0 defines the first box to test
  7064. * @param box1 defines the second box to test
  7065. * @returns true if there is an intersection
  7066. */
  7067. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7068. /**
  7069. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7070. * @param minPoint defines the minimum vector of the bounding box
  7071. * @param maxPoint defines the maximum vector of the bounding box
  7072. * @param sphereCenter defines the sphere center
  7073. * @param sphereRadius defines the sphere radius
  7074. * @returns true if there is an intersection
  7075. */
  7076. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7077. /**
  7078. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7079. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7080. * @param frustumPlanes defines the frustum planes to test
  7081. * @return true if there is an inclusion
  7082. */
  7083. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7084. /**
  7085. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7086. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7087. * @param frustumPlanes defines the frustum planes to test
  7088. * @return true if there is an intersection
  7089. */
  7090. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7091. }
  7092. }
  7093. declare module "babylonjs/Collisions/collider" {
  7094. import { Nullable, IndicesArray } from "babylonjs/types";
  7095. import { Vector3, Plane } from "babylonjs/Maths/math";
  7096. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7097. /** @hidden */
  7098. export class Collider {
  7099. /** Define if a collision was found */
  7100. collisionFound: boolean;
  7101. /**
  7102. * Define last intersection point in local space
  7103. */
  7104. intersectionPoint: Vector3;
  7105. /**
  7106. * Define last collided mesh
  7107. */
  7108. collidedMesh: Nullable<AbstractMesh>;
  7109. private _collisionPoint;
  7110. private _planeIntersectionPoint;
  7111. private _tempVector;
  7112. private _tempVector2;
  7113. private _tempVector3;
  7114. private _tempVector4;
  7115. private _edge;
  7116. private _baseToVertex;
  7117. private _destinationPoint;
  7118. private _slidePlaneNormal;
  7119. private _displacementVector;
  7120. /** @hidden */
  7121. _radius: Vector3;
  7122. /** @hidden */
  7123. _retry: number;
  7124. private _velocity;
  7125. private _basePoint;
  7126. private _epsilon;
  7127. /** @hidden */
  7128. _velocityWorldLength: number;
  7129. /** @hidden */
  7130. _basePointWorld: Vector3;
  7131. private _velocityWorld;
  7132. private _normalizedVelocity;
  7133. /** @hidden */
  7134. _initialVelocity: Vector3;
  7135. /** @hidden */
  7136. _initialPosition: Vector3;
  7137. private _nearestDistance;
  7138. private _collisionMask;
  7139. collisionMask: number;
  7140. /**
  7141. * Gets the plane normal used to compute the sliding response (in local space)
  7142. */
  7143. readonly slidePlaneNormal: Vector3;
  7144. /** @hidden */
  7145. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7146. /** @hidden */
  7147. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7148. /** @hidden */
  7149. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7150. /** @hidden */
  7151. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7152. /** @hidden */
  7153. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7154. /** @hidden */
  7155. _getResponse(pos: Vector3, vel: Vector3): void;
  7156. }
  7157. }
  7158. declare module "babylonjs/Culling/boundingInfo" {
  7159. import { DeepImmutable } from "babylonjs/types";
  7160. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7161. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7162. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7163. import { Collider } from "babylonjs/Collisions/collider";
  7164. /**
  7165. * Interface for cullable objects
  7166. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7167. */
  7168. export interface ICullable {
  7169. /**
  7170. * Checks if the object or part of the object is in the frustum
  7171. * @param frustumPlanes Camera near/planes
  7172. * @returns true if the object is in frustum otherwise false
  7173. */
  7174. isInFrustum(frustumPlanes: Plane[]): boolean;
  7175. /**
  7176. * Checks if a cullable object (mesh...) is in the camera frustum
  7177. * Unlike isInFrustum this cheks the full bounding box
  7178. * @param frustumPlanes Camera near/planes
  7179. * @returns true if the object is in frustum otherwise false
  7180. */
  7181. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7182. }
  7183. /**
  7184. * Info for a bounding data of a mesh
  7185. */
  7186. export class BoundingInfo implements ICullable {
  7187. /**
  7188. * Bounding box for the mesh
  7189. */
  7190. readonly boundingBox: BoundingBox;
  7191. /**
  7192. * Bounding sphere for the mesh
  7193. */
  7194. readonly boundingSphere: BoundingSphere;
  7195. private _isLocked;
  7196. private static readonly TmpVector3;
  7197. /**
  7198. * Constructs bounding info
  7199. * @param minimum min vector of the bounding box/sphere
  7200. * @param maximum max vector of the bounding box/sphere
  7201. * @param worldMatrix defines the new world matrix
  7202. */
  7203. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7204. /**
  7205. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7206. * @param min defines the new minimum vector (in local space)
  7207. * @param max defines the new maximum vector (in local space)
  7208. * @param worldMatrix defines the new world matrix
  7209. */
  7210. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7211. /**
  7212. * min vector of the bounding box/sphere
  7213. */
  7214. readonly minimum: Vector3;
  7215. /**
  7216. * max vector of the bounding box/sphere
  7217. */
  7218. readonly maximum: Vector3;
  7219. /**
  7220. * If the info is locked and won't be updated to avoid perf overhead
  7221. */
  7222. isLocked: boolean;
  7223. /**
  7224. * Updates the bounding sphere and box
  7225. * @param world world matrix to be used to update
  7226. */
  7227. update(world: DeepImmutable<Matrix>): void;
  7228. /**
  7229. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7230. * @param center New center of the bounding info
  7231. * @param extend New extend of the bounding info
  7232. * @returns the current bounding info
  7233. */
  7234. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7235. /**
  7236. * Scale the current bounding info by applying a scale factor
  7237. * @param factor defines the scale factor to apply
  7238. * @returns the current bounding info
  7239. */
  7240. scale(factor: number): BoundingInfo;
  7241. /**
  7242. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7243. * @param frustumPlanes defines the frustum to test
  7244. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7245. * @returns true if the bounding info is in the frustum planes
  7246. */
  7247. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7248. /**
  7249. * Gets the world distance between the min and max points of the bounding box
  7250. */
  7251. readonly diagonalLength: number;
  7252. /**
  7253. * Checks if a cullable object (mesh...) is in the camera frustum
  7254. * Unlike isInFrustum this cheks the full bounding box
  7255. * @param frustumPlanes Camera near/planes
  7256. * @returns true if the object is in frustum otherwise false
  7257. */
  7258. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7259. /** @hidden */
  7260. _checkCollision(collider: Collider): boolean;
  7261. /**
  7262. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7263. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7264. * @param point the point to check intersection with
  7265. * @returns if the point intersects
  7266. */
  7267. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7268. /**
  7269. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7270. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7271. * @param boundingInfo the bounding info to check intersection with
  7272. * @param precise if the intersection should be done using OBB
  7273. * @returns if the bounding info intersects
  7274. */
  7275. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7276. }
  7277. }
  7278. declare module "babylonjs/Misc/smartArray" {
  7279. /**
  7280. * Defines an array and its length.
  7281. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7282. */
  7283. export interface ISmartArrayLike<T> {
  7284. /**
  7285. * The data of the array.
  7286. */
  7287. data: Array<T>;
  7288. /**
  7289. * The active length of the array.
  7290. */
  7291. length: number;
  7292. }
  7293. /**
  7294. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7295. */
  7296. export class SmartArray<T> implements ISmartArrayLike<T> {
  7297. /**
  7298. * The full set of data from the array.
  7299. */
  7300. data: Array<T>;
  7301. /**
  7302. * The active length of the array.
  7303. */
  7304. length: number;
  7305. protected _id: number;
  7306. /**
  7307. * Instantiates a Smart Array.
  7308. * @param capacity defines the default capacity of the array.
  7309. */
  7310. constructor(capacity: number);
  7311. /**
  7312. * Pushes a value at the end of the active data.
  7313. * @param value defines the object to push in the array.
  7314. */
  7315. push(value: T): void;
  7316. /**
  7317. * Iterates over the active data and apply the lambda to them.
  7318. * @param func defines the action to apply on each value.
  7319. */
  7320. forEach(func: (content: T) => void): void;
  7321. /**
  7322. * Sorts the full sets of data.
  7323. * @param compareFn defines the comparison function to apply.
  7324. */
  7325. sort(compareFn: (a: T, b: T) => number): void;
  7326. /**
  7327. * Resets the active data to an empty array.
  7328. */
  7329. reset(): void;
  7330. /**
  7331. * Releases all the data from the array as well as the array.
  7332. */
  7333. dispose(): void;
  7334. /**
  7335. * Concats the active data with a given array.
  7336. * @param array defines the data to concatenate with.
  7337. */
  7338. concat(array: any): void;
  7339. /**
  7340. * Returns the position of a value in the active data.
  7341. * @param value defines the value to find the index for
  7342. * @returns the index if found in the active data otherwise -1
  7343. */
  7344. indexOf(value: T): number;
  7345. /**
  7346. * Returns whether an element is part of the active data.
  7347. * @param value defines the value to look for
  7348. * @returns true if found in the active data otherwise false
  7349. */
  7350. contains(value: T): boolean;
  7351. private static _GlobalId;
  7352. }
  7353. /**
  7354. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7355. * The data in this array can only be present once
  7356. */
  7357. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7358. private _duplicateId;
  7359. /**
  7360. * Pushes a value at the end of the active data.
  7361. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7362. * @param value defines the object to push in the array.
  7363. */
  7364. push(value: T): void;
  7365. /**
  7366. * Pushes a value at the end of the active data.
  7367. * If the data is already present, it won t be added again
  7368. * @param value defines the object to push in the array.
  7369. * @returns true if added false if it was already present
  7370. */
  7371. pushNoDuplicate(value: T): boolean;
  7372. /**
  7373. * Resets the active data to an empty array.
  7374. */
  7375. reset(): void;
  7376. /**
  7377. * Concats the active data with a given array.
  7378. * This ensures no dupplicate will be present in the result.
  7379. * @param array defines the data to concatenate with.
  7380. */
  7381. concatWithNoDuplicate(array: any): void;
  7382. }
  7383. }
  7384. declare module "babylonjs/Materials/multiMaterial" {
  7385. import { Nullable } from "babylonjs/types";
  7386. import { Scene } from "babylonjs/scene";
  7387. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7388. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  7389. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7390. import { Material } from "babylonjs/Materials/material";
  7391. /**
  7392. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7393. * separate meshes. This can be use to improve performances.
  7394. * @see http://doc.babylonjs.com/how_to/multi_materials
  7395. */
  7396. export class MultiMaterial extends Material {
  7397. private _subMaterials;
  7398. /**
  7399. * Gets or Sets the list of Materials used within the multi material.
  7400. * They need to be ordered according to the submeshes order in the associated mesh
  7401. */
  7402. subMaterials: Nullable<Material>[];
  7403. /**
  7404. * Function used to align with Node.getChildren()
  7405. * @returns the list of Materials used within the multi material
  7406. */
  7407. getChildren(): Nullable<Material>[];
  7408. /**
  7409. * Instantiates a new Multi Material
  7410. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7411. * separate meshes. This can be use to improve performances.
  7412. * @see http://doc.babylonjs.com/how_to/multi_materials
  7413. * @param name Define the name in the scene
  7414. * @param scene Define the scene the material belongs to
  7415. */
  7416. constructor(name: string, scene: Scene);
  7417. private _hookArray;
  7418. /**
  7419. * Get one of the submaterial by its index in the submaterials array
  7420. * @param index The index to look the sub material at
  7421. * @returns The Material if the index has been defined
  7422. */
  7423. getSubMaterial(index: number): Nullable<Material>;
  7424. /**
  7425. * Get the list of active textures for the whole sub materials list.
  7426. * @returns All the textures that will be used during the rendering
  7427. */
  7428. getActiveTextures(): BaseTexture[];
  7429. /**
  7430. * Gets the current class name of the material e.g. "MultiMaterial"
  7431. * Mainly use in serialization.
  7432. * @returns the class name
  7433. */
  7434. getClassName(): string;
  7435. /**
  7436. * Checks if the material is ready to render the requested sub mesh
  7437. * @param mesh Define the mesh the submesh belongs to
  7438. * @param subMesh Define the sub mesh to look readyness for
  7439. * @param useInstances Define whether or not the material is used with instances
  7440. * @returns true if ready, otherwise false
  7441. */
  7442. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7443. /**
  7444. * Clones the current material and its related sub materials
  7445. * @param name Define the name of the newly cloned material
  7446. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7447. * @returns the cloned material
  7448. */
  7449. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7450. /**
  7451. * Serializes the materials into a JSON representation.
  7452. * @returns the JSON representation
  7453. */
  7454. serialize(): any;
  7455. /**
  7456. * Dispose the material and release its associated resources
  7457. * @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)
  7458. * @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)
  7459. * @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)
  7460. */
  7461. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7462. /**
  7463. * Creates a MultiMaterial from parsed MultiMaterial data.
  7464. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7465. * @param scene defines the hosting scene
  7466. * @returns a new MultiMaterial
  7467. */
  7468. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7469. }
  7470. }
  7471. declare module "babylonjs/Loading/sceneLoaderFlags" {
  7472. /**
  7473. * Class used to represent data loading progression
  7474. */
  7475. export class SceneLoaderFlags {
  7476. private static _ForceFullSceneLoadingForIncremental;
  7477. private static _ShowLoadingScreen;
  7478. private static _CleanBoneMatrixWeights;
  7479. private static _loggingLevel;
  7480. /**
  7481. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7482. */
  7483. static ForceFullSceneLoadingForIncremental: boolean;
  7484. /**
  7485. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7486. */
  7487. static ShowLoadingScreen: boolean;
  7488. /**
  7489. * Defines the current logging level (while loading the scene)
  7490. * @ignorenaming
  7491. */
  7492. static loggingLevel: number;
  7493. /**
  7494. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7495. */
  7496. static CleanBoneMatrixWeights: boolean;
  7497. }
  7498. }
  7499. declare module "babylonjs/Meshes/transformNode" {
  7500. import { DeepImmutable } from "babylonjs/types";
  7501. import { Observable } from "babylonjs/Misc/observable";
  7502. import { Nullable } from "babylonjs/types";
  7503. import { Camera } from "babylonjs/Cameras/camera";
  7504. import { Scene } from "babylonjs/scene";
  7505. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  7506. import { Node } from "babylonjs/node";
  7507. import { Bone } from "babylonjs/Bones/bone";
  7508. /**
  7509. * 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.
  7510. * @see https://doc.babylonjs.com/how_to/transformnode
  7511. */
  7512. export class TransformNode extends Node {
  7513. /**
  7514. * Object will not rotate to face the camera
  7515. */
  7516. static BILLBOARDMODE_NONE: number;
  7517. /**
  7518. * Object will rotate to face the camera but only on the x axis
  7519. */
  7520. static BILLBOARDMODE_X: number;
  7521. /**
  7522. * Object will rotate to face the camera but only on the y axis
  7523. */
  7524. static BILLBOARDMODE_Y: number;
  7525. /**
  7526. * Object will rotate to face the camera but only on the z axis
  7527. */
  7528. static BILLBOARDMODE_Z: number;
  7529. /**
  7530. * Object will rotate to face the camera
  7531. */
  7532. static BILLBOARDMODE_ALL: number;
  7533. private _forward;
  7534. private _forwardInverted;
  7535. private _up;
  7536. private _right;
  7537. private _rightInverted;
  7538. private _position;
  7539. private _rotation;
  7540. private _rotationQuaternion;
  7541. protected _scaling: Vector3;
  7542. protected _isDirty: boolean;
  7543. private _transformToBoneReferal;
  7544. private _billboardMode;
  7545. /**
  7546. * Gets or sets the billboard mode. Default is 0.
  7547. *
  7548. * | Value | Type | Description |
  7549. * | --- | --- | --- |
  7550. * | 0 | BILLBOARDMODE_NONE | |
  7551. * | 1 | BILLBOARDMODE_X | |
  7552. * | 2 | BILLBOARDMODE_Y | |
  7553. * | 4 | BILLBOARDMODE_Z | |
  7554. * | 7 | BILLBOARDMODE_ALL | |
  7555. *
  7556. */
  7557. billboardMode: number;
  7558. private _preserveParentRotationForBillboard;
  7559. /**
  7560. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  7561. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  7562. */
  7563. preserveParentRotationForBillboard: boolean;
  7564. /**
  7565. * 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
  7566. */
  7567. scalingDeterminant: number;
  7568. private _infiniteDistance;
  7569. /**
  7570. * Gets or sets the distance of the object to max, often used by skybox
  7571. */
  7572. infiniteDistance: boolean;
  7573. /**
  7574. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7575. * By default the system will update normals to compensate
  7576. */
  7577. ignoreNonUniformScaling: boolean;
  7578. /**
  7579. * 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
  7580. */
  7581. reIntegrateRotationIntoRotationQuaternion: boolean;
  7582. /** @hidden */
  7583. _poseMatrix: Matrix;
  7584. /** @hidden */
  7585. _localMatrix: Matrix;
  7586. private _absolutePosition;
  7587. private _pivotMatrix;
  7588. private _pivotMatrixInverse;
  7589. protected _postMultiplyPivotMatrix: boolean;
  7590. protected _isWorldMatrixFrozen: boolean;
  7591. /** @hidden */
  7592. _indexInSceneTransformNodesArray: number;
  7593. private _connectBillboardProcessors;
  7594. /**
  7595. * An event triggered after the world matrix is updated
  7596. */
  7597. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7598. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7599. /**
  7600. * Gets a string identifying the name of the class
  7601. * @returns "TransformNode" string
  7602. */
  7603. getClassName(): string;
  7604. /**
  7605. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7606. */
  7607. position: Vector3;
  7608. /**
  7609. * 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)).
  7610. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7611. */
  7612. rotation: Vector3;
  7613. /**
  7614. * 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)).
  7615. */
  7616. scaling: Vector3;
  7617. /**
  7618. * 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).
  7619. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7620. */
  7621. rotationQuaternion: Nullable<Quaternion>;
  7622. /**
  7623. * The forward direction of that transform in world space.
  7624. */
  7625. readonly forward: Vector3;
  7626. /**
  7627. * The up direction of that transform in world space.
  7628. */
  7629. readonly up: Vector3;
  7630. /**
  7631. * The right direction of that transform in world space.
  7632. */
  7633. readonly right: Vector3;
  7634. /**
  7635. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7636. * @param matrix the matrix to copy the pose from
  7637. * @returns this TransformNode.
  7638. */
  7639. updatePoseMatrix(matrix: Matrix): TransformNode;
  7640. /**
  7641. * Returns the mesh Pose matrix.
  7642. * @returns the pose matrix
  7643. */
  7644. getPoseMatrix(): Matrix;
  7645. /** @hidden */
  7646. _isSynchronized(): boolean;
  7647. /** @hidden */
  7648. _initCache(): void;
  7649. /**
  7650. * Flag the transform node as dirty (Forcing it to update everything)
  7651. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7652. * @returns this transform node
  7653. */
  7654. markAsDirty(property: string): TransformNode;
  7655. /**
  7656. * Returns the current mesh absolute position.
  7657. * Returns a Vector3.
  7658. */
  7659. readonly absolutePosition: Vector3;
  7660. /**
  7661. * Sets a new matrix to apply before all other transformation
  7662. * @param matrix defines the transform matrix
  7663. * @returns the current TransformNode
  7664. */
  7665. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7666. /**
  7667. * Sets a new pivot matrix to the current node
  7668. * @param matrix defines the new pivot matrix to use
  7669. * @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
  7670. * @returns the current TransformNode
  7671. */
  7672. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7673. /**
  7674. * Returns the mesh pivot matrix.
  7675. * Default : Identity.
  7676. * @returns the matrix
  7677. */
  7678. getPivotMatrix(): Matrix;
  7679. /**
  7680. * Prevents the World matrix to be computed any longer.
  7681. * @returns the TransformNode.
  7682. */
  7683. freezeWorldMatrix(): TransformNode;
  7684. /**
  7685. * Allows back the World matrix computation.
  7686. * @returns the TransformNode.
  7687. */
  7688. unfreezeWorldMatrix(): this;
  7689. /**
  7690. * True if the World matrix has been frozen.
  7691. */
  7692. readonly isWorldMatrixFrozen: boolean;
  7693. /**
  7694. * Retuns the mesh absolute position in the World.
  7695. * @returns a Vector3.
  7696. */
  7697. getAbsolutePosition(): Vector3;
  7698. /**
  7699. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7700. * @param absolutePosition the absolute position to set
  7701. * @returns the TransformNode.
  7702. */
  7703. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7704. /**
  7705. * Sets the mesh position in its local space.
  7706. * @param vector3 the position to set in localspace
  7707. * @returns the TransformNode.
  7708. */
  7709. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7710. /**
  7711. * Returns the mesh position in the local space from the current World matrix values.
  7712. * @returns a new Vector3.
  7713. */
  7714. getPositionExpressedInLocalSpace(): Vector3;
  7715. /**
  7716. * Translates the mesh along the passed Vector3 in its local space.
  7717. * @param vector3 the distance to translate in localspace
  7718. * @returns the TransformNode.
  7719. */
  7720. locallyTranslate(vector3: Vector3): TransformNode;
  7721. private static _lookAtVectorCache;
  7722. /**
  7723. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7724. * @param targetPoint the position (must be in same space as current mesh) to look at
  7725. * @param yawCor optional yaw (y-axis) correction in radians
  7726. * @param pitchCor optional pitch (x-axis) correction in radians
  7727. * @param rollCor optional roll (z-axis) correction in radians
  7728. * @param space the choosen space of the target
  7729. * @returns the TransformNode.
  7730. */
  7731. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7732. /**
  7733. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7734. * This Vector3 is expressed in the World space.
  7735. * @param localAxis axis to rotate
  7736. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7737. */
  7738. getDirection(localAxis: Vector3): Vector3;
  7739. /**
  7740. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7741. * localAxis is expressed in the mesh local space.
  7742. * result is computed in the Wordl space from the mesh World matrix.
  7743. * @param localAxis axis to rotate
  7744. * @param result the resulting transformnode
  7745. * @returns this TransformNode.
  7746. */
  7747. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7748. /**
  7749. * Sets this transform node rotation to the given local axis.
  7750. * @param localAxis the axis in local space
  7751. * @param yawCor optional yaw (y-axis) correction in radians
  7752. * @param pitchCor optional pitch (x-axis) correction in radians
  7753. * @param rollCor optional roll (z-axis) correction in radians
  7754. * @returns this TransformNode
  7755. */
  7756. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7757. /**
  7758. * Sets a new pivot point to the current node
  7759. * @param point defines the new pivot point to use
  7760. * @param space defines if the point is in world or local space (local by default)
  7761. * @returns the current TransformNode
  7762. */
  7763. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7764. /**
  7765. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7766. * @returns the pivot point
  7767. */
  7768. getPivotPoint(): Vector3;
  7769. /**
  7770. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7771. * @param result the vector3 to store the result
  7772. * @returns this TransformNode.
  7773. */
  7774. getPivotPointToRef(result: Vector3): TransformNode;
  7775. /**
  7776. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7777. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7778. */
  7779. getAbsolutePivotPoint(): Vector3;
  7780. /**
  7781. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7782. * @param result vector3 to store the result
  7783. * @returns this TransformNode.
  7784. */
  7785. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7786. /**
  7787. * Defines the passed node as the parent of the current node.
  7788. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7789. * @see https://doc.babylonjs.com/how_to/parenting
  7790. * @param node the node ot set as the parent
  7791. * @returns this TransformNode.
  7792. */
  7793. setParent(node: Nullable<Node>): TransformNode;
  7794. private _nonUniformScaling;
  7795. /**
  7796. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7797. */
  7798. readonly nonUniformScaling: boolean;
  7799. /** @hidden */
  7800. _updateNonUniformScalingState(value: boolean): boolean;
  7801. /**
  7802. * Attach the current TransformNode to another TransformNode associated with a bone
  7803. * @param bone Bone affecting the TransformNode
  7804. * @param affectedTransformNode TransformNode associated with the bone
  7805. * @returns this object
  7806. */
  7807. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7808. /**
  7809. * Detach the transform node if its associated with a bone
  7810. * @returns this object
  7811. */
  7812. detachFromBone(): TransformNode;
  7813. private static _rotationAxisCache;
  7814. /**
  7815. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7816. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7817. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7818. * The passed axis is also normalized.
  7819. * @param axis the axis to rotate around
  7820. * @param amount the amount to rotate in radians
  7821. * @param space Space to rotate in (Default: local)
  7822. * @returns the TransformNode.
  7823. */
  7824. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7825. /**
  7826. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7827. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7828. * The passed axis is also normalized. .
  7829. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7830. * @param point the point to rotate around
  7831. * @param axis the axis to rotate around
  7832. * @param amount the amount to rotate in radians
  7833. * @returns the TransformNode
  7834. */
  7835. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7836. /**
  7837. * Translates the mesh along the axis vector for the passed distance in the given space.
  7838. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7839. * @param axis the axis to translate in
  7840. * @param distance the distance to translate
  7841. * @param space Space to rotate in (Default: local)
  7842. * @returns the TransformNode.
  7843. */
  7844. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7845. /**
  7846. * Adds a rotation step to the mesh current rotation.
  7847. * x, y, z are Euler angles expressed in radians.
  7848. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7849. * This means this rotation is made in the mesh local space only.
  7850. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7851. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7852. * ```javascript
  7853. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7854. * ```
  7855. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7856. * 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.
  7857. * @param x Rotation to add
  7858. * @param y Rotation to add
  7859. * @param z Rotation to add
  7860. * @returns the TransformNode.
  7861. */
  7862. addRotation(x: number, y: number, z: number): TransformNode;
  7863. /**
  7864. * @hidden
  7865. */
  7866. protected _getEffectiveParent(): Nullable<Node>;
  7867. private _activeCompositionProcessor;
  7868. private _defaultCompositionProcessor;
  7869. private _pivotCompositionProcessor;
  7870. private _translationProcessor;
  7871. private _defaultTranslationProcessor;
  7872. private _infiniteDistanceTranslationProcessor;
  7873. private _activeParentProcessor;
  7874. private _activeBillboardPostProcessor;
  7875. private _defaultParentProcessor;
  7876. private _billboardParentProcessor;
  7877. private _billboardPostProcessor;
  7878. /**
  7879. * Computes the world matrix of the node
  7880. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7881. * @returns the world matrix
  7882. */
  7883. computeWorldMatrix(force?: boolean): Matrix;
  7884. protected _afterComputeWorldMatrix(): void;
  7885. /**
  7886. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7887. * @param func callback function to add
  7888. *
  7889. * @returns the TransformNode.
  7890. */
  7891. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7892. /**
  7893. * Removes a registered callback function.
  7894. * @param func callback function to remove
  7895. * @returns the TransformNode.
  7896. */
  7897. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7898. /**
  7899. * Gets the position of the current mesh in camera space
  7900. * @param camera defines the camera to use
  7901. * @returns a position
  7902. */
  7903. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7904. /**
  7905. * Returns the distance from the mesh to the active camera
  7906. * @param camera defines the camera to use
  7907. * @returns the distance
  7908. */
  7909. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7910. /**
  7911. * Clone the current transform node
  7912. * @param name Name of the new clone
  7913. * @param newParent New parent for the clone
  7914. * @param doNotCloneChildren Do not clone children hierarchy
  7915. * @returns the new transform node
  7916. */
  7917. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7918. /**
  7919. * Serializes the objects information.
  7920. * @param currentSerializationObject defines the object to serialize in
  7921. * @returns the serialized object
  7922. */
  7923. serialize(currentSerializationObject?: any): any;
  7924. /**
  7925. * Returns a new TransformNode object parsed from the source provided.
  7926. * @param parsedTransformNode is the source.
  7927. * @param scene the scne the object belongs to
  7928. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7929. * @returns a new TransformNode object parsed from the source provided.
  7930. */
  7931. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7932. /**
  7933. * Get all child-transformNodes of this node
  7934. * @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
  7935. * @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
  7936. * @returns an array of TransformNode
  7937. */
  7938. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7939. /**
  7940. * Releases resources associated with this transform node.
  7941. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7942. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7943. */
  7944. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7945. }
  7946. }
  7947. declare module "babylonjs/Animations/animationPropertiesOverride" {
  7948. /**
  7949. * Class used to override all child animations of a given target
  7950. */
  7951. export class AnimationPropertiesOverride {
  7952. /**
  7953. * Gets or sets a value indicating if animation blending must be used
  7954. */
  7955. enableBlending: boolean;
  7956. /**
  7957. * Gets or sets the blending speed to use when enableBlending is true
  7958. */
  7959. blendingSpeed: number;
  7960. /**
  7961. * Gets or sets the default loop mode to use
  7962. */
  7963. loopMode: number;
  7964. }
  7965. }
  7966. declare module "babylonjs/Bones/bone" {
  7967. import { Skeleton } from "babylonjs/Bones/skeleton";
  7968. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  7969. import { Nullable } from "babylonjs/types";
  7970. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7971. import { TransformNode } from "babylonjs/Meshes/transformNode";
  7972. import { Node } from "babylonjs/node";
  7973. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  7974. /**
  7975. * Class used to store bone information
  7976. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7977. */
  7978. export class Bone extends Node {
  7979. /**
  7980. * defines the bone name
  7981. */
  7982. name: string;
  7983. private static _tmpVecs;
  7984. private static _tmpQuat;
  7985. private static _tmpMats;
  7986. /**
  7987. * Gets the list of child bones
  7988. */
  7989. children: Bone[];
  7990. /** Gets the animations associated with this bone */
  7991. animations: import("babylonjs/Animations/animation").Animation[];
  7992. /**
  7993. * Gets or sets bone length
  7994. */
  7995. length: number;
  7996. /**
  7997. * @hidden Internal only
  7998. * Set this value to map this bone to a different index in the transform matrices
  7999. * Set this value to -1 to exclude the bone from the transform matrices
  8000. */
  8001. _index: Nullable<number>;
  8002. private _skeleton;
  8003. private _localMatrix;
  8004. private _restPose;
  8005. private _baseMatrix;
  8006. private _absoluteTransform;
  8007. private _invertedAbsoluteTransform;
  8008. private _parent;
  8009. private _scalingDeterminant;
  8010. private _worldTransform;
  8011. private _localScaling;
  8012. private _localRotation;
  8013. private _localPosition;
  8014. private _needToDecompose;
  8015. private _needToCompose;
  8016. /** @hidden */
  8017. _linkedTransformNode: Nullable<TransformNode>;
  8018. /** @hidden */
  8019. /** @hidden */
  8020. _matrix: Matrix;
  8021. /**
  8022. * Create a new bone
  8023. * @param name defines the bone name
  8024. * @param skeleton defines the parent skeleton
  8025. * @param parentBone defines the parent (can be null if the bone is the root)
  8026. * @param localMatrix defines the local matrix
  8027. * @param restPose defines the rest pose matrix
  8028. * @param baseMatrix defines the base matrix
  8029. * @param index defines index of the bone in the hiearchy
  8030. */
  8031. constructor(
  8032. /**
  8033. * defines the bone name
  8034. */
  8035. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8036. /**
  8037. * Gets the current object class name.
  8038. * @return the class name
  8039. */
  8040. getClassName(): string;
  8041. /**
  8042. * Gets the parent skeleton
  8043. * @returns a skeleton
  8044. */
  8045. getSkeleton(): Skeleton;
  8046. /**
  8047. * Gets parent bone
  8048. * @returns a bone or null if the bone is the root of the bone hierarchy
  8049. */
  8050. getParent(): Nullable<Bone>;
  8051. /**
  8052. * Returns an array containing the root bones
  8053. * @returns an array containing the root bones
  8054. */
  8055. getChildren(): Array<Bone>;
  8056. /**
  8057. * Sets the parent bone
  8058. * @param parent defines the parent (can be null if the bone is the root)
  8059. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8060. */
  8061. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8062. /**
  8063. * Gets the local matrix
  8064. * @returns a matrix
  8065. */
  8066. getLocalMatrix(): Matrix;
  8067. /**
  8068. * Gets the base matrix (initial matrix which remains unchanged)
  8069. * @returns a matrix
  8070. */
  8071. getBaseMatrix(): Matrix;
  8072. /**
  8073. * Gets the rest pose matrix
  8074. * @returns a matrix
  8075. */
  8076. getRestPose(): Matrix;
  8077. /**
  8078. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8079. */
  8080. getWorldMatrix(): Matrix;
  8081. /**
  8082. * Sets the local matrix to rest pose matrix
  8083. */
  8084. returnToRest(): void;
  8085. /**
  8086. * Gets the inverse of the absolute transform matrix.
  8087. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8088. * @returns a matrix
  8089. */
  8090. getInvertedAbsoluteTransform(): Matrix;
  8091. /**
  8092. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8093. * @returns a matrix
  8094. */
  8095. getAbsoluteTransform(): Matrix;
  8096. /**
  8097. * Links with the given transform node.
  8098. * The local matrix of this bone is copied from the transform node every frame.
  8099. * @param transformNode defines the transform node to link to
  8100. */
  8101. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8102. /** Gets or sets current position (in local space) */
  8103. position: Vector3;
  8104. /** Gets or sets current rotation (in local space) */
  8105. rotation: Vector3;
  8106. /** Gets or sets current rotation quaternion (in local space) */
  8107. rotationQuaternion: Quaternion;
  8108. /** Gets or sets current scaling (in local space) */
  8109. scaling: Vector3;
  8110. /**
  8111. * Gets the animation properties override
  8112. */
  8113. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8114. private _decompose;
  8115. private _compose;
  8116. /**
  8117. * Update the base and local matrices
  8118. * @param matrix defines the new base or local matrix
  8119. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8120. * @param updateLocalMatrix defines if the local matrix should be updated
  8121. */
  8122. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8123. /** @hidden */
  8124. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8125. /**
  8126. * Flag the bone as dirty (Forcing it to update everything)
  8127. */
  8128. markAsDirty(): void;
  8129. private _markAsDirtyAndCompose;
  8130. private _markAsDirtyAndDecompose;
  8131. /**
  8132. * Translate the bone in local or world space
  8133. * @param vec The amount to translate the bone
  8134. * @param space The space that the translation is in
  8135. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8136. */
  8137. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8138. /**
  8139. * Set the postion of the bone in local or world space
  8140. * @param position The position to set the bone
  8141. * @param space The space that the position is in
  8142. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8143. */
  8144. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8145. /**
  8146. * Set the absolute position of the bone (world space)
  8147. * @param position The position to set the bone
  8148. * @param mesh The mesh that this bone is attached to
  8149. */
  8150. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8151. /**
  8152. * Scale the bone on the x, y and z axes (in local space)
  8153. * @param x The amount to scale the bone on the x axis
  8154. * @param y The amount to scale the bone on the y axis
  8155. * @param z The amount to scale the bone on the z axis
  8156. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8157. */
  8158. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8159. /**
  8160. * Set the bone scaling in local space
  8161. * @param scale defines the scaling vector
  8162. */
  8163. setScale(scale: Vector3): void;
  8164. /**
  8165. * Gets the current scaling in local space
  8166. * @returns the current scaling vector
  8167. */
  8168. getScale(): Vector3;
  8169. /**
  8170. * Gets the current scaling in local space and stores it in a target vector
  8171. * @param result defines the target vector
  8172. */
  8173. getScaleToRef(result: Vector3): void;
  8174. /**
  8175. * Set the yaw, pitch, and roll of the bone in local or world space
  8176. * @param yaw The rotation of the bone on the y axis
  8177. * @param pitch The rotation of the bone on the x axis
  8178. * @param roll The rotation of the bone on the z axis
  8179. * @param space The space that the axes of rotation are in
  8180. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8181. */
  8182. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8183. /**
  8184. * Add a rotation to the bone on an axis in local or world space
  8185. * @param axis The axis to rotate the bone on
  8186. * @param amount The amount to rotate the bone
  8187. * @param space The space that the axis is in
  8188. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8189. */
  8190. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8191. /**
  8192. * Set the rotation of the bone to a particular axis angle in local or world space
  8193. * @param axis The axis to rotate the bone on
  8194. * @param angle The angle that the bone should be rotated to
  8195. * @param space The space that the axis is in
  8196. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8197. */
  8198. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8199. /**
  8200. * Set the euler rotation of the bone in local of world space
  8201. * @param rotation The euler rotation that the bone should be set to
  8202. * @param space The space that the rotation is in
  8203. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8204. */
  8205. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8206. /**
  8207. * Set the quaternion rotation of the bone in local of world space
  8208. * @param quat The quaternion rotation that the bone should be set to
  8209. * @param space The space that the rotation is in
  8210. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8211. */
  8212. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8213. /**
  8214. * Set the rotation matrix of the bone in local of world space
  8215. * @param rotMat The rotation matrix that the bone should be set to
  8216. * @param space The space that the rotation is in
  8217. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8218. */
  8219. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8220. private _rotateWithMatrix;
  8221. private _getNegativeRotationToRef;
  8222. /**
  8223. * Get the position of the bone in local or world space
  8224. * @param space The space that the returned position is in
  8225. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8226. * @returns The position of the bone
  8227. */
  8228. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8229. /**
  8230. * Copy the position of the bone to a vector3 in local or world space
  8231. * @param space The space that the returned position is in
  8232. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8233. * @param result The vector3 to copy the position to
  8234. */
  8235. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8236. /**
  8237. * Get the absolute position of the bone (world space)
  8238. * @param mesh The mesh that this bone is attached to
  8239. * @returns The absolute position of the bone
  8240. */
  8241. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8242. /**
  8243. * Copy the absolute position of the bone (world space) to the result param
  8244. * @param mesh The mesh that this bone is attached to
  8245. * @param result The vector3 to copy the absolute position to
  8246. */
  8247. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8248. /**
  8249. * Compute the absolute transforms of this bone and its children
  8250. */
  8251. computeAbsoluteTransforms(): void;
  8252. /**
  8253. * Get the world direction from an axis that is in the local space of the bone
  8254. * @param localAxis The local direction that is used to compute the world direction
  8255. * @param mesh The mesh that this bone is attached to
  8256. * @returns The world direction
  8257. */
  8258. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8259. /**
  8260. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8261. * @param localAxis The local direction that is used to compute the world direction
  8262. * @param mesh The mesh that this bone is attached to
  8263. * @param result The vector3 that the world direction will be copied to
  8264. */
  8265. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8266. /**
  8267. * Get the euler rotation of the bone in local or world space
  8268. * @param space The space that the rotation should be in
  8269. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8270. * @returns The euler rotation
  8271. */
  8272. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8273. /**
  8274. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8275. * @param space The space that the rotation should be in
  8276. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8277. * @param result The vector3 that the rotation should be copied to
  8278. */
  8279. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8280. /**
  8281. * Get the quaternion rotation of the bone in either local or world space
  8282. * @param space The space that the rotation should be in
  8283. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8284. * @returns The quaternion rotation
  8285. */
  8286. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8287. /**
  8288. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8289. * @param space The space that the rotation should be in
  8290. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8291. * @param result The quaternion that the rotation should be copied to
  8292. */
  8293. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8294. /**
  8295. * Get the rotation matrix of the bone in local or world space
  8296. * @param space The space that the rotation should be in
  8297. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8298. * @returns The rotation matrix
  8299. */
  8300. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8301. /**
  8302. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8303. * @param space The space that the rotation should be in
  8304. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8305. * @param result The quaternion that the rotation should be copied to
  8306. */
  8307. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8308. /**
  8309. * Get the world position of a point that is in the local space of the bone
  8310. * @param position The local position
  8311. * @param mesh The mesh that this bone is attached to
  8312. * @returns The world position
  8313. */
  8314. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8315. /**
  8316. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8317. * @param position The local position
  8318. * @param mesh The mesh that this bone is attached to
  8319. * @param result The vector3 that the world position should be copied to
  8320. */
  8321. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8322. /**
  8323. * Get the local position of a point that is in world space
  8324. * @param position The world position
  8325. * @param mesh The mesh that this bone is attached to
  8326. * @returns The local position
  8327. */
  8328. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8329. /**
  8330. * Get the local position of a point that is in world space and copy it to the result param
  8331. * @param position The world position
  8332. * @param mesh The mesh that this bone is attached to
  8333. * @param result The vector3 that the local position should be copied to
  8334. */
  8335. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8336. }
  8337. }
  8338. declare module "babylonjs/Misc/iInspectable" {
  8339. /**
  8340. * Enum that determines the text-wrapping mode to use.
  8341. */
  8342. export enum InspectableType {
  8343. /**
  8344. * Checkbox for booleans
  8345. */
  8346. Checkbox = 0,
  8347. /**
  8348. * Sliders for numbers
  8349. */
  8350. Slider = 1,
  8351. /**
  8352. * Vector3
  8353. */
  8354. Vector3 = 2,
  8355. /**
  8356. * Quaternions
  8357. */
  8358. Quaternion = 3,
  8359. /**
  8360. * Color3
  8361. */
  8362. Color3 = 4
  8363. }
  8364. /**
  8365. * Interface used to define custom inspectable properties.
  8366. * This interface is used by the inspector to display custom property grids
  8367. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8368. */
  8369. export interface IInspectable {
  8370. /**
  8371. * Gets the label to display
  8372. */
  8373. label: string;
  8374. /**
  8375. * Gets the name of the property to edit
  8376. */
  8377. propertyName: string;
  8378. /**
  8379. * Gets the type of the editor to use
  8380. */
  8381. type: InspectableType;
  8382. /**
  8383. * Gets the minimum value of the property when using in "slider" mode
  8384. */
  8385. min?: number;
  8386. /**
  8387. * Gets the maximum value of the property when using in "slider" mode
  8388. */
  8389. max?: number;
  8390. /**
  8391. * Gets the setp to use when using in "slider" mode
  8392. */
  8393. step?: number;
  8394. }
  8395. }
  8396. declare module "babylonjs/Materials/Textures/cubeTexture" {
  8397. import { Nullable } from "babylonjs/types";
  8398. import { Scene } from "babylonjs/scene";
  8399. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8400. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8401. /**
  8402. * Class for creating a cube texture
  8403. */
  8404. export class CubeTexture extends BaseTexture {
  8405. private _delayedOnLoad;
  8406. /**
  8407. * The url of the texture
  8408. */
  8409. url: string;
  8410. /**
  8411. * Gets or sets the center of the bounding box associated with the cube texture.
  8412. * It must define where the camera used to render the texture was set
  8413. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8414. */
  8415. boundingBoxPosition: Vector3;
  8416. private _boundingBoxSize;
  8417. /**
  8418. * Gets or sets the size of the bounding box associated with the cube texture
  8419. * When defined, the cubemap will switch to local mode
  8420. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8421. * @example https://www.babylonjs-playground.com/#RNASML
  8422. */
  8423. /**
  8424. * Returns the bounding box size
  8425. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8426. */
  8427. boundingBoxSize: Vector3;
  8428. protected _rotationY: number;
  8429. /**
  8430. * Sets texture matrix rotation angle around Y axis in radians.
  8431. */
  8432. /**
  8433. * Gets texture matrix rotation angle around Y axis radians.
  8434. */
  8435. rotationY: number;
  8436. /**
  8437. * Are mip maps generated for this texture or not.
  8438. */
  8439. readonly noMipmap: boolean;
  8440. private _noMipmap;
  8441. private _files;
  8442. private _extensions;
  8443. private _textureMatrix;
  8444. private _format;
  8445. private _createPolynomials;
  8446. /** @hidden */
  8447. _prefiltered: boolean;
  8448. /**
  8449. * Creates a cube texture from an array of image urls
  8450. * @param files defines an array of image urls
  8451. * @param scene defines the hosting scene
  8452. * @param noMipmap specifies if mip maps are not used
  8453. * @returns a cube texture
  8454. */
  8455. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8456. /**
  8457. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8458. * @param url defines the url of the prefiltered texture
  8459. * @param scene defines the scene the texture is attached to
  8460. * @param forcedExtension defines the extension of the file if different from the url
  8461. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8462. * @return the prefiltered texture
  8463. */
  8464. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8465. /**
  8466. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8467. * as prefiltered data.
  8468. * @param rootUrl defines the url of the texture or the root name of the six images
  8469. * @param scene defines the scene the texture is attached to
  8470. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8471. * @param noMipmap defines if mipmaps should be created or not
  8472. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8473. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8474. * @param onError defines a callback triggered in case of error during load
  8475. * @param format defines the internal format to use for the texture once loaded
  8476. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8477. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8478. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8479. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8480. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8481. * @return the cube texture
  8482. */
  8483. 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);
  8484. /**
  8485. * Get the current class name of the texture useful for serialization or dynamic coding.
  8486. * @returns "CubeTexture"
  8487. */
  8488. getClassName(): string;
  8489. /**
  8490. * Update the url (and optional buffer) of this texture if url was null during construction.
  8491. * @param url the url of the texture
  8492. * @param forcedExtension defines the extension to use
  8493. * @param onLoad callback called when the texture is loaded (defaults to null)
  8494. */
  8495. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8496. /**
  8497. * Delays loading of the cube texture
  8498. * @param forcedExtension defines the extension to use
  8499. */
  8500. delayLoad(forcedExtension?: string): void;
  8501. /**
  8502. * Returns the reflection texture matrix
  8503. * @returns the reflection texture matrix
  8504. */
  8505. getReflectionTextureMatrix(): Matrix;
  8506. /**
  8507. * Sets the reflection texture matrix
  8508. * @param value Reflection texture matrix
  8509. */
  8510. setReflectionTextureMatrix(value: Matrix): void;
  8511. /**
  8512. * Parses text to create a cube texture
  8513. * @param parsedTexture define the serialized text to read from
  8514. * @param scene defines the hosting scene
  8515. * @param rootUrl defines the root url of the cube texture
  8516. * @returns a cube texture
  8517. */
  8518. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8519. /**
  8520. * Makes a clone, or deep copy, of the cube texture
  8521. * @returns a new cube texture
  8522. */
  8523. clone(): CubeTexture;
  8524. }
  8525. }
  8526. declare module "babylonjs/Shaders/postprocess.vertex" {
  8527. /** @hidden */
  8528. export var postprocessVertexShader: {
  8529. name: string;
  8530. shader: string;
  8531. };
  8532. }
  8533. declare module "babylonjs/Cameras/targetCamera" {
  8534. import { Nullable } from "babylonjs/types";
  8535. import { Camera } from "babylonjs/Cameras/camera";
  8536. import { Scene } from "babylonjs/scene";
  8537. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  8538. /**
  8539. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8540. * This is the base of the follow, arc rotate cameras and Free camera
  8541. * @see http://doc.babylonjs.com/features/cameras
  8542. */
  8543. export class TargetCamera extends Camera {
  8544. private static _RigCamTransformMatrix;
  8545. private static _TargetTransformMatrix;
  8546. private static _TargetFocalPoint;
  8547. /**
  8548. * Define the current direction the camera is moving to
  8549. */
  8550. cameraDirection: Vector3;
  8551. /**
  8552. * Define the current rotation the camera is rotating to
  8553. */
  8554. cameraRotation: Vector2;
  8555. /**
  8556. * When set, the up vector of the camera will be updated by the rotation of the camera
  8557. */
  8558. updateUpVectorFromRotation: boolean;
  8559. private _tmpQuaternion;
  8560. /**
  8561. * Define the current rotation of the camera
  8562. */
  8563. rotation: Vector3;
  8564. /**
  8565. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8566. */
  8567. rotationQuaternion: Quaternion;
  8568. /**
  8569. * Define the current speed of the camera
  8570. */
  8571. speed: number;
  8572. /**
  8573. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8574. * around all axis.
  8575. */
  8576. noRotationConstraint: boolean;
  8577. /**
  8578. * Define the current target of the camera as an object or a position.
  8579. */
  8580. lockedTarget: any;
  8581. /** @hidden */
  8582. _currentTarget: Vector3;
  8583. /** @hidden */
  8584. _initialFocalDistance: number;
  8585. /** @hidden */
  8586. _viewMatrix: Matrix;
  8587. /** @hidden */
  8588. _camMatrix: Matrix;
  8589. /** @hidden */
  8590. _cameraTransformMatrix: Matrix;
  8591. /** @hidden */
  8592. _cameraRotationMatrix: Matrix;
  8593. /** @hidden */
  8594. _referencePoint: Vector3;
  8595. /** @hidden */
  8596. _transformedReferencePoint: Vector3;
  8597. protected _globalCurrentTarget: Vector3;
  8598. protected _globalCurrentUpVector: Vector3;
  8599. /** @hidden */
  8600. _reset: () => void;
  8601. private _defaultUp;
  8602. /**
  8603. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8604. * This is the base of the follow, arc rotate cameras and Free camera
  8605. * @see http://doc.babylonjs.com/features/cameras
  8606. * @param name Defines the name of the camera in the scene
  8607. * @param position Defines the start position of the camera in the scene
  8608. * @param scene Defines the scene the camera belongs to
  8609. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8610. */
  8611. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8612. /**
  8613. * Gets the position in front of the camera at a given distance.
  8614. * @param distance The distance from the camera we want the position to be
  8615. * @returns the position
  8616. */
  8617. getFrontPosition(distance: number): Vector3;
  8618. /** @hidden */
  8619. _getLockedTargetPosition(): Nullable<Vector3>;
  8620. private _storedPosition;
  8621. private _storedRotation;
  8622. private _storedRotationQuaternion;
  8623. /**
  8624. * Store current camera state of the camera (fov, position, rotation, etc..)
  8625. * @returns the camera
  8626. */
  8627. storeState(): Camera;
  8628. /**
  8629. * Restored camera state. You must call storeState() first
  8630. * @returns whether it was successful or not
  8631. * @hidden
  8632. */
  8633. _restoreStateValues(): boolean;
  8634. /** @hidden */
  8635. _initCache(): void;
  8636. /** @hidden */
  8637. _updateCache(ignoreParentClass?: boolean): void;
  8638. /** @hidden */
  8639. _isSynchronizedViewMatrix(): boolean;
  8640. /** @hidden */
  8641. _computeLocalCameraSpeed(): number;
  8642. /**
  8643. * Defines the target the camera should look at.
  8644. * This will automatically adapt alpha beta and radius to fit within the new target.
  8645. * @param target Defines the new target as a Vector or a mesh
  8646. */
  8647. setTarget(target: Vector3): void;
  8648. /**
  8649. * Return the current target position of the camera. This value is expressed in local space.
  8650. * @returns the target position
  8651. */
  8652. getTarget(): Vector3;
  8653. /** @hidden */
  8654. _decideIfNeedsToMove(): boolean;
  8655. /** @hidden */
  8656. _updatePosition(): void;
  8657. /** @hidden */
  8658. _checkInputs(): void;
  8659. protected _updateCameraRotationMatrix(): void;
  8660. /**
  8661. * 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)
  8662. * @returns the current camera
  8663. */
  8664. private _rotateUpVectorWithCameraRotationMatrix;
  8665. private _cachedRotationZ;
  8666. private _cachedQuaternionRotationZ;
  8667. /** @hidden */
  8668. _getViewMatrix(): Matrix;
  8669. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8670. /**
  8671. * @hidden
  8672. */
  8673. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8674. /**
  8675. * @hidden
  8676. */
  8677. _updateRigCameras(): void;
  8678. private _getRigCamPositionAndTarget;
  8679. /**
  8680. * Gets the current object class name.
  8681. * @return the class name
  8682. */
  8683. getClassName(): string;
  8684. }
  8685. }
  8686. declare module "babylonjs/Cameras/cameraInputsManager" {
  8687. import { Nullable } from "babylonjs/types";
  8688. import { Camera } from "babylonjs/Cameras/camera";
  8689. /**
  8690. * @ignore
  8691. * This is a list of all the different input types that are available in the application.
  8692. * Fo instance: ArcRotateCameraGamepadInput...
  8693. */
  8694. export var CameraInputTypes: {};
  8695. /**
  8696. * This is the contract to implement in order to create a new input class.
  8697. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8698. */
  8699. export interface ICameraInput<TCamera extends Camera> {
  8700. /**
  8701. * Defines the camera the input is attached to.
  8702. */
  8703. camera: Nullable<TCamera>;
  8704. /**
  8705. * Gets the class name of the current intput.
  8706. * @returns the class name
  8707. */
  8708. getClassName(): string;
  8709. /**
  8710. * Get the friendly name associated with the input class.
  8711. * @returns the input friendly name
  8712. */
  8713. getSimpleName(): string;
  8714. /**
  8715. * Attach the input controls to a specific dom element to get the input from.
  8716. * @param element Defines the element the controls should be listened from
  8717. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8718. */
  8719. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8720. /**
  8721. * Detach the current controls from the specified dom element.
  8722. * @param element Defines the element to stop listening the inputs from
  8723. */
  8724. detachControl(element: Nullable<HTMLElement>): void;
  8725. /**
  8726. * Update the current camera state depending on the inputs that have been used this frame.
  8727. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8728. */
  8729. checkInputs?: () => void;
  8730. }
  8731. /**
  8732. * Represents a map of input types to input instance or input index to input instance.
  8733. */
  8734. export interface CameraInputsMap<TCamera extends Camera> {
  8735. /**
  8736. * Accessor to the input by input type.
  8737. */
  8738. [name: string]: ICameraInput<TCamera>;
  8739. /**
  8740. * Accessor to the input by input index.
  8741. */
  8742. [idx: number]: ICameraInput<TCamera>;
  8743. }
  8744. /**
  8745. * This represents the input manager used within a camera.
  8746. * It helps dealing with all the different kind of input attached to a camera.
  8747. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8748. */
  8749. export class CameraInputsManager<TCamera extends Camera> {
  8750. /**
  8751. * Defines the list of inputs attahed to the camera.
  8752. */
  8753. attached: CameraInputsMap<TCamera>;
  8754. /**
  8755. * Defines the dom element the camera is collecting inputs from.
  8756. * This is null if the controls have not been attached.
  8757. */
  8758. attachedElement: Nullable<HTMLElement>;
  8759. /**
  8760. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8761. */
  8762. noPreventDefault: boolean;
  8763. /**
  8764. * Defined the camera the input manager belongs to.
  8765. */
  8766. camera: TCamera;
  8767. /**
  8768. * Update the current camera state depending on the inputs that have been used this frame.
  8769. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8770. */
  8771. checkInputs: () => void;
  8772. /**
  8773. * Instantiate a new Camera Input Manager.
  8774. * @param camera Defines the camera the input manager blongs to
  8775. */
  8776. constructor(camera: TCamera);
  8777. /**
  8778. * Add an input method to a camera
  8779. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8780. * @param input camera input method
  8781. */
  8782. add(input: ICameraInput<TCamera>): void;
  8783. /**
  8784. * Remove a specific input method from a camera
  8785. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8786. * @param inputToRemove camera input method
  8787. */
  8788. remove(inputToRemove: ICameraInput<TCamera>): void;
  8789. /**
  8790. * Remove a specific input type from a camera
  8791. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8792. * @param inputType the type of the input to remove
  8793. */
  8794. removeByType(inputType: string): void;
  8795. private _addCheckInputs;
  8796. /**
  8797. * Attach the input controls to the currently attached dom element to listen the events from.
  8798. * @param input Defines the input to attach
  8799. */
  8800. attachInput(input: ICameraInput<TCamera>): void;
  8801. /**
  8802. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8803. * @param element Defines the dom element to collect the events from
  8804. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8805. */
  8806. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8807. /**
  8808. * Detach the current manager inputs controls from a specific dom element.
  8809. * @param element Defines the dom element to collect the events from
  8810. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8811. */
  8812. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8813. /**
  8814. * Rebuild the dynamic inputCheck function from the current list of
  8815. * defined inputs in the manager.
  8816. */
  8817. rebuildInputCheck(): void;
  8818. /**
  8819. * Remove all attached input methods from a camera
  8820. */
  8821. clear(): void;
  8822. /**
  8823. * Serialize the current input manager attached to a camera.
  8824. * This ensures than once parsed,
  8825. * the input associated to the camera will be identical to the current ones
  8826. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8827. */
  8828. serialize(serializedCamera: any): void;
  8829. /**
  8830. * Parses an input manager serialized JSON to restore the previous list of inputs
  8831. * and states associated to a camera.
  8832. * @param parsedCamera Defines the JSON to parse
  8833. */
  8834. parse(parsedCamera: any): void;
  8835. }
  8836. }
  8837. declare module "babylonjs/Events/keyboardEvents" {
  8838. /**
  8839. * Gather the list of keyboard event types as constants.
  8840. */
  8841. export class KeyboardEventTypes {
  8842. /**
  8843. * The keydown event is fired when a key becomes active (pressed).
  8844. */
  8845. static readonly KEYDOWN: number;
  8846. /**
  8847. * The keyup event is fired when a key has been released.
  8848. */
  8849. static readonly KEYUP: number;
  8850. }
  8851. /**
  8852. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8853. */
  8854. export class KeyboardInfo {
  8855. /**
  8856. * Defines the type of event (KeyboardEventTypes)
  8857. */
  8858. type: number;
  8859. /**
  8860. * Defines the related dom event
  8861. */
  8862. event: KeyboardEvent;
  8863. /**
  8864. * Instantiates a new keyboard info.
  8865. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8866. * @param type Defines the type of event (KeyboardEventTypes)
  8867. * @param event Defines the related dom event
  8868. */
  8869. constructor(
  8870. /**
  8871. * Defines the type of event (KeyboardEventTypes)
  8872. */
  8873. type: number,
  8874. /**
  8875. * Defines the related dom event
  8876. */
  8877. event: KeyboardEvent);
  8878. }
  8879. /**
  8880. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8881. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8882. */
  8883. export class KeyboardInfoPre extends KeyboardInfo {
  8884. /**
  8885. * Defines the type of event (KeyboardEventTypes)
  8886. */
  8887. type: number;
  8888. /**
  8889. * Defines the related dom event
  8890. */
  8891. event: KeyboardEvent;
  8892. /**
  8893. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8894. */
  8895. skipOnPointerObservable: boolean;
  8896. /**
  8897. * Instantiates a new keyboard pre info.
  8898. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8899. * @param type Defines the type of event (KeyboardEventTypes)
  8900. * @param event Defines the related dom event
  8901. */
  8902. constructor(
  8903. /**
  8904. * Defines the type of event (KeyboardEventTypes)
  8905. */
  8906. type: number,
  8907. /**
  8908. * Defines the related dom event
  8909. */
  8910. event: KeyboardEvent);
  8911. }
  8912. }
  8913. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8914. import { Nullable } from "babylonjs/types";
  8915. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8916. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8917. /**
  8918. * Manage the keyboard inputs to control the movement of a free camera.
  8919. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8920. */
  8921. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8922. /**
  8923. * Defines the camera the input is attached to.
  8924. */
  8925. camera: FreeCamera;
  8926. /**
  8927. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8928. */
  8929. keysUp: number[];
  8930. /**
  8931. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8932. */
  8933. keysDown: number[];
  8934. /**
  8935. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8936. */
  8937. keysLeft: number[];
  8938. /**
  8939. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8940. */
  8941. keysRight: number[];
  8942. private _keys;
  8943. private _onCanvasBlurObserver;
  8944. private _onKeyboardObserver;
  8945. private _engine;
  8946. private _scene;
  8947. /**
  8948. * Attach the input controls to a specific dom element to get the input from.
  8949. * @param element Defines the element the controls should be listened from
  8950. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8951. */
  8952. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8953. /**
  8954. * Detach the current controls from the specified dom element.
  8955. * @param element Defines the element to stop listening the inputs from
  8956. */
  8957. detachControl(element: Nullable<HTMLElement>): void;
  8958. /**
  8959. * Update the current camera state depending on the inputs that have been used this frame.
  8960. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8961. */
  8962. checkInputs(): void;
  8963. /**
  8964. * Gets the class name of the current intput.
  8965. * @returns the class name
  8966. */
  8967. getClassName(): string;
  8968. /** @hidden */
  8969. _onLostFocus(): void;
  8970. /**
  8971. * Get the friendly name associated with the input class.
  8972. * @returns the input friendly name
  8973. */
  8974. getSimpleName(): string;
  8975. }
  8976. }
  8977. declare module "babylonjs/Lights/shadowLight" {
  8978. import { Camera } from "babylonjs/Cameras/camera";
  8979. import { Scene } from "babylonjs/scene";
  8980. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8981. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8982. import { Light } from "babylonjs/Lights/light";
  8983. /**
  8984. * Interface describing all the common properties and methods a shadow light needs to implement.
  8985. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8986. * as well as binding the different shadow properties to the effects.
  8987. */
  8988. export interface IShadowLight extends Light {
  8989. /**
  8990. * The light id in the scene (used in scene.findLighById for instance)
  8991. */
  8992. id: string;
  8993. /**
  8994. * The position the shdow will be casted from.
  8995. */
  8996. position: Vector3;
  8997. /**
  8998. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8999. */
  9000. direction: Vector3;
  9001. /**
  9002. * The transformed position. Position of the light in world space taking parenting in account.
  9003. */
  9004. transformedPosition: Vector3;
  9005. /**
  9006. * The transformed direction. Direction of the light in world space taking parenting in account.
  9007. */
  9008. transformedDirection: Vector3;
  9009. /**
  9010. * The friendly name of the light in the scene.
  9011. */
  9012. name: string;
  9013. /**
  9014. * Defines the shadow projection clipping minimum z value.
  9015. */
  9016. shadowMinZ: number;
  9017. /**
  9018. * Defines the shadow projection clipping maximum z value.
  9019. */
  9020. shadowMaxZ: number;
  9021. /**
  9022. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9023. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9024. */
  9025. computeTransformedInformation(): boolean;
  9026. /**
  9027. * Gets the scene the light belongs to.
  9028. * @returns The scene
  9029. */
  9030. getScene(): Scene;
  9031. /**
  9032. * Callback defining a custom Projection Matrix Builder.
  9033. * This can be used to override the default projection matrix computation.
  9034. */
  9035. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9036. /**
  9037. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9038. * @param matrix The materix to updated with the projection information
  9039. * @param viewMatrix The transform matrix of the light
  9040. * @param renderList The list of mesh to render in the map
  9041. * @returns The current light
  9042. */
  9043. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9044. /**
  9045. * Gets the current depth scale used in ESM.
  9046. * @returns The scale
  9047. */
  9048. getDepthScale(): number;
  9049. /**
  9050. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9051. * @returns true if a cube texture needs to be use
  9052. */
  9053. needCube(): boolean;
  9054. /**
  9055. * Detects if the projection matrix requires to be recomputed this frame.
  9056. * @returns true if it requires to be recomputed otherwise, false.
  9057. */
  9058. needProjectionMatrixCompute(): boolean;
  9059. /**
  9060. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9061. */
  9062. forceProjectionMatrixCompute(): void;
  9063. /**
  9064. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9065. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9066. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9067. */
  9068. getShadowDirection(faceIndex?: number): Vector3;
  9069. /**
  9070. * Gets the minZ used for shadow according to both the scene and the light.
  9071. * @param activeCamera The camera we are returning the min for
  9072. * @returns the depth min z
  9073. */
  9074. getDepthMinZ(activeCamera: Camera): number;
  9075. /**
  9076. * Gets the maxZ used for shadow according to both the scene and the light.
  9077. * @param activeCamera The camera we are returning the max for
  9078. * @returns the depth max z
  9079. */
  9080. getDepthMaxZ(activeCamera: Camera): number;
  9081. }
  9082. /**
  9083. * Base implementation IShadowLight
  9084. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9085. */
  9086. export abstract class ShadowLight extends Light implements IShadowLight {
  9087. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9088. protected _position: Vector3;
  9089. protected _setPosition(value: Vector3): void;
  9090. /**
  9091. * Sets the position the shadow will be casted from. Also use as the light position for both
  9092. * point and spot lights.
  9093. */
  9094. /**
  9095. * Sets the position the shadow will be casted from. Also use as the light position for both
  9096. * point and spot lights.
  9097. */
  9098. position: Vector3;
  9099. protected _direction: Vector3;
  9100. protected _setDirection(value: Vector3): void;
  9101. /**
  9102. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9103. * Also use as the light direction on spot and directional lights.
  9104. */
  9105. /**
  9106. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9107. * Also use as the light direction on spot and directional lights.
  9108. */
  9109. direction: Vector3;
  9110. private _shadowMinZ;
  9111. /**
  9112. * Gets the shadow projection clipping minimum z value.
  9113. */
  9114. /**
  9115. * Sets the shadow projection clipping minimum z value.
  9116. */
  9117. shadowMinZ: number;
  9118. private _shadowMaxZ;
  9119. /**
  9120. * Sets the shadow projection clipping maximum z value.
  9121. */
  9122. /**
  9123. * Gets the shadow projection clipping maximum z value.
  9124. */
  9125. shadowMaxZ: number;
  9126. /**
  9127. * Callback defining a custom Projection Matrix Builder.
  9128. * This can be used to override the default projection matrix computation.
  9129. */
  9130. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9131. /**
  9132. * The transformed position. Position of the light in world space taking parenting in account.
  9133. */
  9134. transformedPosition: Vector3;
  9135. /**
  9136. * The transformed direction. Direction of the light in world space taking parenting in account.
  9137. */
  9138. transformedDirection: Vector3;
  9139. private _needProjectionMatrixCompute;
  9140. /**
  9141. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9142. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9143. */
  9144. computeTransformedInformation(): boolean;
  9145. /**
  9146. * Return the depth scale used for the shadow map.
  9147. * @returns the depth scale.
  9148. */
  9149. getDepthScale(): number;
  9150. /**
  9151. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9152. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9153. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9154. */
  9155. getShadowDirection(faceIndex?: number): Vector3;
  9156. /**
  9157. * Returns the ShadowLight absolute position in the World.
  9158. * @returns the position vector in world space
  9159. */
  9160. getAbsolutePosition(): Vector3;
  9161. /**
  9162. * Sets the ShadowLight direction toward the passed target.
  9163. * @param target The point to target in local space
  9164. * @returns the updated ShadowLight direction
  9165. */
  9166. setDirectionToTarget(target: Vector3): Vector3;
  9167. /**
  9168. * Returns the light rotation in euler definition.
  9169. * @returns the x y z rotation in local space.
  9170. */
  9171. getRotation(): Vector3;
  9172. /**
  9173. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9174. * @returns true if a cube texture needs to be use
  9175. */
  9176. needCube(): boolean;
  9177. /**
  9178. * Detects if the projection matrix requires to be recomputed this frame.
  9179. * @returns true if it requires to be recomputed otherwise, false.
  9180. */
  9181. needProjectionMatrixCompute(): boolean;
  9182. /**
  9183. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9184. */
  9185. forceProjectionMatrixCompute(): void;
  9186. /** @hidden */
  9187. _initCache(): void;
  9188. /** @hidden */
  9189. _isSynchronized(): boolean;
  9190. /**
  9191. * Computes the world matrix of the node
  9192. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9193. * @returns the world matrix
  9194. */
  9195. computeWorldMatrix(force?: boolean): Matrix;
  9196. /**
  9197. * Gets the minZ used for shadow according to both the scene and the light.
  9198. * @param activeCamera The camera we are returning the min for
  9199. * @returns the depth min z
  9200. */
  9201. getDepthMinZ(activeCamera: Camera): number;
  9202. /**
  9203. * Gets the maxZ used for shadow according to both the scene and the light.
  9204. * @param activeCamera The camera we are returning the max for
  9205. * @returns the depth max z
  9206. */
  9207. getDepthMaxZ(activeCamera: Camera): number;
  9208. /**
  9209. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9210. * @param matrix The materix to updated with the projection information
  9211. * @param viewMatrix The transform matrix of the light
  9212. * @param renderList The list of mesh to render in the map
  9213. * @returns The current light
  9214. */
  9215. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9216. }
  9217. }
  9218. declare module "babylonjs/Materials/materialHelper" {
  9219. import { Nullable } from "babylonjs/types";
  9220. import { Scene } from "babylonjs/scene";
  9221. import { Engine } from "babylonjs/Engines/engine";
  9222. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9223. import { Light } from "babylonjs/Lights/light";
  9224. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9225. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  9226. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9227. /**
  9228. * "Static Class" containing the most commonly used helper while dealing with material for
  9229. * rendering purpose.
  9230. *
  9231. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9232. *
  9233. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9234. */
  9235. export class MaterialHelper {
  9236. /**
  9237. * Bind the current view position to an effect.
  9238. * @param effect The effect to be bound
  9239. * @param scene The scene the eyes position is used from
  9240. */
  9241. static BindEyePosition(effect: Effect, scene: Scene): void;
  9242. /**
  9243. * Helps preparing the defines values about the UVs in used in the effect.
  9244. * UVs are shared as much as we can accross channels in the shaders.
  9245. * @param texture The texture we are preparing the UVs for
  9246. * @param defines The defines to update
  9247. * @param key The channel key "diffuse", "specular"... used in the shader
  9248. */
  9249. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9250. /**
  9251. * Binds a texture matrix value to its corrsponding uniform
  9252. * @param texture The texture to bind the matrix for
  9253. * @param uniformBuffer The uniform buffer receivin the data
  9254. * @param key The channel key "diffuse", "specular"... used in the shader
  9255. */
  9256. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9257. /**
  9258. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9259. * @param mesh defines the current mesh
  9260. * @param scene defines the current scene
  9261. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9262. * @param pointsCloud defines if point cloud rendering has to be turned on
  9263. * @param fogEnabled defines if fog has to be turned on
  9264. * @param alphaTest defines if alpha testing has to be turned on
  9265. * @param defines defines the current list of defines
  9266. */
  9267. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9268. /**
  9269. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9270. * @param scene defines the current scene
  9271. * @param engine defines the current engine
  9272. * @param defines specifies the list of active defines
  9273. * @param useInstances defines if instances have to be turned on
  9274. * @param useClipPlane defines if clip plane have to be turned on
  9275. */
  9276. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9277. /**
  9278. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9279. * @param mesh The mesh containing the geometry data we will draw
  9280. * @param defines The defines to update
  9281. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9282. * @param useBones Precise whether bones should be used or not (override mesh info)
  9283. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9284. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9285. * @returns false if defines are considered not dirty and have not been checked
  9286. */
  9287. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9288. /**
  9289. * Prepares the defines related to multiview
  9290. * @param scene The scene we are intending to draw
  9291. * @param defines The defines to update
  9292. */
  9293. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9294. /**
  9295. * Prepares the defines related to the light information passed in parameter
  9296. * @param scene The scene we are intending to draw
  9297. * @param mesh The mesh the effect is compiling for
  9298. * @param defines The defines to update
  9299. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9300. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9301. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9302. * @returns true if normals will be required for the rest of the effect
  9303. */
  9304. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9305. /**
  9306. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9307. * that won t be acctive due to defines being turned off.
  9308. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9309. * @param samplersList The samplers list
  9310. * @param defines The defines helping in the list generation
  9311. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9312. */
  9313. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9314. /**
  9315. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9316. * @param defines The defines to update while falling back
  9317. * @param fallbacks The authorized effect fallbacks
  9318. * @param maxSimultaneousLights The maximum number of lights allowed
  9319. * @param rank the current rank of the Effect
  9320. * @returns The newly affected rank
  9321. */
  9322. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9323. /**
  9324. * Prepares the list of attributes required for morph targets according to the effect defines.
  9325. * @param attribs The current list of supported attribs
  9326. * @param mesh The mesh to prepare the morph targets attributes for
  9327. * @param defines The current Defines of the effect
  9328. */
  9329. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9330. /**
  9331. * Prepares the list of attributes required for bones according to the effect defines.
  9332. * @param attribs The current list of supported attribs
  9333. * @param mesh The mesh to prepare the bones attributes for
  9334. * @param defines The current Defines of the effect
  9335. * @param fallbacks The current efffect fallback strategy
  9336. */
  9337. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9338. /**
  9339. * Prepares the list of attributes required for instances according to the effect defines.
  9340. * @param attribs The current list of supported attribs
  9341. * @param defines The current Defines of the effect
  9342. */
  9343. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9344. /**
  9345. * Binds the light shadow information to the effect for the given mesh.
  9346. * @param light The light containing the generator
  9347. * @param scene The scene the lights belongs to
  9348. * @param mesh The mesh we are binding the information to render
  9349. * @param lightIndex The light index in the effect used to render the mesh
  9350. * @param effect The effect we are binding the data to
  9351. */
  9352. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9353. /**
  9354. * Binds the light information to the effect.
  9355. * @param light The light containing the generator
  9356. * @param effect The effect we are binding the data to
  9357. * @param lightIndex The light index in the effect used to render
  9358. */
  9359. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9360. /**
  9361. * Binds the lights information from the scene to the effect for the given mesh.
  9362. * @param scene The scene the lights belongs to
  9363. * @param mesh The mesh we are binding the information to render
  9364. * @param effect The effect we are binding the data to
  9365. * @param defines The generated defines for the effect
  9366. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9367. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9368. */
  9369. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9370. private static _tempFogColor;
  9371. /**
  9372. * Binds the fog information from the scene to the effect for the given mesh.
  9373. * @param scene The scene the lights belongs to
  9374. * @param mesh The mesh we are binding the information to render
  9375. * @param effect The effect we are binding the data to
  9376. * @param linearSpace Defines if the fog effect is applied in linear space
  9377. */
  9378. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9379. /**
  9380. * Binds the bones information from the mesh to the effect.
  9381. * @param mesh The mesh we are binding the information to render
  9382. * @param effect The effect we are binding the data to
  9383. */
  9384. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9385. /**
  9386. * Binds the morph targets information from the mesh to the effect.
  9387. * @param abstractMesh The mesh we are binding the information to render
  9388. * @param effect The effect we are binding the data to
  9389. */
  9390. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9391. /**
  9392. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9393. * @param defines The generated defines used in the effect
  9394. * @param effect The effect we are binding the data to
  9395. * @param scene The scene we are willing to render with logarithmic scale for
  9396. */
  9397. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9398. /**
  9399. * Binds the clip plane information from the scene to the effect.
  9400. * @param scene The scene the clip plane information are extracted from
  9401. * @param effect The effect we are binding the data to
  9402. */
  9403. static BindClipPlane(effect: Effect, scene: Scene): void;
  9404. }
  9405. }
  9406. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  9407. /** @hidden */
  9408. export var kernelBlurVaryingDeclaration: {
  9409. name: string;
  9410. shader: string;
  9411. };
  9412. }
  9413. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  9414. /** @hidden */
  9415. export var kernelBlurFragment: {
  9416. name: string;
  9417. shader: string;
  9418. };
  9419. }
  9420. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  9421. /** @hidden */
  9422. export var kernelBlurFragment2: {
  9423. name: string;
  9424. shader: string;
  9425. };
  9426. }
  9427. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  9428. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9429. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  9430. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  9431. /** @hidden */
  9432. export var kernelBlurPixelShader: {
  9433. name: string;
  9434. shader: string;
  9435. };
  9436. }
  9437. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  9438. /** @hidden */
  9439. export var kernelBlurVertex: {
  9440. name: string;
  9441. shader: string;
  9442. };
  9443. }
  9444. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  9445. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9446. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  9447. /** @hidden */
  9448. export var kernelBlurVertexShader: {
  9449. name: string;
  9450. shader: string;
  9451. };
  9452. }
  9453. declare module "babylonjs/PostProcesses/blurPostProcess" {
  9454. import { Vector2 } from "babylonjs/Maths/math";
  9455. import { Nullable } from "babylonjs/types";
  9456. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  9457. import { Camera } from "babylonjs/Cameras/camera";
  9458. import { Effect } from "babylonjs/Materials/effect";
  9459. import { Engine } from "babylonjs/Engines/engine";
  9460. import "babylonjs/Shaders/kernelBlur.fragment";
  9461. import "babylonjs/Shaders/kernelBlur.vertex";
  9462. /**
  9463. * The Blur Post Process which blurs an image based on a kernel and direction.
  9464. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9465. */
  9466. export class BlurPostProcess extends PostProcess {
  9467. /** The direction in which to blur the image. */
  9468. direction: Vector2;
  9469. private blockCompilation;
  9470. protected _kernel: number;
  9471. protected _idealKernel: number;
  9472. protected _packedFloat: boolean;
  9473. private _staticDefines;
  9474. /**
  9475. * Sets the length in pixels of the blur sample region
  9476. */
  9477. /**
  9478. * Gets the length in pixels of the blur sample region
  9479. */
  9480. kernel: number;
  9481. /**
  9482. * Sets wether or not the blur needs to unpack/repack floats
  9483. */
  9484. /**
  9485. * Gets wether or not the blur is unpacking/repacking floats
  9486. */
  9487. packedFloat: boolean;
  9488. /**
  9489. * Creates a new instance BlurPostProcess
  9490. * @param name The name of the effect.
  9491. * @param direction The direction in which to blur the image.
  9492. * @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.
  9493. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9494. * @param camera The camera to apply the render pass to.
  9495. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9496. * @param engine The engine which the post process will be applied. (default: current engine)
  9497. * @param reusable If the post process can be reused on the same frame. (default: false)
  9498. * @param textureType Type of textures used when performing the post process. (default: 0)
  9499. * @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)
  9500. */
  9501. constructor(name: string,
  9502. /** The direction in which to blur the image. */
  9503. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9504. /**
  9505. * Updates the effect with the current post process compile time values and recompiles the shader.
  9506. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9507. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9508. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9509. * @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
  9510. * @param onCompiled Called when the shader has been compiled.
  9511. * @param onError Called if there is an error when compiling a shader.
  9512. */
  9513. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9514. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9515. /**
  9516. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9517. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9518. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9519. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9520. * The gaps between physical kernels are compensated for in the weighting of the samples
  9521. * @param idealKernel Ideal blur kernel.
  9522. * @return Nearest best kernel.
  9523. */
  9524. protected _nearestBestKernel(idealKernel: number): number;
  9525. /**
  9526. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9527. * @param x The point on the Gaussian distribution to sample.
  9528. * @return the value of the Gaussian function at x.
  9529. */
  9530. protected _gaussianWeight(x: number): number;
  9531. /**
  9532. * Generates a string that can be used as a floating point number in GLSL.
  9533. * @param x Value to print.
  9534. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9535. * @return GLSL float string.
  9536. */
  9537. protected _glslFloat(x: number, decimalFigures?: number): string;
  9538. }
  9539. }
  9540. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9541. /** @hidden */
  9542. export var shadowMapPixelShader: {
  9543. name: string;
  9544. shader: string;
  9545. };
  9546. }
  9547. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9548. /** @hidden */
  9549. export var bonesDeclaration: {
  9550. name: string;
  9551. shader: string;
  9552. };
  9553. }
  9554. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9555. /** @hidden */
  9556. export var morphTargetsVertexGlobalDeclaration: {
  9557. name: string;
  9558. shader: string;
  9559. };
  9560. }
  9561. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9562. /** @hidden */
  9563. export var morphTargetsVertexDeclaration: {
  9564. name: string;
  9565. shader: string;
  9566. };
  9567. }
  9568. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9569. /** @hidden */
  9570. export var instancesDeclaration: {
  9571. name: string;
  9572. shader: string;
  9573. };
  9574. }
  9575. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9576. /** @hidden */
  9577. export var helperFunctions: {
  9578. name: string;
  9579. shader: string;
  9580. };
  9581. }
  9582. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9583. /** @hidden */
  9584. export var morphTargetsVertex: {
  9585. name: string;
  9586. shader: string;
  9587. };
  9588. }
  9589. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9590. /** @hidden */
  9591. export var instancesVertex: {
  9592. name: string;
  9593. shader: string;
  9594. };
  9595. }
  9596. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9597. /** @hidden */
  9598. export var bonesVertex: {
  9599. name: string;
  9600. shader: string;
  9601. };
  9602. }
  9603. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9604. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9605. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9606. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9607. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9608. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9609. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9610. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9611. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9612. /** @hidden */
  9613. export var shadowMapVertexShader: {
  9614. name: string;
  9615. shader: string;
  9616. };
  9617. }
  9618. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9619. /** @hidden */
  9620. export var depthBoxBlurPixelShader: {
  9621. name: string;
  9622. shader: string;
  9623. };
  9624. }
  9625. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9626. import { Nullable } from "babylonjs/types";
  9627. import { Scene } from "babylonjs/scene";
  9628. import { Matrix } from "babylonjs/Maths/math";
  9629. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9630. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9631. import { Mesh } from "babylonjs/Meshes/mesh";
  9632. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9633. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9634. import { Effect } from "babylonjs/Materials/effect";
  9635. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9636. import "babylonjs/Shaders/shadowMap.fragment";
  9637. import "babylonjs/Shaders/shadowMap.vertex";
  9638. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9639. import { Observable } from "babylonjs/Misc/observable";
  9640. /**
  9641. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9642. */
  9643. export interface ICustomShaderOptions {
  9644. /**
  9645. * Gets or sets the custom shader name to use
  9646. */
  9647. shaderName: string;
  9648. /**
  9649. * The list of attribute names used in the shader
  9650. */
  9651. attributes?: string[];
  9652. /**
  9653. * The list of unifrom names used in the shader
  9654. */
  9655. uniforms?: string[];
  9656. /**
  9657. * The list of sampler names used in the shader
  9658. */
  9659. samplers?: string[];
  9660. /**
  9661. * The list of defines used in the shader
  9662. */
  9663. defines?: string[];
  9664. }
  9665. /**
  9666. * Interface to implement to create a shadow generator compatible with BJS.
  9667. */
  9668. export interface IShadowGenerator {
  9669. /**
  9670. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9671. * @returns The render target texture if present otherwise, null
  9672. */
  9673. getShadowMap(): Nullable<RenderTargetTexture>;
  9674. /**
  9675. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9676. * @returns The render target texture if the shadow map is present otherwise, null
  9677. */
  9678. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9679. /**
  9680. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9681. * @param subMesh The submesh we want to render in the shadow map
  9682. * @param useInstances Defines wether will draw in the map using instances
  9683. * @returns true if ready otherwise, false
  9684. */
  9685. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9686. /**
  9687. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9688. * @param defines Defines of the material we want to update
  9689. * @param lightIndex Index of the light in the enabled light list of the material
  9690. */
  9691. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9692. /**
  9693. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9694. * defined in the generator but impacting the effect).
  9695. * It implies the unifroms available on the materials are the standard BJS ones.
  9696. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9697. * @param effect The effect we are binfing the information for
  9698. */
  9699. bindShadowLight(lightIndex: string, effect: Effect): void;
  9700. /**
  9701. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9702. * (eq to shadow prjection matrix * light transform matrix)
  9703. * @returns The transform matrix used to create the shadow map
  9704. */
  9705. getTransformMatrix(): Matrix;
  9706. /**
  9707. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9708. * Cube and 2D textures for instance.
  9709. */
  9710. recreateShadowMap(): void;
  9711. /**
  9712. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9713. * @param onCompiled Callback triggered at the and of the effects compilation
  9714. * @param options Sets of optional options forcing the compilation with different modes
  9715. */
  9716. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9717. useInstances: boolean;
  9718. }>): void;
  9719. /**
  9720. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9721. * @param options Sets of optional options forcing the compilation with different modes
  9722. * @returns A promise that resolves when the compilation completes
  9723. */
  9724. forceCompilationAsync(options?: Partial<{
  9725. useInstances: boolean;
  9726. }>): Promise<void>;
  9727. /**
  9728. * Serializes the shadow generator setup to a json object.
  9729. * @returns The serialized JSON object
  9730. */
  9731. serialize(): any;
  9732. /**
  9733. * Disposes the Shadow map and related Textures and effects.
  9734. */
  9735. dispose(): void;
  9736. }
  9737. /**
  9738. * Default implementation IShadowGenerator.
  9739. * This is the main object responsible of generating shadows in the framework.
  9740. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9741. */
  9742. export class ShadowGenerator implements IShadowGenerator {
  9743. /**
  9744. * Shadow generator mode None: no filtering applied.
  9745. */
  9746. static readonly FILTER_NONE: number;
  9747. /**
  9748. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9749. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9750. */
  9751. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9752. /**
  9753. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9754. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9755. */
  9756. static readonly FILTER_POISSONSAMPLING: number;
  9757. /**
  9758. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9759. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9760. */
  9761. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9762. /**
  9763. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9764. * edge artifacts on steep falloff.
  9765. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9766. */
  9767. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9768. /**
  9769. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9770. * edge artifacts on steep falloff.
  9771. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9772. */
  9773. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9774. /**
  9775. * Shadow generator mode PCF: Percentage Closer Filtering
  9776. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9777. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9778. */
  9779. static readonly FILTER_PCF: number;
  9780. /**
  9781. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9782. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9783. * Contact Hardening
  9784. */
  9785. static readonly FILTER_PCSS: number;
  9786. /**
  9787. * Reserved for PCF and PCSS
  9788. * Highest Quality.
  9789. *
  9790. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9791. *
  9792. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9793. */
  9794. static readonly QUALITY_HIGH: number;
  9795. /**
  9796. * Reserved for PCF and PCSS
  9797. * Good tradeoff for quality/perf cross devices
  9798. *
  9799. * Execute PCF on a 3*3 kernel.
  9800. *
  9801. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9802. */
  9803. static readonly QUALITY_MEDIUM: number;
  9804. /**
  9805. * Reserved for PCF and PCSS
  9806. * The lowest quality but the fastest.
  9807. *
  9808. * Execute PCF on a 1*1 kernel.
  9809. *
  9810. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9811. */
  9812. static readonly QUALITY_LOW: number;
  9813. /** Gets or sets the custom shader name to use */
  9814. customShaderOptions: ICustomShaderOptions;
  9815. /**
  9816. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9817. */
  9818. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9819. /**
  9820. * Observable triggered before a mesh is rendered in the shadow map.
  9821. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9822. */
  9823. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9824. private _bias;
  9825. /**
  9826. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9827. */
  9828. /**
  9829. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9830. */
  9831. bias: number;
  9832. private _normalBias;
  9833. /**
  9834. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9835. */
  9836. /**
  9837. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9838. */
  9839. normalBias: number;
  9840. private _blurBoxOffset;
  9841. /**
  9842. * Gets the blur box offset: offset applied during the blur pass.
  9843. * Only useful if useKernelBlur = false
  9844. */
  9845. /**
  9846. * Sets the blur box offset: offset applied during the blur pass.
  9847. * Only useful if useKernelBlur = false
  9848. */
  9849. blurBoxOffset: number;
  9850. private _blurScale;
  9851. /**
  9852. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9853. * 2 means half of the size.
  9854. */
  9855. /**
  9856. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9857. * 2 means half of the size.
  9858. */
  9859. blurScale: number;
  9860. private _blurKernel;
  9861. /**
  9862. * Gets the blur kernel: kernel size of the blur pass.
  9863. * Only useful if useKernelBlur = true
  9864. */
  9865. /**
  9866. * Sets the blur kernel: kernel size of the blur pass.
  9867. * Only useful if useKernelBlur = true
  9868. */
  9869. blurKernel: number;
  9870. private _useKernelBlur;
  9871. /**
  9872. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9873. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9874. */
  9875. /**
  9876. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9877. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9878. */
  9879. useKernelBlur: boolean;
  9880. private _depthScale;
  9881. /**
  9882. * Gets the depth scale used in ESM mode.
  9883. */
  9884. /**
  9885. * Sets the depth scale used in ESM mode.
  9886. * This can override the scale stored on the light.
  9887. */
  9888. depthScale: number;
  9889. private _filter;
  9890. /**
  9891. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9892. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9893. */
  9894. /**
  9895. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9896. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9897. */
  9898. filter: number;
  9899. /**
  9900. * Gets if the current filter is set to Poisson Sampling.
  9901. */
  9902. /**
  9903. * Sets the current filter to Poisson Sampling.
  9904. */
  9905. usePoissonSampling: boolean;
  9906. /**
  9907. * Gets if the current filter is set to ESM.
  9908. */
  9909. /**
  9910. * Sets the current filter is to ESM.
  9911. */
  9912. useExponentialShadowMap: boolean;
  9913. /**
  9914. * Gets if the current filter is set to filtered ESM.
  9915. */
  9916. /**
  9917. * Gets if the current filter is set to filtered ESM.
  9918. */
  9919. useBlurExponentialShadowMap: boolean;
  9920. /**
  9921. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9922. * exponential to prevent steep falloff artifacts).
  9923. */
  9924. /**
  9925. * Sets the current filter to "close ESM" (using the inverse of the
  9926. * exponential to prevent steep falloff artifacts).
  9927. */
  9928. useCloseExponentialShadowMap: boolean;
  9929. /**
  9930. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9931. * exponential to prevent steep falloff artifacts).
  9932. */
  9933. /**
  9934. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9935. * exponential to prevent steep falloff artifacts).
  9936. */
  9937. useBlurCloseExponentialShadowMap: boolean;
  9938. /**
  9939. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9940. */
  9941. /**
  9942. * Sets the current filter to "PCF" (percentage closer filtering).
  9943. */
  9944. usePercentageCloserFiltering: boolean;
  9945. private _filteringQuality;
  9946. /**
  9947. * Gets the PCF or PCSS Quality.
  9948. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9949. */
  9950. /**
  9951. * Sets the PCF or PCSS Quality.
  9952. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9953. */
  9954. filteringQuality: number;
  9955. /**
  9956. * Gets if the current filter is set to "PCSS" (contact hardening).
  9957. */
  9958. /**
  9959. * Sets the current filter to "PCSS" (contact hardening).
  9960. */
  9961. useContactHardeningShadow: boolean;
  9962. private _contactHardeningLightSizeUVRatio;
  9963. /**
  9964. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9965. * Using a ratio helps keeping shape stability independently of the map size.
  9966. *
  9967. * It does not account for the light projection as it was having too much
  9968. * instability during the light setup or during light position changes.
  9969. *
  9970. * Only valid if useContactHardeningShadow is true.
  9971. */
  9972. /**
  9973. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9974. * Using a ratio helps keeping shape stability independently of the map size.
  9975. *
  9976. * It does not account for the light projection as it was having too much
  9977. * instability during the light setup or during light position changes.
  9978. *
  9979. * Only valid if useContactHardeningShadow is true.
  9980. */
  9981. contactHardeningLightSizeUVRatio: number;
  9982. private _darkness;
  9983. /**
  9984. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9985. * 0 means strongest and 1 would means no shadow.
  9986. * @returns the darkness.
  9987. */
  9988. getDarkness(): number;
  9989. /**
  9990. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9991. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9992. * @returns the shadow generator allowing fluent coding.
  9993. */
  9994. setDarkness(darkness: number): ShadowGenerator;
  9995. private _transparencyShadow;
  9996. /**
  9997. * Sets the ability to have transparent shadow (boolean).
  9998. * @param transparent True if transparent else False
  9999. * @returns the shadow generator allowing fluent coding
  10000. */
  10001. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  10002. private _shadowMap;
  10003. private _shadowMap2;
  10004. /**
  10005. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  10006. * @returns The render target texture if present otherwise, null
  10007. */
  10008. getShadowMap(): Nullable<RenderTargetTexture>;
  10009. /**
  10010. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10011. * @returns The render target texture if the shadow map is present otherwise, null
  10012. */
  10013. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10014. /**
  10015. * Helper function to add a mesh and its descendants to the list of shadow casters.
  10016. * @param mesh Mesh to add
  10017. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  10018. * @returns the Shadow Generator itself
  10019. */
  10020. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10021. /**
  10022. * Helper function to remove a mesh and its descendants from the list of shadow casters
  10023. * @param mesh Mesh to remove
  10024. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  10025. * @returns the Shadow Generator itself
  10026. */
  10027. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10028. /**
  10029. * Controls the extent to which the shadows fade out at the edge of the frustum
  10030. * Used only by directionals and spots
  10031. */
  10032. frustumEdgeFalloff: number;
  10033. private _light;
  10034. /**
  10035. * Returns the associated light object.
  10036. * @returns the light generating the shadow
  10037. */
  10038. getLight(): IShadowLight;
  10039. /**
  10040. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  10041. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  10042. * It might on the other hand introduce peter panning.
  10043. */
  10044. forceBackFacesOnly: boolean;
  10045. private _scene;
  10046. private _lightDirection;
  10047. private _effect;
  10048. private _viewMatrix;
  10049. private _projectionMatrix;
  10050. private _transformMatrix;
  10051. private _cachedPosition;
  10052. private _cachedDirection;
  10053. private _cachedDefines;
  10054. private _currentRenderID;
  10055. private _boxBlurPostprocess;
  10056. private _kernelBlurXPostprocess;
  10057. private _kernelBlurYPostprocess;
  10058. private _blurPostProcesses;
  10059. private _mapSize;
  10060. private _currentFaceIndex;
  10061. private _currentFaceIndexCache;
  10062. private _textureType;
  10063. private _defaultTextureMatrix;
  10064. /** @hidden */
  10065. static _SceneComponentInitialization: (scene: Scene) => void;
  10066. /**
  10067. * Creates a ShadowGenerator object.
  10068. * A ShadowGenerator is the required tool to use the shadows.
  10069. * Each light casting shadows needs to use its own ShadowGenerator.
  10070. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10071. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10072. * @param light The light object generating the shadows.
  10073. * @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.
  10074. */
  10075. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10076. private _initializeGenerator;
  10077. private _initializeShadowMap;
  10078. private _initializeBlurRTTAndPostProcesses;
  10079. private _renderForShadowMap;
  10080. private _renderSubMeshForShadowMap;
  10081. private _applyFilterValues;
  10082. /**
  10083. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10084. * @param onCompiled Callback triggered at the and of the effects compilation
  10085. * @param options Sets of optional options forcing the compilation with different modes
  10086. */
  10087. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10088. useInstances: boolean;
  10089. }>): void;
  10090. /**
  10091. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10092. * @param options Sets of optional options forcing the compilation with different modes
  10093. * @returns A promise that resolves when the compilation completes
  10094. */
  10095. forceCompilationAsync(options?: Partial<{
  10096. useInstances: boolean;
  10097. }>): Promise<void>;
  10098. /**
  10099. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10100. * @param subMesh The submesh we want to render in the shadow map
  10101. * @param useInstances Defines wether will draw in the map using instances
  10102. * @returns true if ready otherwise, false
  10103. */
  10104. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10105. /**
  10106. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10107. * @param defines Defines of the material we want to update
  10108. * @param lightIndex Index of the light in the enabled light list of the material
  10109. */
  10110. prepareDefines(defines: any, lightIndex: number): void;
  10111. /**
  10112. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10113. * defined in the generator but impacting the effect).
  10114. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10115. * @param effect The effect we are binfing the information for
  10116. */
  10117. bindShadowLight(lightIndex: string, effect: Effect): void;
  10118. /**
  10119. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10120. * (eq to shadow prjection matrix * light transform matrix)
  10121. * @returns The transform matrix used to create the shadow map
  10122. */
  10123. getTransformMatrix(): Matrix;
  10124. /**
  10125. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10126. * Cube and 2D textures for instance.
  10127. */
  10128. recreateShadowMap(): void;
  10129. private _disposeBlurPostProcesses;
  10130. private _disposeRTTandPostProcesses;
  10131. /**
  10132. * Disposes the ShadowGenerator.
  10133. * Returns nothing.
  10134. */
  10135. dispose(): void;
  10136. /**
  10137. * Serializes the shadow generator setup to a json object.
  10138. * @returns The serialized JSON object
  10139. */
  10140. serialize(): any;
  10141. /**
  10142. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10143. * @param parsedShadowGenerator The JSON object to parse
  10144. * @param scene The scene to create the shadow map for
  10145. * @returns The parsed shadow generator
  10146. */
  10147. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10148. }
  10149. }
  10150. declare module "babylonjs/Lights/light" {
  10151. import { Nullable } from "babylonjs/types";
  10152. import { Scene } from "babylonjs/scene";
  10153. import { Vector3, Color3 } from "babylonjs/Maths/math";
  10154. import { Node } from "babylonjs/node";
  10155. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10156. import { Effect } from "babylonjs/Materials/effect";
  10157. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10158. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10159. /**
  10160. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10161. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10162. * 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.
  10163. */
  10164. export abstract class Light extends Node {
  10165. /**
  10166. * Falloff Default: light is falling off following the material specification:
  10167. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10168. */
  10169. static readonly FALLOFF_DEFAULT: number;
  10170. /**
  10171. * Falloff Physical: light is falling off following the inverse squared distance law.
  10172. */
  10173. static readonly FALLOFF_PHYSICAL: number;
  10174. /**
  10175. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10176. * to enhance interoperability with other engines.
  10177. */
  10178. static readonly FALLOFF_GLTF: number;
  10179. /**
  10180. * Falloff Standard: light is falling off like in the standard material
  10181. * to enhance interoperability with other materials.
  10182. */
  10183. static readonly FALLOFF_STANDARD: number;
  10184. /**
  10185. * If every light affecting the material is in this lightmapMode,
  10186. * material.lightmapTexture adds or multiplies
  10187. * (depends on material.useLightmapAsShadowmap)
  10188. * after every other light calculations.
  10189. */
  10190. static readonly LIGHTMAP_DEFAULT: number;
  10191. /**
  10192. * material.lightmapTexture as only diffuse lighting from this light
  10193. * adds only specular lighting from this light
  10194. * adds dynamic shadows
  10195. */
  10196. static readonly LIGHTMAP_SPECULAR: number;
  10197. /**
  10198. * material.lightmapTexture as only lighting
  10199. * no light calculation from this light
  10200. * only adds dynamic shadows from this light
  10201. */
  10202. static readonly LIGHTMAP_SHADOWSONLY: number;
  10203. /**
  10204. * Each light type uses the default quantity according to its type:
  10205. * point/spot lights use luminous intensity
  10206. * directional lights use illuminance
  10207. */
  10208. static readonly INTENSITYMODE_AUTOMATIC: number;
  10209. /**
  10210. * lumen (lm)
  10211. */
  10212. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10213. /**
  10214. * candela (lm/sr)
  10215. */
  10216. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10217. /**
  10218. * lux (lm/m^2)
  10219. */
  10220. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10221. /**
  10222. * nit (cd/m^2)
  10223. */
  10224. static readonly INTENSITYMODE_LUMINANCE: number;
  10225. /**
  10226. * Light type const id of the point light.
  10227. */
  10228. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10229. /**
  10230. * Light type const id of the directional light.
  10231. */
  10232. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10233. /**
  10234. * Light type const id of the spot light.
  10235. */
  10236. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10237. /**
  10238. * Light type const id of the hemispheric light.
  10239. */
  10240. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10241. /**
  10242. * Diffuse gives the basic color to an object.
  10243. */
  10244. diffuse: Color3;
  10245. /**
  10246. * Specular produces a highlight color on an object.
  10247. * Note: This is note affecting PBR materials.
  10248. */
  10249. specular: Color3;
  10250. /**
  10251. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10252. * falling off base on range or angle.
  10253. * This can be set to any values in Light.FALLOFF_x.
  10254. *
  10255. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10256. * other types of materials.
  10257. */
  10258. falloffType: number;
  10259. /**
  10260. * Strength of the light.
  10261. * Note: By default it is define in the framework own unit.
  10262. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10263. */
  10264. intensity: number;
  10265. private _range;
  10266. protected _inverseSquaredRange: number;
  10267. /**
  10268. * Defines how far from the source the light is impacting in scene units.
  10269. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10270. */
  10271. /**
  10272. * Defines how far from the source the light is impacting in scene units.
  10273. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10274. */
  10275. range: number;
  10276. /**
  10277. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10278. * of light.
  10279. */
  10280. private _photometricScale;
  10281. private _intensityMode;
  10282. /**
  10283. * Gets the photometric scale used to interpret the intensity.
  10284. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10285. */
  10286. /**
  10287. * Sets the photometric scale used to interpret the intensity.
  10288. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10289. */
  10290. intensityMode: number;
  10291. private _radius;
  10292. /**
  10293. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10294. */
  10295. /**
  10296. * sets the light radius used by PBR Materials to simulate soft area lights.
  10297. */
  10298. radius: number;
  10299. private _renderPriority;
  10300. /**
  10301. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10302. * exceeding the number allowed of the materials.
  10303. */
  10304. renderPriority: number;
  10305. private _shadowEnabled;
  10306. /**
  10307. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10308. * the current shadow generator.
  10309. */
  10310. /**
  10311. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10312. * the current shadow generator.
  10313. */
  10314. shadowEnabled: boolean;
  10315. private _includedOnlyMeshes;
  10316. /**
  10317. * Gets the only meshes impacted by this light.
  10318. */
  10319. /**
  10320. * Sets the only meshes impacted by this light.
  10321. */
  10322. includedOnlyMeshes: AbstractMesh[];
  10323. private _excludedMeshes;
  10324. /**
  10325. * Gets the meshes not impacted by this light.
  10326. */
  10327. /**
  10328. * Sets the meshes not impacted by this light.
  10329. */
  10330. excludedMeshes: AbstractMesh[];
  10331. private _excludeWithLayerMask;
  10332. /**
  10333. * Gets the layer id use to find what meshes are not impacted by the light.
  10334. * Inactive if 0
  10335. */
  10336. /**
  10337. * Sets the layer id use to find what meshes are not impacted by the light.
  10338. * Inactive if 0
  10339. */
  10340. excludeWithLayerMask: number;
  10341. private _includeOnlyWithLayerMask;
  10342. /**
  10343. * Gets the layer id use to find what meshes are impacted by the light.
  10344. * Inactive if 0
  10345. */
  10346. /**
  10347. * Sets the layer id use to find what meshes are impacted by the light.
  10348. * Inactive if 0
  10349. */
  10350. includeOnlyWithLayerMask: number;
  10351. private _lightmapMode;
  10352. /**
  10353. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10354. */
  10355. /**
  10356. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10357. */
  10358. lightmapMode: number;
  10359. /**
  10360. * Shadow generator associted to the light.
  10361. * @hidden Internal use only.
  10362. */
  10363. _shadowGenerator: Nullable<IShadowGenerator>;
  10364. /**
  10365. * @hidden Internal use only.
  10366. */
  10367. _excludedMeshesIds: string[];
  10368. /**
  10369. * @hidden Internal use only.
  10370. */
  10371. _includedOnlyMeshesIds: string[];
  10372. /**
  10373. * The current light unifom buffer.
  10374. * @hidden Internal use only.
  10375. */
  10376. _uniformBuffer: UniformBuffer;
  10377. /**
  10378. * Creates a Light object in the scene.
  10379. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10380. * @param name The firendly name of the light
  10381. * @param scene The scene the light belongs too
  10382. */
  10383. constructor(name: string, scene: Scene);
  10384. protected abstract _buildUniformLayout(): void;
  10385. /**
  10386. * Sets the passed Effect "effect" with the Light information.
  10387. * @param effect The effect to update
  10388. * @param lightIndex The index of the light in the effect to update
  10389. * @returns The light
  10390. */
  10391. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10392. /**
  10393. * Returns the string "Light".
  10394. * @returns the class name
  10395. */
  10396. getClassName(): string;
  10397. /** @hidden */
  10398. readonly _isLight: boolean;
  10399. /**
  10400. * Converts the light information to a readable string for debug purpose.
  10401. * @param fullDetails Supports for multiple levels of logging within scene loading
  10402. * @returns the human readable light info
  10403. */
  10404. toString(fullDetails?: boolean): string;
  10405. /** @hidden */
  10406. protected _syncParentEnabledState(): void;
  10407. /**
  10408. * Set the enabled state of this node.
  10409. * @param value - the new enabled state
  10410. */
  10411. setEnabled(value: boolean): void;
  10412. /**
  10413. * Returns the Light associated shadow generator if any.
  10414. * @return the associated shadow generator.
  10415. */
  10416. getShadowGenerator(): Nullable<IShadowGenerator>;
  10417. /**
  10418. * Returns a Vector3, the absolute light position in the World.
  10419. * @returns the world space position of the light
  10420. */
  10421. getAbsolutePosition(): Vector3;
  10422. /**
  10423. * Specifies if the light will affect the passed mesh.
  10424. * @param mesh The mesh to test against the light
  10425. * @return true the mesh is affected otherwise, false.
  10426. */
  10427. canAffectMesh(mesh: AbstractMesh): boolean;
  10428. /**
  10429. * Sort function to order lights for rendering.
  10430. * @param a First Light object to compare to second.
  10431. * @param b Second Light object to compare first.
  10432. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10433. */
  10434. static CompareLightsPriority(a: Light, b: Light): number;
  10435. /**
  10436. * Releases resources associated with this node.
  10437. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10438. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10439. */
  10440. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10441. /**
  10442. * Returns the light type ID (integer).
  10443. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10444. */
  10445. getTypeID(): number;
  10446. /**
  10447. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10448. * @returns the scaled intensity in intensity mode unit
  10449. */
  10450. getScaledIntensity(): number;
  10451. /**
  10452. * Returns a new Light object, named "name", from the current one.
  10453. * @param name The name of the cloned light
  10454. * @returns the new created light
  10455. */
  10456. clone(name: string): Nullable<Light>;
  10457. /**
  10458. * Serializes the current light into a Serialization object.
  10459. * @returns the serialized object.
  10460. */
  10461. serialize(): any;
  10462. /**
  10463. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10464. * This new light is named "name" and added to the passed scene.
  10465. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10466. * @param name The friendly name of the light
  10467. * @param scene The scene the new light will belong to
  10468. * @returns the constructor function
  10469. */
  10470. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10471. /**
  10472. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10473. * @param parsedLight The JSON representation of the light
  10474. * @param scene The scene to create the parsed light in
  10475. * @returns the created light after parsing
  10476. */
  10477. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10478. private _hookArrayForExcluded;
  10479. private _hookArrayForIncludedOnly;
  10480. private _resyncMeshes;
  10481. /**
  10482. * Forces the meshes to update their light related information in their rendering used effects
  10483. * @hidden Internal Use Only
  10484. */
  10485. _markMeshesAsLightDirty(): void;
  10486. /**
  10487. * Recomputes the cached photometric scale if needed.
  10488. */
  10489. private _computePhotometricScale;
  10490. /**
  10491. * Returns the Photometric Scale according to the light type and intensity mode.
  10492. */
  10493. private _getPhotometricScale;
  10494. /**
  10495. * Reorder the light in the scene according to their defined priority.
  10496. * @hidden Internal Use Only
  10497. */
  10498. _reorderLightsInScene(): void;
  10499. /**
  10500. * Prepares the list of defines specific to the light type.
  10501. * @param defines the list of defines
  10502. * @param lightIndex defines the index of the light for the effect
  10503. */
  10504. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10505. }
  10506. }
  10507. declare module "babylonjs/Actions/action" {
  10508. import { Observable } from "babylonjs/Misc/observable";
  10509. import { Condition } from "babylonjs/Actions/condition";
  10510. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10511. import { ActionManager } from "babylonjs/Actions/actionManager";
  10512. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10513. /**
  10514. * Interface used to define Action
  10515. */
  10516. export interface IAction {
  10517. /**
  10518. * Trigger for the action
  10519. */
  10520. trigger: number;
  10521. /** Options of the trigger */
  10522. triggerOptions: any;
  10523. /**
  10524. * Gets the trigger parameters
  10525. * @returns the trigger parameters
  10526. */
  10527. getTriggerParameter(): any;
  10528. /**
  10529. * Internal only - executes current action event
  10530. * @hidden
  10531. */
  10532. _executeCurrent(evt?: ActionEvent): void;
  10533. /**
  10534. * Serialize placeholder for child classes
  10535. * @param parent of child
  10536. * @returns the serialized object
  10537. */
  10538. serialize(parent: any): any;
  10539. /**
  10540. * Internal only
  10541. * @hidden
  10542. */
  10543. _prepare(): void;
  10544. /**
  10545. * Internal only - manager for action
  10546. * @hidden
  10547. */
  10548. _actionManager: AbstractActionManager;
  10549. }
  10550. /**
  10551. * The action to be carried out following a trigger
  10552. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10553. */
  10554. export class Action implements IAction {
  10555. /** the trigger, with or without parameters, for the action */
  10556. triggerOptions: any;
  10557. /**
  10558. * Trigger for the action
  10559. */
  10560. trigger: number;
  10561. /**
  10562. * Internal only - manager for action
  10563. * @hidden
  10564. */
  10565. _actionManager: ActionManager;
  10566. private _nextActiveAction;
  10567. private _child;
  10568. private _condition?;
  10569. private _triggerParameter;
  10570. /**
  10571. * An event triggered prior to action being executed.
  10572. */
  10573. onBeforeExecuteObservable: Observable<Action>;
  10574. /**
  10575. * Creates a new Action
  10576. * @param triggerOptions the trigger, with or without parameters, for the action
  10577. * @param condition an optional determinant of action
  10578. */
  10579. constructor(
  10580. /** the trigger, with or without parameters, for the action */
  10581. triggerOptions: any, condition?: Condition);
  10582. /**
  10583. * Internal only
  10584. * @hidden
  10585. */
  10586. _prepare(): void;
  10587. /**
  10588. * Gets the trigger parameters
  10589. * @returns the trigger parameters
  10590. */
  10591. getTriggerParameter(): any;
  10592. /**
  10593. * Internal only - executes current action event
  10594. * @hidden
  10595. */
  10596. _executeCurrent(evt?: ActionEvent): void;
  10597. /**
  10598. * Execute placeholder for child classes
  10599. * @param evt optional action event
  10600. */
  10601. execute(evt?: ActionEvent): void;
  10602. /**
  10603. * Skips to next active action
  10604. */
  10605. skipToNextActiveAction(): void;
  10606. /**
  10607. * Adds action to chain of actions, may be a DoNothingAction
  10608. * @param action defines the next action to execute
  10609. * @returns The action passed in
  10610. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10611. */
  10612. then(action: Action): Action;
  10613. /**
  10614. * Internal only
  10615. * @hidden
  10616. */
  10617. _getProperty(propertyPath: string): string;
  10618. /**
  10619. * Internal only
  10620. * @hidden
  10621. */
  10622. _getEffectiveTarget(target: any, propertyPath: string): any;
  10623. /**
  10624. * Serialize placeholder for child classes
  10625. * @param parent of child
  10626. * @returns the serialized object
  10627. */
  10628. serialize(parent: any): any;
  10629. /**
  10630. * Internal only called by serialize
  10631. * @hidden
  10632. */
  10633. protected _serialize(serializedAction: any, parent?: any): any;
  10634. /**
  10635. * Internal only
  10636. * @hidden
  10637. */
  10638. static _SerializeValueAsString: (value: any) => string;
  10639. /**
  10640. * Internal only
  10641. * @hidden
  10642. */
  10643. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  10644. name: string;
  10645. targetType: string;
  10646. value: string;
  10647. };
  10648. }
  10649. }
  10650. declare module "babylonjs/Actions/condition" {
  10651. import { ActionManager } from "babylonjs/Actions/actionManager";
  10652. /**
  10653. * A Condition applied to an Action
  10654. */
  10655. export class Condition {
  10656. /**
  10657. * Internal only - manager for action
  10658. * @hidden
  10659. */
  10660. _actionManager: ActionManager;
  10661. /**
  10662. * Internal only
  10663. * @hidden
  10664. */
  10665. _evaluationId: number;
  10666. /**
  10667. * Internal only
  10668. * @hidden
  10669. */
  10670. _currentResult: boolean;
  10671. /**
  10672. * Creates a new Condition
  10673. * @param actionManager the manager of the action the condition is applied to
  10674. */
  10675. constructor(actionManager: ActionManager);
  10676. /**
  10677. * Check if the current condition is valid
  10678. * @returns a boolean
  10679. */
  10680. isValid(): boolean;
  10681. /**
  10682. * Internal only
  10683. * @hidden
  10684. */
  10685. _getProperty(propertyPath: string): string;
  10686. /**
  10687. * Internal only
  10688. * @hidden
  10689. */
  10690. _getEffectiveTarget(target: any, propertyPath: string): any;
  10691. /**
  10692. * Serialize placeholder for child classes
  10693. * @returns the serialized object
  10694. */
  10695. serialize(): any;
  10696. /**
  10697. * Internal only
  10698. * @hidden
  10699. */
  10700. protected _serialize(serializedCondition: any): any;
  10701. }
  10702. /**
  10703. * Defines specific conditional operators as extensions of Condition
  10704. */
  10705. export class ValueCondition extends Condition {
  10706. /** path to specify the property of the target the conditional operator uses */
  10707. propertyPath: string;
  10708. /** the value compared by the conditional operator against the current value of the property */
  10709. value: any;
  10710. /** the conditional operator, default ValueCondition.IsEqual */
  10711. operator: number;
  10712. /**
  10713. * Internal only
  10714. * @hidden
  10715. */
  10716. private static _IsEqual;
  10717. /**
  10718. * Internal only
  10719. * @hidden
  10720. */
  10721. private static _IsDifferent;
  10722. /**
  10723. * Internal only
  10724. * @hidden
  10725. */
  10726. private static _IsGreater;
  10727. /**
  10728. * Internal only
  10729. * @hidden
  10730. */
  10731. private static _IsLesser;
  10732. /**
  10733. * returns the number for IsEqual
  10734. */
  10735. static readonly IsEqual: number;
  10736. /**
  10737. * Returns the number for IsDifferent
  10738. */
  10739. static readonly IsDifferent: number;
  10740. /**
  10741. * Returns the number for IsGreater
  10742. */
  10743. static readonly IsGreater: number;
  10744. /**
  10745. * Returns the number for IsLesser
  10746. */
  10747. static readonly IsLesser: number;
  10748. /**
  10749. * Internal only The action manager for the condition
  10750. * @hidden
  10751. */
  10752. _actionManager: ActionManager;
  10753. /**
  10754. * Internal only
  10755. * @hidden
  10756. */
  10757. private _target;
  10758. /**
  10759. * Internal only
  10760. * @hidden
  10761. */
  10762. private _effectiveTarget;
  10763. /**
  10764. * Internal only
  10765. * @hidden
  10766. */
  10767. private _property;
  10768. /**
  10769. * Creates a new ValueCondition
  10770. * @param actionManager manager for the action the condition applies to
  10771. * @param target for the action
  10772. * @param propertyPath path to specify the property of the target the conditional operator uses
  10773. * @param value the value compared by the conditional operator against the current value of the property
  10774. * @param operator the conditional operator, default ValueCondition.IsEqual
  10775. */
  10776. constructor(actionManager: ActionManager, target: any,
  10777. /** path to specify the property of the target the conditional operator uses */
  10778. propertyPath: string,
  10779. /** the value compared by the conditional operator against the current value of the property */
  10780. value: any,
  10781. /** the conditional operator, default ValueCondition.IsEqual */
  10782. operator?: number);
  10783. /**
  10784. * Compares the given value with the property value for the specified conditional operator
  10785. * @returns the result of the comparison
  10786. */
  10787. isValid(): boolean;
  10788. /**
  10789. * Serialize the ValueCondition into a JSON compatible object
  10790. * @returns serialization object
  10791. */
  10792. serialize(): any;
  10793. /**
  10794. * Gets the name of the conditional operator for the ValueCondition
  10795. * @param operator the conditional operator
  10796. * @returns the name
  10797. */
  10798. static GetOperatorName(operator: number): string;
  10799. }
  10800. /**
  10801. * Defines a predicate condition as an extension of Condition
  10802. */
  10803. export class PredicateCondition extends Condition {
  10804. /** defines the predicate function used to validate the condition */
  10805. predicate: () => boolean;
  10806. /**
  10807. * Internal only - manager for action
  10808. * @hidden
  10809. */
  10810. _actionManager: ActionManager;
  10811. /**
  10812. * Creates a new PredicateCondition
  10813. * @param actionManager manager for the action the condition applies to
  10814. * @param predicate defines the predicate function used to validate the condition
  10815. */
  10816. constructor(actionManager: ActionManager,
  10817. /** defines the predicate function used to validate the condition */
  10818. predicate: () => boolean);
  10819. /**
  10820. * @returns the validity of the predicate condition
  10821. */
  10822. isValid(): boolean;
  10823. }
  10824. /**
  10825. * Defines a state condition as an extension of Condition
  10826. */
  10827. export class StateCondition extends Condition {
  10828. /** Value to compare with target state */
  10829. value: string;
  10830. /**
  10831. * Internal only - manager for action
  10832. * @hidden
  10833. */
  10834. _actionManager: ActionManager;
  10835. /**
  10836. * Internal only
  10837. * @hidden
  10838. */
  10839. private _target;
  10840. /**
  10841. * Creates a new StateCondition
  10842. * @param actionManager manager for the action the condition applies to
  10843. * @param target of the condition
  10844. * @param value to compare with target state
  10845. */
  10846. constructor(actionManager: ActionManager, target: any,
  10847. /** Value to compare with target state */
  10848. value: string);
  10849. /**
  10850. * Gets a boolean indicating if the current condition is met
  10851. * @returns the validity of the state
  10852. */
  10853. isValid(): boolean;
  10854. /**
  10855. * Serialize the StateCondition into a JSON compatible object
  10856. * @returns serialization object
  10857. */
  10858. serialize(): any;
  10859. }
  10860. }
  10861. declare module "babylonjs/Actions/directActions" {
  10862. import { Action } from "babylonjs/Actions/action";
  10863. import { Condition } from "babylonjs/Actions/condition";
  10864. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10865. /**
  10866. * This defines an action responsible to toggle a boolean once triggered.
  10867. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10868. */
  10869. export class SwitchBooleanAction extends Action {
  10870. /**
  10871. * The path to the boolean property in the target object
  10872. */
  10873. propertyPath: string;
  10874. private _target;
  10875. private _effectiveTarget;
  10876. private _property;
  10877. /**
  10878. * Instantiate the action
  10879. * @param triggerOptions defines the trigger options
  10880. * @param target defines the object containing the boolean
  10881. * @param propertyPath defines the path to the boolean property in the target object
  10882. * @param condition defines the trigger related conditions
  10883. */
  10884. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10885. /** @hidden */
  10886. _prepare(): void;
  10887. /**
  10888. * Execute the action toggle the boolean value.
  10889. */
  10890. execute(): void;
  10891. /**
  10892. * Serializes the actions and its related information.
  10893. * @param parent defines the object to serialize in
  10894. * @returns the serialized object
  10895. */
  10896. serialize(parent: any): any;
  10897. }
  10898. /**
  10899. * This defines an action responsible to set a the state field of the target
  10900. * to a desired value once triggered.
  10901. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10902. */
  10903. export class SetStateAction extends Action {
  10904. /**
  10905. * The value to store in the state field.
  10906. */
  10907. value: string;
  10908. private _target;
  10909. /**
  10910. * Instantiate the action
  10911. * @param triggerOptions defines the trigger options
  10912. * @param target defines the object containing the state property
  10913. * @param value defines the value to store in the state field
  10914. * @param condition defines the trigger related conditions
  10915. */
  10916. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10917. /**
  10918. * Execute the action and store the value on the target state property.
  10919. */
  10920. execute(): void;
  10921. /**
  10922. * Serializes the actions and its related information.
  10923. * @param parent defines the object to serialize in
  10924. * @returns the serialized object
  10925. */
  10926. serialize(parent: any): any;
  10927. }
  10928. /**
  10929. * This defines an action responsible to set a property of the target
  10930. * to a desired value once triggered.
  10931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10932. */
  10933. export class SetValueAction extends Action {
  10934. /**
  10935. * The path of the property to set in the target.
  10936. */
  10937. propertyPath: string;
  10938. /**
  10939. * The value to set in the property
  10940. */
  10941. value: any;
  10942. private _target;
  10943. private _effectiveTarget;
  10944. private _property;
  10945. /**
  10946. * Instantiate the action
  10947. * @param triggerOptions defines the trigger options
  10948. * @param target defines the object containing the property
  10949. * @param propertyPath defines the path of the property to set in the target
  10950. * @param value defines the value to set in the property
  10951. * @param condition defines the trigger related conditions
  10952. */
  10953. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10954. /** @hidden */
  10955. _prepare(): void;
  10956. /**
  10957. * Execute the action and set the targetted property to the desired value.
  10958. */
  10959. execute(): void;
  10960. /**
  10961. * Serializes the actions and its related information.
  10962. * @param parent defines the object to serialize in
  10963. * @returns the serialized object
  10964. */
  10965. serialize(parent: any): any;
  10966. }
  10967. /**
  10968. * This defines an action responsible to increment the target value
  10969. * to a desired value once triggered.
  10970. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10971. */
  10972. export class IncrementValueAction extends Action {
  10973. /**
  10974. * The path of the property to increment in the target.
  10975. */
  10976. propertyPath: string;
  10977. /**
  10978. * The value we should increment the property by.
  10979. */
  10980. value: any;
  10981. private _target;
  10982. private _effectiveTarget;
  10983. private _property;
  10984. /**
  10985. * Instantiate the action
  10986. * @param triggerOptions defines the trigger options
  10987. * @param target defines the object containing the property
  10988. * @param propertyPath defines the path of the property to increment in the target
  10989. * @param value defines the value value we should increment the property by
  10990. * @param condition defines the trigger related conditions
  10991. */
  10992. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10993. /** @hidden */
  10994. _prepare(): void;
  10995. /**
  10996. * Execute the action and increment the target of the value amount.
  10997. */
  10998. execute(): void;
  10999. /**
  11000. * Serializes the actions and its related information.
  11001. * @param parent defines the object to serialize in
  11002. * @returns the serialized object
  11003. */
  11004. serialize(parent: any): any;
  11005. }
  11006. /**
  11007. * This defines an action responsible to start an animation once triggered.
  11008. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11009. */
  11010. export class PlayAnimationAction extends Action {
  11011. /**
  11012. * Where the animation should start (animation frame)
  11013. */
  11014. from: number;
  11015. /**
  11016. * Where the animation should stop (animation frame)
  11017. */
  11018. to: number;
  11019. /**
  11020. * Define if the animation should loop or stop after the first play.
  11021. */
  11022. loop?: boolean;
  11023. private _target;
  11024. /**
  11025. * Instantiate the action
  11026. * @param triggerOptions defines the trigger options
  11027. * @param target defines the target animation or animation name
  11028. * @param from defines from where the animation should start (animation frame)
  11029. * @param end defines where the animation should stop (animation frame)
  11030. * @param loop defines if the animation should loop or stop after the first play
  11031. * @param condition defines the trigger related conditions
  11032. */
  11033. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  11034. /** @hidden */
  11035. _prepare(): void;
  11036. /**
  11037. * Execute the action and play the animation.
  11038. */
  11039. execute(): void;
  11040. /**
  11041. * Serializes the actions and its related information.
  11042. * @param parent defines the object to serialize in
  11043. * @returns the serialized object
  11044. */
  11045. serialize(parent: any): any;
  11046. }
  11047. /**
  11048. * This defines an action responsible to stop an animation once triggered.
  11049. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11050. */
  11051. export class StopAnimationAction extends Action {
  11052. private _target;
  11053. /**
  11054. * Instantiate the action
  11055. * @param triggerOptions defines the trigger options
  11056. * @param target defines the target animation or animation name
  11057. * @param condition defines the trigger related conditions
  11058. */
  11059. constructor(triggerOptions: any, target: any, condition?: Condition);
  11060. /** @hidden */
  11061. _prepare(): void;
  11062. /**
  11063. * Execute the action and stop the animation.
  11064. */
  11065. execute(): void;
  11066. /**
  11067. * Serializes the actions and its related information.
  11068. * @param parent defines the object to serialize in
  11069. * @returns the serialized object
  11070. */
  11071. serialize(parent: any): any;
  11072. }
  11073. /**
  11074. * This defines an action responsible that does nothing once triggered.
  11075. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11076. */
  11077. export class DoNothingAction extends Action {
  11078. /**
  11079. * Instantiate the action
  11080. * @param triggerOptions defines the trigger options
  11081. * @param condition defines the trigger related conditions
  11082. */
  11083. constructor(triggerOptions?: any, condition?: Condition);
  11084. /**
  11085. * Execute the action and do nothing.
  11086. */
  11087. execute(): void;
  11088. /**
  11089. * Serializes the actions and its related information.
  11090. * @param parent defines the object to serialize in
  11091. * @returns the serialized object
  11092. */
  11093. serialize(parent: any): any;
  11094. }
  11095. /**
  11096. * This defines an action responsible to trigger several actions once triggered.
  11097. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11098. */
  11099. export class CombineAction extends Action {
  11100. /**
  11101. * The list of aggregated animations to run.
  11102. */
  11103. children: Action[];
  11104. /**
  11105. * Instantiate the action
  11106. * @param triggerOptions defines the trigger options
  11107. * @param children defines the list of aggregated animations to run
  11108. * @param condition defines the trigger related conditions
  11109. */
  11110. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11111. /** @hidden */
  11112. _prepare(): void;
  11113. /**
  11114. * Execute the action and executes all the aggregated actions.
  11115. */
  11116. execute(evt: ActionEvent): 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 run code (external event) once triggered.
  11126. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11127. */
  11128. export class ExecuteCodeAction extends Action {
  11129. /**
  11130. * The callback function to run.
  11131. */
  11132. func: (evt: ActionEvent) => void;
  11133. /**
  11134. * Instantiate the action
  11135. * @param triggerOptions defines the trigger options
  11136. * @param func defines the callback function to run
  11137. * @param condition defines the trigger related conditions
  11138. */
  11139. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11140. /**
  11141. * Execute the action and run the attached code.
  11142. */
  11143. execute(evt: ActionEvent): void;
  11144. }
  11145. /**
  11146. * This defines an action responsible to set the parent property of the target once triggered.
  11147. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11148. */
  11149. export class SetParentAction extends Action {
  11150. private _parent;
  11151. private _target;
  11152. /**
  11153. * Instantiate the action
  11154. * @param triggerOptions defines the trigger options
  11155. * @param target defines the target containing the parent property
  11156. * @param parent defines from where the animation should start (animation frame)
  11157. * @param condition defines the trigger related conditions
  11158. */
  11159. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11160. /** @hidden */
  11161. _prepare(): void;
  11162. /**
  11163. * Execute the action and set the parent property.
  11164. */
  11165. execute(): void;
  11166. /**
  11167. * Serializes the actions and its related information.
  11168. * @param parent defines the object to serialize in
  11169. * @returns the serialized object
  11170. */
  11171. serialize(parent: any): any;
  11172. }
  11173. }
  11174. declare module "babylonjs/Actions/actionManager" {
  11175. import { Nullable } from "babylonjs/types";
  11176. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11177. import { Scene } from "babylonjs/scene";
  11178. import { IAction } from "babylonjs/Actions/action";
  11179. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11180. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11181. /**
  11182. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11183. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11184. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11185. */
  11186. export class ActionManager extends AbstractActionManager {
  11187. /**
  11188. * Nothing
  11189. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11190. */
  11191. static readonly NothingTrigger: number;
  11192. /**
  11193. * On pick
  11194. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11195. */
  11196. static readonly OnPickTrigger: number;
  11197. /**
  11198. * On left pick
  11199. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11200. */
  11201. static readonly OnLeftPickTrigger: number;
  11202. /**
  11203. * On right pick
  11204. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11205. */
  11206. static readonly OnRightPickTrigger: number;
  11207. /**
  11208. * On center pick
  11209. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11210. */
  11211. static readonly OnCenterPickTrigger: number;
  11212. /**
  11213. * On pick down
  11214. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11215. */
  11216. static readonly OnPickDownTrigger: number;
  11217. /**
  11218. * On double pick
  11219. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11220. */
  11221. static readonly OnDoublePickTrigger: number;
  11222. /**
  11223. * On pick up
  11224. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11225. */
  11226. static readonly OnPickUpTrigger: number;
  11227. /**
  11228. * On pick out.
  11229. * This trigger will only be raised if you also declared a OnPickDown
  11230. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11231. */
  11232. static readonly OnPickOutTrigger: number;
  11233. /**
  11234. * On long press
  11235. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11236. */
  11237. static readonly OnLongPressTrigger: number;
  11238. /**
  11239. * On pointer over
  11240. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11241. */
  11242. static readonly OnPointerOverTrigger: number;
  11243. /**
  11244. * On pointer out
  11245. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11246. */
  11247. static readonly OnPointerOutTrigger: number;
  11248. /**
  11249. * On every frame
  11250. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11251. */
  11252. static readonly OnEveryFrameTrigger: number;
  11253. /**
  11254. * On intersection enter
  11255. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11256. */
  11257. static readonly OnIntersectionEnterTrigger: number;
  11258. /**
  11259. * On intersection exit
  11260. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11261. */
  11262. static readonly OnIntersectionExitTrigger: number;
  11263. /**
  11264. * On key down
  11265. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11266. */
  11267. static readonly OnKeyDownTrigger: number;
  11268. /**
  11269. * On key up
  11270. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11271. */
  11272. static readonly OnKeyUpTrigger: number;
  11273. private _scene;
  11274. /**
  11275. * Creates a new action manager
  11276. * @param scene defines the hosting scene
  11277. */
  11278. constructor(scene: Scene);
  11279. /**
  11280. * Releases all associated resources
  11281. */
  11282. dispose(): void;
  11283. /**
  11284. * Gets hosting scene
  11285. * @returns the hosting scene
  11286. */
  11287. getScene(): Scene;
  11288. /**
  11289. * Does this action manager handles actions of any of the given triggers
  11290. * @param triggers defines the triggers to be tested
  11291. * @return a boolean indicating whether one (or more) of the triggers is handled
  11292. */
  11293. hasSpecificTriggers(triggers: number[]): boolean;
  11294. /**
  11295. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11296. * speed.
  11297. * @param triggerA defines the trigger to be tested
  11298. * @param triggerB defines the trigger to be tested
  11299. * @return a boolean indicating whether one (or more) of the triggers is handled
  11300. */
  11301. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11302. /**
  11303. * Does this action manager handles actions of a given trigger
  11304. * @param trigger defines the trigger to be tested
  11305. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11306. * @return whether the trigger is handled
  11307. */
  11308. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11309. /**
  11310. * Does this action manager has pointer triggers
  11311. */
  11312. readonly hasPointerTriggers: boolean;
  11313. /**
  11314. * Does this action manager has pick triggers
  11315. */
  11316. readonly hasPickTriggers: boolean;
  11317. /**
  11318. * Registers an action to this action manager
  11319. * @param action defines the action to be registered
  11320. * @return the action amended (prepared) after registration
  11321. */
  11322. registerAction(action: IAction): Nullable<IAction>;
  11323. /**
  11324. * Unregisters an action to this action manager
  11325. * @param action defines the action to be unregistered
  11326. * @return a boolean indicating whether the action has been unregistered
  11327. */
  11328. unregisterAction(action: IAction): Boolean;
  11329. /**
  11330. * Process a specific trigger
  11331. * @param trigger defines the trigger to process
  11332. * @param evt defines the event details to be processed
  11333. */
  11334. processTrigger(trigger: number, evt?: IActionEvent): void;
  11335. /** @hidden */
  11336. _getEffectiveTarget(target: any, propertyPath: string): any;
  11337. /** @hidden */
  11338. _getProperty(propertyPath: string): string;
  11339. /**
  11340. * Serialize this manager to a JSON object
  11341. * @param name defines the property name to store this manager
  11342. * @returns a JSON representation of this manager
  11343. */
  11344. serialize(name: string): any;
  11345. /**
  11346. * Creates a new ActionManager from a JSON data
  11347. * @param parsedActions defines the JSON data to read from
  11348. * @param object defines the hosting mesh
  11349. * @param scene defines the hosting scene
  11350. */
  11351. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11352. /**
  11353. * Get a trigger name by index
  11354. * @param trigger defines the trigger index
  11355. * @returns a trigger name
  11356. */
  11357. static GetTriggerName(trigger: number): string;
  11358. }
  11359. }
  11360. declare module "babylonjs/Culling/ray" {
  11361. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11362. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11363. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11364. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11365. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11366. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11367. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11368. /**
  11369. * Class representing a ray with position and direction
  11370. */
  11371. export class Ray {
  11372. /** origin point */
  11373. origin: Vector3;
  11374. /** direction */
  11375. direction: Vector3;
  11376. /** length of the ray */
  11377. length: number;
  11378. private static readonly TmpVector3;
  11379. private _tmpRay;
  11380. /**
  11381. * Creates a new ray
  11382. * @param origin origin point
  11383. * @param direction direction
  11384. * @param length length of the ray
  11385. */
  11386. constructor(
  11387. /** origin point */
  11388. origin: Vector3,
  11389. /** direction */
  11390. direction: Vector3,
  11391. /** length of the ray */
  11392. length?: number);
  11393. /**
  11394. * Checks if the ray intersects a box
  11395. * @param minimum bound of the box
  11396. * @param maximum bound of the box
  11397. * @param intersectionTreshold extra extend to be added to the box in all direction
  11398. * @returns if the box was hit
  11399. */
  11400. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11401. /**
  11402. * Checks if the ray intersects a box
  11403. * @param box the bounding box to check
  11404. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11405. * @returns if the box was hit
  11406. */
  11407. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11408. /**
  11409. * If the ray hits a sphere
  11410. * @param sphere the bounding sphere to check
  11411. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11412. * @returns true if it hits the sphere
  11413. */
  11414. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11415. /**
  11416. * If the ray hits a triange
  11417. * @param vertex0 triangle vertex
  11418. * @param vertex1 triangle vertex
  11419. * @param vertex2 triangle vertex
  11420. * @returns intersection information if hit
  11421. */
  11422. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11423. /**
  11424. * Checks if ray intersects a plane
  11425. * @param plane the plane to check
  11426. * @returns the distance away it was hit
  11427. */
  11428. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11429. /**
  11430. * Checks if ray intersects a mesh
  11431. * @param mesh the mesh to check
  11432. * @param fastCheck if only the bounding box should checked
  11433. * @returns picking info of the intersecton
  11434. */
  11435. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11436. /**
  11437. * Checks if ray intersects a mesh
  11438. * @param meshes the meshes to check
  11439. * @param fastCheck if only the bounding box should checked
  11440. * @param results array to store result in
  11441. * @returns Array of picking infos
  11442. */
  11443. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11444. private _comparePickingInfo;
  11445. private static smallnum;
  11446. private static rayl;
  11447. /**
  11448. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11449. * @param sega the first point of the segment to test the intersection against
  11450. * @param segb the second point of the segment to test the intersection against
  11451. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11452. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11453. */
  11454. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11455. /**
  11456. * Update the ray from viewport position
  11457. * @param x position
  11458. * @param y y position
  11459. * @param viewportWidth viewport width
  11460. * @param viewportHeight viewport height
  11461. * @param world world matrix
  11462. * @param view view matrix
  11463. * @param projection projection matrix
  11464. * @returns this ray updated
  11465. */
  11466. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11467. /**
  11468. * Creates a ray with origin and direction of 0,0,0
  11469. * @returns the new ray
  11470. */
  11471. static Zero(): Ray;
  11472. /**
  11473. * Creates a new ray from screen space and viewport
  11474. * @param x position
  11475. * @param y y position
  11476. * @param viewportWidth viewport width
  11477. * @param viewportHeight viewport height
  11478. * @param world world matrix
  11479. * @param view view matrix
  11480. * @param projection projection matrix
  11481. * @returns new ray
  11482. */
  11483. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11484. /**
  11485. * 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
  11486. * transformed to the given world matrix.
  11487. * @param origin The origin point
  11488. * @param end The end point
  11489. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11490. * @returns the new ray
  11491. */
  11492. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11493. /**
  11494. * Transforms a ray by a matrix
  11495. * @param ray ray to transform
  11496. * @param matrix matrix to apply
  11497. * @returns the resulting new ray
  11498. */
  11499. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11500. /**
  11501. * Transforms a ray by a matrix
  11502. * @param ray ray to transform
  11503. * @param matrix matrix to apply
  11504. * @param result ray to store result in
  11505. */
  11506. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11507. /**
  11508. * Unproject a ray from screen space to object space
  11509. * @param sourceX defines the screen space x coordinate to use
  11510. * @param sourceY defines the screen space y coordinate to use
  11511. * @param viewportWidth defines the current width of the viewport
  11512. * @param viewportHeight defines the current height of the viewport
  11513. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11514. * @param view defines the view matrix to use
  11515. * @param projection defines the projection matrix to use
  11516. */
  11517. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11518. }
  11519. /**
  11520. * Type used to define predicate used to select faces when a mesh intersection is detected
  11521. */
  11522. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11523. module "babylonjs/scene" {
  11524. interface Scene {
  11525. /** @hidden */
  11526. _tempPickingRay: Nullable<Ray>;
  11527. /** @hidden */
  11528. _cachedRayForTransform: Ray;
  11529. /** @hidden */
  11530. _pickWithRayInverseMatrix: Matrix;
  11531. /** @hidden */
  11532. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11533. /** @hidden */
  11534. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11535. }
  11536. }
  11537. }
  11538. declare module "babylonjs/sceneComponent" {
  11539. import { Scene } from "babylonjs/scene";
  11540. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11541. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11542. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11543. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11544. import { Nullable } from "babylonjs/types";
  11545. import { Camera } from "babylonjs/Cameras/camera";
  11546. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11547. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11548. import { AbstractScene } from "babylonjs/abstractScene";
  11549. /**
  11550. * Groups all the scene component constants in one place to ease maintenance.
  11551. * @hidden
  11552. */
  11553. export class SceneComponentConstants {
  11554. static readonly NAME_EFFECTLAYER: string;
  11555. static readonly NAME_LAYER: string;
  11556. static readonly NAME_LENSFLARESYSTEM: string;
  11557. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11558. static readonly NAME_PARTICLESYSTEM: string;
  11559. static readonly NAME_GAMEPAD: string;
  11560. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11561. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11562. static readonly NAME_DEPTHRENDERER: string;
  11563. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11564. static readonly NAME_SPRITE: string;
  11565. static readonly NAME_OUTLINERENDERER: string;
  11566. static readonly NAME_PROCEDURALTEXTURE: string;
  11567. static readonly NAME_SHADOWGENERATOR: string;
  11568. static readonly NAME_OCTREE: string;
  11569. static readonly NAME_PHYSICSENGINE: string;
  11570. static readonly NAME_AUDIO: string;
  11571. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11572. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11573. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11574. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11575. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11576. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11577. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11578. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11579. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11580. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11581. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11582. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11583. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11584. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11585. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11586. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11587. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11588. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11589. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11590. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11591. static readonly STEP_AFTERRENDER_AUDIO: number;
  11592. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11593. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11594. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11595. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11596. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11597. static readonly STEP_POINTERMOVE_SPRITE: number;
  11598. static readonly STEP_POINTERDOWN_SPRITE: number;
  11599. static readonly STEP_POINTERUP_SPRITE: number;
  11600. }
  11601. /**
  11602. * This represents a scene component.
  11603. *
  11604. * This is used to decouple the dependency the scene is having on the different workloads like
  11605. * layers, post processes...
  11606. */
  11607. export interface ISceneComponent {
  11608. /**
  11609. * The name of the component. Each component must have a unique name.
  11610. */
  11611. name: string;
  11612. /**
  11613. * The scene the component belongs to.
  11614. */
  11615. scene: Scene;
  11616. /**
  11617. * Register the component to one instance of a scene.
  11618. */
  11619. register(): void;
  11620. /**
  11621. * Rebuilds the elements related to this component in case of
  11622. * context lost for instance.
  11623. */
  11624. rebuild(): void;
  11625. /**
  11626. * Disposes the component and the associated ressources.
  11627. */
  11628. dispose(): void;
  11629. }
  11630. /**
  11631. * This represents a SERIALIZABLE scene component.
  11632. *
  11633. * This extends Scene Component to add Serialization methods on top.
  11634. */
  11635. export interface ISceneSerializableComponent extends ISceneComponent {
  11636. /**
  11637. * Adds all the element from the container to the scene
  11638. * @param container the container holding the elements
  11639. */
  11640. addFromContainer(container: AbstractScene): void;
  11641. /**
  11642. * Removes all the elements in the container from the scene
  11643. * @param container contains the elements to remove
  11644. * @param dispose if the removed element should be disposed (default: false)
  11645. */
  11646. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11647. /**
  11648. * Serializes the component data to the specified json object
  11649. * @param serializationObject The object to serialize to
  11650. */
  11651. serialize(serializationObject: any): void;
  11652. }
  11653. /**
  11654. * Strong typing of a Mesh related stage step action
  11655. */
  11656. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11657. /**
  11658. * Strong typing of a Evaluate Sub Mesh related stage step action
  11659. */
  11660. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11661. /**
  11662. * Strong typing of a Active Mesh related stage step action
  11663. */
  11664. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11665. /**
  11666. * Strong typing of a Camera related stage step action
  11667. */
  11668. export type CameraStageAction = (camera: Camera) => void;
  11669. /**
  11670. * Strong typing of a Render Target related stage step action
  11671. */
  11672. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11673. /**
  11674. * Strong typing of a RenderingGroup related stage step action
  11675. */
  11676. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11677. /**
  11678. * Strong typing of a Mesh Render related stage step action
  11679. */
  11680. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11681. /**
  11682. * Strong typing of a simple stage step action
  11683. */
  11684. export type SimpleStageAction = () => void;
  11685. /**
  11686. * Strong typing of a render target action.
  11687. */
  11688. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11689. /**
  11690. * Strong typing of a pointer move action.
  11691. */
  11692. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11693. /**
  11694. * Strong typing of a pointer up/down action.
  11695. */
  11696. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11697. /**
  11698. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11699. * @hidden
  11700. */
  11701. export class Stage<T extends Function> extends Array<{
  11702. index: number;
  11703. component: ISceneComponent;
  11704. action: T;
  11705. }> {
  11706. /**
  11707. * Hide ctor from the rest of the world.
  11708. * @param items The items to add.
  11709. */
  11710. private constructor();
  11711. /**
  11712. * Creates a new Stage.
  11713. * @returns A new instance of a Stage
  11714. */
  11715. static Create<T extends Function>(): Stage<T>;
  11716. /**
  11717. * Registers a step in an ordered way in the targeted stage.
  11718. * @param index Defines the position to register the step in
  11719. * @param component Defines the component attached to the step
  11720. * @param action Defines the action to launch during the step
  11721. */
  11722. registerStep(index: number, component: ISceneComponent, action: T): void;
  11723. /**
  11724. * Clears all the steps from the stage.
  11725. */
  11726. clear(): void;
  11727. }
  11728. }
  11729. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11730. import { Nullable } from "babylonjs/types";
  11731. import { Observable } from "babylonjs/Misc/observable";
  11732. import { Scene } from "babylonjs/scene";
  11733. import { Sprite } from "babylonjs/Sprites/sprite";
  11734. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11735. import { Ray } from "babylonjs/Culling/ray";
  11736. import { Camera } from "babylonjs/Cameras/camera";
  11737. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11738. import { ISceneComponent } from "babylonjs/sceneComponent";
  11739. module "babylonjs/scene" {
  11740. interface Scene {
  11741. /** @hidden */
  11742. _pointerOverSprite: Nullable<Sprite>;
  11743. /** @hidden */
  11744. _pickedDownSprite: Nullable<Sprite>;
  11745. /** @hidden */
  11746. _tempSpritePickingRay: Nullable<Ray>;
  11747. /**
  11748. * All of the sprite managers added to this scene
  11749. * @see http://doc.babylonjs.com/babylon101/sprites
  11750. */
  11751. spriteManagers: Array<ISpriteManager>;
  11752. /**
  11753. * An event triggered when sprites rendering is about to start
  11754. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11755. */
  11756. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11757. /**
  11758. * An event triggered when sprites rendering is done
  11759. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11760. */
  11761. onAfterSpritesRenderingObservable: Observable<Scene>;
  11762. /** @hidden */
  11763. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11764. /** Launch a ray to try to pick a sprite in the scene
  11765. * @param x position on screen
  11766. * @param y position on screen
  11767. * @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
  11768. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11769. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11770. * @returns a PickingInfo
  11771. */
  11772. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11773. /** Use the given ray to pick a sprite in the scene
  11774. * @param ray The ray (in world space) to use to pick meshes
  11775. * @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
  11776. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11777. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11778. * @returns a PickingInfo
  11779. */
  11780. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11781. /**
  11782. * Force the sprite under the pointer
  11783. * @param sprite defines the sprite to use
  11784. */
  11785. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11786. /**
  11787. * Gets the sprite under the pointer
  11788. * @returns a Sprite or null if no sprite is under the pointer
  11789. */
  11790. getPointerOverSprite(): Nullable<Sprite>;
  11791. }
  11792. }
  11793. /**
  11794. * Defines the sprite scene component responsible to manage sprites
  11795. * in a given scene.
  11796. */
  11797. export class SpriteSceneComponent implements ISceneComponent {
  11798. /**
  11799. * The component name helpfull to identify the component in the list of scene components.
  11800. */
  11801. readonly name: string;
  11802. /**
  11803. * The scene the component belongs to.
  11804. */
  11805. scene: Scene;
  11806. /** @hidden */
  11807. private _spritePredicate;
  11808. /**
  11809. * Creates a new instance of the component for the given scene
  11810. * @param scene Defines the scene to register the component in
  11811. */
  11812. constructor(scene: Scene);
  11813. /**
  11814. * Registers the component in a given scene
  11815. */
  11816. register(): void;
  11817. /**
  11818. * Rebuilds the elements related to this component in case of
  11819. * context lost for instance.
  11820. */
  11821. rebuild(): void;
  11822. /**
  11823. * Disposes the component and the associated ressources.
  11824. */
  11825. dispose(): void;
  11826. private _pickSpriteButKeepRay;
  11827. private _pointerMove;
  11828. private _pointerDown;
  11829. private _pointerUp;
  11830. }
  11831. }
  11832. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11833. /** @hidden */
  11834. export var fogFragmentDeclaration: {
  11835. name: string;
  11836. shader: string;
  11837. };
  11838. }
  11839. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11840. /** @hidden */
  11841. export var fogFragment: {
  11842. name: string;
  11843. shader: string;
  11844. };
  11845. }
  11846. declare module "babylonjs/Shaders/sprites.fragment" {
  11847. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11848. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11849. /** @hidden */
  11850. export var spritesPixelShader: {
  11851. name: string;
  11852. shader: string;
  11853. };
  11854. }
  11855. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11856. /** @hidden */
  11857. export var fogVertexDeclaration: {
  11858. name: string;
  11859. shader: string;
  11860. };
  11861. }
  11862. declare module "babylonjs/Shaders/sprites.vertex" {
  11863. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11864. /** @hidden */
  11865. export var spritesVertexShader: {
  11866. name: string;
  11867. shader: string;
  11868. };
  11869. }
  11870. declare module "babylonjs/Sprites/spriteManager" {
  11871. import { IDisposable, Scene } from "babylonjs/scene";
  11872. import { Nullable } from "babylonjs/types";
  11873. import { Observable } from "babylonjs/Misc/observable";
  11874. import { Sprite } from "babylonjs/Sprites/sprite";
  11875. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11876. import { Camera } from "babylonjs/Cameras/camera";
  11877. import { Texture } from "babylonjs/Materials/Textures/texture";
  11878. import "babylonjs/Shaders/sprites.fragment";
  11879. import "babylonjs/Shaders/sprites.vertex";
  11880. import { Ray } from "babylonjs/Culling/ray";
  11881. /**
  11882. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11883. */
  11884. export interface ISpriteManager extends IDisposable {
  11885. /**
  11886. * Restricts the camera to viewing objects with the same layerMask.
  11887. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11888. */
  11889. layerMask: number;
  11890. /**
  11891. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11892. */
  11893. isPickable: boolean;
  11894. /**
  11895. * Specifies the rendering group id for this mesh (0 by default)
  11896. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11897. */
  11898. renderingGroupId: number;
  11899. /**
  11900. * Defines the list of sprites managed by the manager.
  11901. */
  11902. sprites: Array<Sprite>;
  11903. /**
  11904. * Tests the intersection of a sprite with a specific ray.
  11905. * @param ray The ray we are sending to test the collision
  11906. * @param camera The camera space we are sending rays in
  11907. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11908. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11909. * @returns picking info or null.
  11910. */
  11911. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11912. /**
  11913. * Renders the list of sprites on screen.
  11914. */
  11915. render(): void;
  11916. }
  11917. /**
  11918. * Class used to manage multiple sprites on the same spritesheet
  11919. * @see http://doc.babylonjs.com/babylon101/sprites
  11920. */
  11921. export class SpriteManager implements ISpriteManager {
  11922. /** defines the manager's name */
  11923. name: string;
  11924. /** Gets the list of sprites */
  11925. sprites: Sprite[];
  11926. /** Gets or sets the rendering group id (0 by default) */
  11927. renderingGroupId: number;
  11928. /** Gets or sets camera layer mask */
  11929. layerMask: number;
  11930. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11931. fogEnabled: boolean;
  11932. /** Gets or sets a boolean indicating if the sprites are pickable */
  11933. isPickable: boolean;
  11934. /** Defines the default width of a cell in the spritesheet */
  11935. cellWidth: number;
  11936. /** Defines the default height of a cell in the spritesheet */
  11937. cellHeight: number;
  11938. /**
  11939. * An event triggered when the manager is disposed.
  11940. */
  11941. onDisposeObservable: Observable<SpriteManager>;
  11942. private _onDisposeObserver;
  11943. /**
  11944. * Callback called when the manager is disposed
  11945. */
  11946. onDispose: () => void;
  11947. private _capacity;
  11948. private _spriteTexture;
  11949. private _epsilon;
  11950. private _scene;
  11951. private _vertexData;
  11952. private _buffer;
  11953. private _vertexBuffers;
  11954. private _indexBuffer;
  11955. private _effectBase;
  11956. private _effectFog;
  11957. /**
  11958. * Gets or sets the spritesheet texture
  11959. */
  11960. texture: Texture;
  11961. /**
  11962. * Creates a new sprite manager
  11963. * @param name defines the manager's name
  11964. * @param imgUrl defines the sprite sheet url
  11965. * @param capacity defines the maximum allowed number of sprites
  11966. * @param cellSize defines the size of a sprite cell
  11967. * @param scene defines the hosting scene
  11968. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11969. * @param samplingMode defines the smapling mode to use with spritesheet
  11970. */
  11971. constructor(
  11972. /** defines the manager's name */
  11973. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11974. private _appendSpriteVertex;
  11975. /**
  11976. * Intersects the sprites with a ray
  11977. * @param ray defines the ray to intersect with
  11978. * @param camera defines the current active camera
  11979. * @param predicate defines a predicate used to select candidate sprites
  11980. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11981. * @returns null if no hit or a PickingInfo
  11982. */
  11983. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11984. /**
  11985. * Render all child sprites
  11986. */
  11987. render(): void;
  11988. /**
  11989. * Release associated resources
  11990. */
  11991. dispose(): void;
  11992. }
  11993. }
  11994. declare module "babylonjs/Sprites/sprite" {
  11995. import { Vector3, Color4 } from "babylonjs/Maths/math";
  11996. import { Nullable } from "babylonjs/types";
  11997. import { ActionManager } from "babylonjs/Actions/actionManager";
  11998. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11999. /**
  12000. * Class used to represent a sprite
  12001. * @see http://doc.babylonjs.com/babylon101/sprites
  12002. */
  12003. export class Sprite {
  12004. /** defines the name */
  12005. name: string;
  12006. /** Gets or sets the current world position */
  12007. position: Vector3;
  12008. /** Gets or sets the main color */
  12009. color: Color4;
  12010. /** Gets or sets the width */
  12011. width: number;
  12012. /** Gets or sets the height */
  12013. height: number;
  12014. /** Gets or sets rotation angle */
  12015. angle: number;
  12016. /** Gets or sets the cell index in the sprite sheet */
  12017. cellIndex: number;
  12018. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12019. invertU: number;
  12020. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12021. invertV: number;
  12022. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12023. disposeWhenFinishedAnimating: boolean;
  12024. /** Gets the list of attached animations */
  12025. animations: Animation[];
  12026. /** Gets or sets a boolean indicating if the sprite can be picked */
  12027. isPickable: boolean;
  12028. /**
  12029. * Gets or sets the associated action manager
  12030. */
  12031. actionManager: Nullable<ActionManager>;
  12032. private _animationStarted;
  12033. private _loopAnimation;
  12034. private _fromIndex;
  12035. private _toIndex;
  12036. private _delay;
  12037. private _direction;
  12038. private _manager;
  12039. private _time;
  12040. private _onAnimationEnd;
  12041. /**
  12042. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12043. */
  12044. isVisible: boolean;
  12045. /**
  12046. * Gets or sets the sprite size
  12047. */
  12048. size: number;
  12049. /**
  12050. * Creates a new Sprite
  12051. * @param name defines the name
  12052. * @param manager defines the manager
  12053. */
  12054. constructor(
  12055. /** defines the name */
  12056. name: string, manager: ISpriteManager);
  12057. /**
  12058. * Starts an animation
  12059. * @param from defines the initial key
  12060. * @param to defines the end key
  12061. * @param loop defines if the animation must loop
  12062. * @param delay defines the start delay (in ms)
  12063. * @param onAnimationEnd defines a callback to call when animation ends
  12064. */
  12065. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12066. /** Stops current animation (if any) */
  12067. stopAnimation(): void;
  12068. /** @hidden */
  12069. _animate(deltaTime: number): void;
  12070. /** Release associated resources */
  12071. dispose(): void;
  12072. }
  12073. }
  12074. declare module "babylonjs/Collisions/pickingInfo" {
  12075. import { Nullable } from "babylonjs/types";
  12076. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  12077. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12078. import { Sprite } from "babylonjs/Sprites/sprite";
  12079. import { Ray } from "babylonjs/Culling/ray";
  12080. /**
  12081. * Information about the result of picking within a scene
  12082. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12083. */
  12084. export class PickingInfo {
  12085. /** @hidden */
  12086. _pickingUnavailable: boolean;
  12087. /**
  12088. * If the pick collided with an object
  12089. */
  12090. hit: boolean;
  12091. /**
  12092. * Distance away where the pick collided
  12093. */
  12094. distance: number;
  12095. /**
  12096. * The location of pick collision
  12097. */
  12098. pickedPoint: Nullable<Vector3>;
  12099. /**
  12100. * The mesh corresponding the the pick collision
  12101. */
  12102. pickedMesh: Nullable<AbstractMesh>;
  12103. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  12104. bu: number;
  12105. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  12106. bv: number;
  12107. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12108. faceId: number;
  12109. /** Id of the the submesh that was picked */
  12110. subMeshId: number;
  12111. /** If a sprite was picked, this will be the sprite the pick collided with */
  12112. pickedSprite: Nullable<Sprite>;
  12113. /**
  12114. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12115. */
  12116. originMesh: Nullable<AbstractMesh>;
  12117. /**
  12118. * The ray that was used to perform the picking.
  12119. */
  12120. ray: Nullable<Ray>;
  12121. /**
  12122. * Gets the normal correspodning to the face the pick collided with
  12123. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12124. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12125. * @returns The normal correspodning to the face the pick collided with
  12126. */
  12127. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12128. /**
  12129. * Gets the texture coordinates of where the pick occured
  12130. * @returns the vector containing the coordnates of the texture
  12131. */
  12132. getTextureCoordinates(): Nullable<Vector2>;
  12133. }
  12134. }
  12135. declare module "babylonjs/Events/pointerEvents" {
  12136. import { Nullable } from "babylonjs/types";
  12137. import { Vector2 } from "babylonjs/Maths/math";
  12138. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12139. import { Ray } from "babylonjs/Culling/ray";
  12140. /**
  12141. * Gather the list of pointer event types as constants.
  12142. */
  12143. export class PointerEventTypes {
  12144. /**
  12145. * 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.
  12146. */
  12147. static readonly POINTERDOWN: number;
  12148. /**
  12149. * The pointerup event is fired when a pointer is no longer active.
  12150. */
  12151. static readonly POINTERUP: number;
  12152. /**
  12153. * The pointermove event is fired when a pointer changes coordinates.
  12154. */
  12155. static readonly POINTERMOVE: number;
  12156. /**
  12157. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12158. */
  12159. static readonly POINTERWHEEL: number;
  12160. /**
  12161. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12162. */
  12163. static readonly POINTERPICK: number;
  12164. /**
  12165. * The pointertap event is fired when a the object has been touched and released without drag.
  12166. */
  12167. static readonly POINTERTAP: number;
  12168. /**
  12169. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12170. */
  12171. static readonly POINTERDOUBLETAP: number;
  12172. }
  12173. /**
  12174. * Base class of pointer info types.
  12175. */
  12176. export class PointerInfoBase {
  12177. /**
  12178. * Defines the type of event (PointerEventTypes)
  12179. */
  12180. type: number;
  12181. /**
  12182. * Defines the related dom event
  12183. */
  12184. event: PointerEvent | MouseWheelEvent;
  12185. /**
  12186. * Instantiates the base class of pointers info.
  12187. * @param type Defines the type of event (PointerEventTypes)
  12188. * @param event Defines the related dom event
  12189. */
  12190. constructor(
  12191. /**
  12192. * Defines the type of event (PointerEventTypes)
  12193. */
  12194. type: number,
  12195. /**
  12196. * Defines the related dom event
  12197. */
  12198. event: PointerEvent | MouseWheelEvent);
  12199. }
  12200. /**
  12201. * This class is used to store pointer related info for the onPrePointerObservable event.
  12202. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12203. */
  12204. export class PointerInfoPre extends PointerInfoBase {
  12205. /**
  12206. * Ray from a pointer if availible (eg. 6dof controller)
  12207. */
  12208. ray: Nullable<Ray>;
  12209. /**
  12210. * Defines the local position of the pointer on the canvas.
  12211. */
  12212. localPosition: Vector2;
  12213. /**
  12214. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12215. */
  12216. skipOnPointerObservable: boolean;
  12217. /**
  12218. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12219. * @param type Defines the type of event (PointerEventTypes)
  12220. * @param event Defines the related dom event
  12221. * @param localX Defines the local x coordinates of the pointer when the event occured
  12222. * @param localY Defines the local y coordinates of the pointer when the event occured
  12223. */
  12224. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12225. }
  12226. /**
  12227. * This type contains all the data related to a pointer event in Babylon.js.
  12228. * 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.
  12229. */
  12230. export class PointerInfo extends PointerInfoBase {
  12231. /**
  12232. * Defines the picking info associated to the info (if any)\
  12233. */
  12234. pickInfo: Nullable<PickingInfo>;
  12235. /**
  12236. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12237. * @param type Defines the type of event (PointerEventTypes)
  12238. * @param event Defines the related dom event
  12239. * @param pickInfo Defines the picking info associated to the info (if any)\
  12240. */
  12241. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12242. /**
  12243. * Defines the picking info associated to the info (if any)\
  12244. */
  12245. pickInfo: Nullable<PickingInfo>);
  12246. }
  12247. /**
  12248. * Data relating to a touch event on the screen.
  12249. */
  12250. export interface PointerTouch {
  12251. /**
  12252. * X coordinate of touch.
  12253. */
  12254. x: number;
  12255. /**
  12256. * Y coordinate of touch.
  12257. */
  12258. y: number;
  12259. /**
  12260. * Id of touch. Unique for each finger.
  12261. */
  12262. pointerId: number;
  12263. /**
  12264. * Event type passed from DOM.
  12265. */
  12266. type: any;
  12267. }
  12268. }
  12269. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12270. import { Observable } from "babylonjs/Misc/observable";
  12271. import { Nullable } from "babylonjs/types";
  12272. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12273. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12274. /**
  12275. * Manage the mouse inputs to control the movement of a free camera.
  12276. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12277. */
  12278. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12279. /**
  12280. * Define if touch is enabled in the mouse input
  12281. */
  12282. touchEnabled: boolean;
  12283. /**
  12284. * Defines the camera the input is attached to.
  12285. */
  12286. camera: FreeCamera;
  12287. /**
  12288. * Defines the buttons associated with the input to handle camera move.
  12289. */
  12290. buttons: number[];
  12291. /**
  12292. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12293. */
  12294. angularSensibility: number;
  12295. private _pointerInput;
  12296. private _onMouseMove;
  12297. private _observer;
  12298. private previousPosition;
  12299. /**
  12300. * Observable for when a pointer move event occurs containing the move offset
  12301. */
  12302. onPointerMovedObservable: Observable<{
  12303. offsetX: number;
  12304. offsetY: number;
  12305. }>;
  12306. /**
  12307. * @hidden
  12308. * If the camera should be rotated automatically based on pointer movement
  12309. */
  12310. _allowCameraRotation: boolean;
  12311. /**
  12312. * Manage the mouse inputs to control the movement of a free camera.
  12313. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12314. * @param touchEnabled Defines if touch is enabled or not
  12315. */
  12316. constructor(
  12317. /**
  12318. * Define if touch is enabled in the mouse input
  12319. */
  12320. touchEnabled?: boolean);
  12321. /**
  12322. * Attach the input controls to a specific dom element to get the input from.
  12323. * @param element Defines the element the controls should be listened from
  12324. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12325. */
  12326. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12327. /**
  12328. * Called on JS contextmenu event.
  12329. * Override this method to provide functionality.
  12330. */
  12331. protected onContextMenu(evt: PointerEvent): void;
  12332. /**
  12333. * Detach the current controls from the specified dom element.
  12334. * @param element Defines the element to stop listening the inputs from
  12335. */
  12336. detachControl(element: Nullable<HTMLElement>): void;
  12337. /**
  12338. * Gets the class name of the current intput.
  12339. * @returns the class name
  12340. */
  12341. getClassName(): string;
  12342. /**
  12343. * Get the friendly name associated with the input class.
  12344. * @returns the input friendly name
  12345. */
  12346. getSimpleName(): string;
  12347. }
  12348. }
  12349. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12350. import { Nullable } from "babylonjs/types";
  12351. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12352. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12353. /**
  12354. * Manage the touch inputs to control the movement of a free camera.
  12355. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12356. */
  12357. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12358. /**
  12359. * Defines the camera the input is attached to.
  12360. */
  12361. camera: FreeCamera;
  12362. /**
  12363. * Defines the touch sensibility for rotation.
  12364. * The higher the faster.
  12365. */
  12366. touchAngularSensibility: number;
  12367. /**
  12368. * Defines the touch sensibility for move.
  12369. * The higher the faster.
  12370. */
  12371. touchMoveSensibility: number;
  12372. private _offsetX;
  12373. private _offsetY;
  12374. private _pointerPressed;
  12375. private _pointerInput;
  12376. private _observer;
  12377. private _onLostFocus;
  12378. /**
  12379. * Attach the input controls to a specific dom element to get the input from.
  12380. * @param element Defines the element the controls should be listened from
  12381. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12382. */
  12383. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12384. /**
  12385. * Detach the current controls from the specified dom element.
  12386. * @param element Defines the element to stop listening the inputs from
  12387. */
  12388. detachControl(element: Nullable<HTMLElement>): void;
  12389. /**
  12390. * Update the current camera state depending on the inputs that have been used this frame.
  12391. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12392. */
  12393. checkInputs(): void;
  12394. /**
  12395. * Gets the class name of the current intput.
  12396. * @returns the class name
  12397. */
  12398. getClassName(): string;
  12399. /**
  12400. * Get the friendly name associated with the input class.
  12401. * @returns the input friendly name
  12402. */
  12403. getSimpleName(): string;
  12404. }
  12405. }
  12406. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12407. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12408. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12409. import { FreeCameraKeyboardMoveInput } from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  12410. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12411. import { Nullable } from "babylonjs/types";
  12412. /**
  12413. * Default Inputs manager for the FreeCamera.
  12414. * It groups all the default supported inputs for ease of use.
  12415. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12416. */
  12417. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12418. /**
  12419. * @hidden
  12420. */
  12421. _keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  12422. /**
  12423. * @hidden
  12424. */
  12425. _mouseInput: Nullable<FreeCameraMouseInput>;
  12426. /**
  12427. * Instantiates a new FreeCameraInputsManager.
  12428. * @param camera Defines the camera the inputs belong to
  12429. */
  12430. constructor(camera: FreeCamera);
  12431. /**
  12432. * Add keyboard input support to the input manager.
  12433. * @returns the current input manager
  12434. */
  12435. addKeyboard(): FreeCameraInputsManager;
  12436. /**
  12437. * Add mouse input support to the input manager.
  12438. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12439. * @returns the current input manager
  12440. */
  12441. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12442. /**
  12443. * Removes the mouse input support from the manager
  12444. * @returns the current input manager
  12445. */
  12446. removeMouse(): FreeCameraInputsManager;
  12447. /**
  12448. * Add touch input support to the input manager.
  12449. * @returns the current input manager
  12450. */
  12451. addTouch(): FreeCameraInputsManager;
  12452. }
  12453. }
  12454. declare module "babylonjs/Cameras/freeCamera" {
  12455. import { Vector3 } from "babylonjs/Maths/math";
  12456. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12457. import { Scene } from "babylonjs/scene";
  12458. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12459. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12460. /**
  12461. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12462. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12463. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12464. */
  12465. export class FreeCamera extends TargetCamera {
  12466. /**
  12467. * Define the collision ellipsoid of the camera.
  12468. * This is helpful to simulate a camera body like the player body around the camera
  12469. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12470. */
  12471. ellipsoid: Vector3;
  12472. /**
  12473. * Define an offset for the position of the ellipsoid around the camera.
  12474. * This can be helpful to determine the center of the body near the gravity center of the body
  12475. * instead of its head.
  12476. */
  12477. ellipsoidOffset: Vector3;
  12478. /**
  12479. * Enable or disable collisions of the camera with the rest of the scene objects.
  12480. */
  12481. checkCollisions: boolean;
  12482. /**
  12483. * Enable or disable gravity on the camera.
  12484. */
  12485. applyGravity: boolean;
  12486. /**
  12487. * Define the input manager associated to the camera.
  12488. */
  12489. inputs: FreeCameraInputsManager;
  12490. /**
  12491. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12492. * Higher values reduce sensitivity.
  12493. */
  12494. /**
  12495. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12496. * Higher values reduce sensitivity.
  12497. */
  12498. angularSensibility: number;
  12499. /**
  12500. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12501. */
  12502. keysUp: number[];
  12503. /**
  12504. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12505. */
  12506. keysDown: number[];
  12507. /**
  12508. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12509. */
  12510. keysLeft: number[];
  12511. /**
  12512. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12513. */
  12514. keysRight: number[];
  12515. /**
  12516. * Event raised when the camera collide with a mesh in the scene.
  12517. */
  12518. onCollide: (collidedMesh: AbstractMesh) => void;
  12519. private _collider;
  12520. private _needMoveForGravity;
  12521. private _oldPosition;
  12522. private _diffPosition;
  12523. private _newPosition;
  12524. /** @hidden */
  12525. _localDirection: Vector3;
  12526. /** @hidden */
  12527. _transformedDirection: Vector3;
  12528. /**
  12529. * Instantiates a Free Camera.
  12530. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12531. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12532. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12533. * @param name Define the name of the camera in the scene
  12534. * @param position Define the start position of the camera in the scene
  12535. * @param scene Define the scene the camera belongs to
  12536. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12537. */
  12538. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12539. /**
  12540. * Attached controls to the current camera.
  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 camera.
  12547. * The camera will stop reacting to inputs.
  12548. * @param element Defines the element to stop listening the inputs from
  12549. */
  12550. detachControl(element: HTMLElement): void;
  12551. private _collisionMask;
  12552. /**
  12553. * Define a collision mask to limit the list of object the camera can collide with
  12554. */
  12555. collisionMask: number;
  12556. /** @hidden */
  12557. _collideWithWorld(displacement: Vector3): void;
  12558. private _onCollisionPositionChange;
  12559. /** @hidden */
  12560. _checkInputs(): void;
  12561. /** @hidden */
  12562. _decideIfNeedsToMove(): boolean;
  12563. /** @hidden */
  12564. _updatePosition(): void;
  12565. /**
  12566. * Destroy the camera and release the current resources hold by it.
  12567. */
  12568. dispose(): void;
  12569. /**
  12570. * Gets the current object class name.
  12571. * @return the class name
  12572. */
  12573. getClassName(): string;
  12574. }
  12575. }
  12576. declare module "babylonjs/Gamepads/gamepad" {
  12577. import { Observable } from "babylonjs/Misc/observable";
  12578. /**
  12579. * Represents a gamepad control stick position
  12580. */
  12581. export class StickValues {
  12582. /**
  12583. * The x component of the control stick
  12584. */
  12585. x: number;
  12586. /**
  12587. * The y component of the control stick
  12588. */
  12589. y: number;
  12590. /**
  12591. * Initializes the gamepad x and y control stick values
  12592. * @param x The x component of the gamepad control stick value
  12593. * @param y The y component of the gamepad control stick value
  12594. */
  12595. constructor(
  12596. /**
  12597. * The x component of the control stick
  12598. */
  12599. x: number,
  12600. /**
  12601. * The y component of the control stick
  12602. */
  12603. y: number);
  12604. }
  12605. /**
  12606. * An interface which manages callbacks for gamepad button changes
  12607. */
  12608. export interface GamepadButtonChanges {
  12609. /**
  12610. * Called when a gamepad has been changed
  12611. */
  12612. changed: boolean;
  12613. /**
  12614. * Called when a gamepad press event has been triggered
  12615. */
  12616. pressChanged: boolean;
  12617. /**
  12618. * Called when a touch event has been triggered
  12619. */
  12620. touchChanged: boolean;
  12621. /**
  12622. * Called when a value has changed
  12623. */
  12624. valueChanged: boolean;
  12625. }
  12626. /**
  12627. * Represents a gamepad
  12628. */
  12629. export class Gamepad {
  12630. /**
  12631. * The id of the gamepad
  12632. */
  12633. id: string;
  12634. /**
  12635. * The index of the gamepad
  12636. */
  12637. index: number;
  12638. /**
  12639. * The browser gamepad
  12640. */
  12641. browserGamepad: any;
  12642. /**
  12643. * Specifies what type of gamepad this represents
  12644. */
  12645. type: number;
  12646. private _leftStick;
  12647. private _rightStick;
  12648. /** @hidden */
  12649. _isConnected: boolean;
  12650. private _leftStickAxisX;
  12651. private _leftStickAxisY;
  12652. private _rightStickAxisX;
  12653. private _rightStickAxisY;
  12654. /**
  12655. * Triggered when the left control stick has been changed
  12656. */
  12657. private _onleftstickchanged;
  12658. /**
  12659. * Triggered when the right control stick has been changed
  12660. */
  12661. private _onrightstickchanged;
  12662. /**
  12663. * Represents a gamepad controller
  12664. */
  12665. static GAMEPAD: number;
  12666. /**
  12667. * Represents a generic controller
  12668. */
  12669. static GENERIC: number;
  12670. /**
  12671. * Represents an XBox controller
  12672. */
  12673. static XBOX: number;
  12674. /**
  12675. * Represents a pose-enabled controller
  12676. */
  12677. static POSE_ENABLED: number;
  12678. /**
  12679. * Specifies whether the left control stick should be Y-inverted
  12680. */
  12681. protected _invertLeftStickY: boolean;
  12682. /**
  12683. * Specifies if the gamepad has been connected
  12684. */
  12685. readonly isConnected: boolean;
  12686. /**
  12687. * Initializes the gamepad
  12688. * @param id The id of the gamepad
  12689. * @param index The index of the gamepad
  12690. * @param browserGamepad The browser gamepad
  12691. * @param leftStickX The x component of the left joystick
  12692. * @param leftStickY The y component of the left joystick
  12693. * @param rightStickX The x component of the right joystick
  12694. * @param rightStickY The y component of the right joystick
  12695. */
  12696. constructor(
  12697. /**
  12698. * The id of the gamepad
  12699. */
  12700. id: string,
  12701. /**
  12702. * The index of the gamepad
  12703. */
  12704. index: number,
  12705. /**
  12706. * The browser gamepad
  12707. */
  12708. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12709. /**
  12710. * Callback triggered when the left joystick has changed
  12711. * @param callback
  12712. */
  12713. onleftstickchanged(callback: (values: StickValues) => void): void;
  12714. /**
  12715. * Callback triggered when the right joystick has changed
  12716. * @param callback
  12717. */
  12718. onrightstickchanged(callback: (values: StickValues) => void): void;
  12719. /**
  12720. * Gets the left joystick
  12721. */
  12722. /**
  12723. * Sets the left joystick values
  12724. */
  12725. leftStick: StickValues;
  12726. /**
  12727. * Gets the right joystick
  12728. */
  12729. /**
  12730. * Sets the right joystick value
  12731. */
  12732. rightStick: StickValues;
  12733. /**
  12734. * Updates the gamepad joystick positions
  12735. */
  12736. update(): void;
  12737. /**
  12738. * Disposes the gamepad
  12739. */
  12740. dispose(): void;
  12741. }
  12742. /**
  12743. * Represents a generic gamepad
  12744. */
  12745. export class GenericPad extends Gamepad {
  12746. private _buttons;
  12747. private _onbuttondown;
  12748. private _onbuttonup;
  12749. /**
  12750. * Observable triggered when a button has been pressed
  12751. */
  12752. onButtonDownObservable: Observable<number>;
  12753. /**
  12754. * Observable triggered when a button has been released
  12755. */
  12756. onButtonUpObservable: Observable<number>;
  12757. /**
  12758. * Callback triggered when a button has been pressed
  12759. * @param callback Called when a button has been pressed
  12760. */
  12761. onbuttondown(callback: (buttonPressed: number) => void): void;
  12762. /**
  12763. * Callback triggered when a button has been released
  12764. * @param callback Called when a button has been released
  12765. */
  12766. onbuttonup(callback: (buttonReleased: number) => void): void;
  12767. /**
  12768. * Initializes the generic gamepad
  12769. * @param id The id of the generic gamepad
  12770. * @param index The index of the generic gamepad
  12771. * @param browserGamepad The browser gamepad
  12772. */
  12773. constructor(id: string, index: number, browserGamepad: any);
  12774. private _setButtonValue;
  12775. /**
  12776. * Updates the generic gamepad
  12777. */
  12778. update(): void;
  12779. /**
  12780. * Disposes the generic gamepad
  12781. */
  12782. dispose(): void;
  12783. }
  12784. }
  12785. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  12786. import { Observable } from "babylonjs/Misc/observable";
  12787. import { Nullable } from "babylonjs/types";
  12788. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12789. import { TransformNode } from "babylonjs/Meshes/transformNode";
  12790. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12791. import { Ray } from "babylonjs/Culling/ray";
  12792. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  12793. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  12794. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12795. /**
  12796. * Defines the types of pose enabled controllers that are supported
  12797. */
  12798. export enum PoseEnabledControllerType {
  12799. /**
  12800. * HTC Vive
  12801. */
  12802. VIVE = 0,
  12803. /**
  12804. * Oculus Rift
  12805. */
  12806. OCULUS = 1,
  12807. /**
  12808. * Windows mixed reality
  12809. */
  12810. WINDOWS = 2,
  12811. /**
  12812. * Samsung gear VR
  12813. */
  12814. GEAR_VR = 3,
  12815. /**
  12816. * Google Daydream
  12817. */
  12818. DAYDREAM = 4,
  12819. /**
  12820. * Generic
  12821. */
  12822. GENERIC = 5
  12823. }
  12824. /**
  12825. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12826. */
  12827. export interface MutableGamepadButton {
  12828. /**
  12829. * Value of the button/trigger
  12830. */
  12831. value: number;
  12832. /**
  12833. * If the button/trigger is currently touched
  12834. */
  12835. touched: boolean;
  12836. /**
  12837. * If the button/trigger is currently pressed
  12838. */
  12839. pressed: boolean;
  12840. }
  12841. /**
  12842. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12843. * @hidden
  12844. */
  12845. export interface ExtendedGamepadButton extends GamepadButton {
  12846. /**
  12847. * If the button/trigger is currently pressed
  12848. */
  12849. readonly pressed: boolean;
  12850. /**
  12851. * If the button/trigger is currently touched
  12852. */
  12853. readonly touched: boolean;
  12854. /**
  12855. * Value of the button/trigger
  12856. */
  12857. readonly value: number;
  12858. }
  12859. /** @hidden */
  12860. export interface _GamePadFactory {
  12861. /**
  12862. * Returns wether or not the current gamepad can be created for this type of controller.
  12863. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12864. * @returns true if it can be created, otherwise false
  12865. */
  12866. canCreate(gamepadInfo: any): boolean;
  12867. /**
  12868. * Creates a new instance of the Gamepad.
  12869. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12870. * @returns the new gamepad instance
  12871. */
  12872. create(gamepadInfo: any): Gamepad;
  12873. }
  12874. /**
  12875. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12876. */
  12877. export class PoseEnabledControllerHelper {
  12878. /** @hidden */
  12879. static _ControllerFactories: _GamePadFactory[];
  12880. /** @hidden */
  12881. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12882. /**
  12883. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12884. * @param vrGamepad the gamepad to initialized
  12885. * @returns a vr controller of the type the gamepad identified as
  12886. */
  12887. static InitiateController(vrGamepad: any): Gamepad;
  12888. }
  12889. /**
  12890. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12891. */
  12892. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12893. private _deviceRoomPosition;
  12894. private _deviceRoomRotationQuaternion;
  12895. /**
  12896. * The device position in babylon space
  12897. */
  12898. devicePosition: Vector3;
  12899. /**
  12900. * The device rotation in babylon space
  12901. */
  12902. deviceRotationQuaternion: Quaternion;
  12903. /**
  12904. * The scale factor of the device in babylon space
  12905. */
  12906. deviceScaleFactor: number;
  12907. /**
  12908. * (Likely devicePosition should be used instead) The device position in its room space
  12909. */
  12910. position: Vector3;
  12911. /**
  12912. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12913. */
  12914. rotationQuaternion: Quaternion;
  12915. /**
  12916. * The type of controller (Eg. Windows mixed reality)
  12917. */
  12918. controllerType: PoseEnabledControllerType;
  12919. protected _calculatedPosition: Vector3;
  12920. private _calculatedRotation;
  12921. /**
  12922. * The raw pose from the device
  12923. */
  12924. rawPose: DevicePose;
  12925. private _trackPosition;
  12926. private _maxRotationDistFromHeadset;
  12927. private _draggedRoomRotation;
  12928. /**
  12929. * @hidden
  12930. */
  12931. _disableTrackPosition(fixedPosition: Vector3): void;
  12932. /**
  12933. * Internal, the mesh attached to the controller
  12934. * @hidden
  12935. */
  12936. _mesh: Nullable<AbstractMesh>;
  12937. private _poseControlledCamera;
  12938. private _leftHandSystemQuaternion;
  12939. /**
  12940. * Internal, matrix used to convert room space to babylon space
  12941. * @hidden
  12942. */
  12943. _deviceToWorld: Matrix;
  12944. /**
  12945. * Node to be used when casting a ray from the controller
  12946. * @hidden
  12947. */
  12948. _pointingPoseNode: Nullable<TransformNode>;
  12949. /**
  12950. * Name of the child mesh that can be used to cast a ray from the controller
  12951. */
  12952. static readonly POINTING_POSE: string;
  12953. /**
  12954. * Creates a new PoseEnabledController from a gamepad
  12955. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12956. */
  12957. constructor(browserGamepad: any);
  12958. private _workingMatrix;
  12959. /**
  12960. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12961. */
  12962. update(): void;
  12963. /**
  12964. * Updates only the pose device and mesh without doing any button event checking
  12965. */
  12966. protected _updatePoseAndMesh(): void;
  12967. /**
  12968. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12969. * @param poseData raw pose fromthe device
  12970. */
  12971. updateFromDevice(poseData: DevicePose): void;
  12972. /**
  12973. * @hidden
  12974. */
  12975. _meshAttachedObservable: Observable<AbstractMesh>;
  12976. /**
  12977. * Attaches a mesh to the controller
  12978. * @param mesh the mesh to be attached
  12979. */
  12980. attachToMesh(mesh: AbstractMesh): void;
  12981. /**
  12982. * Attaches the controllers mesh to a camera
  12983. * @param camera the camera the mesh should be attached to
  12984. */
  12985. attachToPoseControlledCamera(camera: TargetCamera): void;
  12986. /**
  12987. * Disposes of the controller
  12988. */
  12989. dispose(): void;
  12990. /**
  12991. * The mesh that is attached to the controller
  12992. */
  12993. readonly mesh: Nullable<AbstractMesh>;
  12994. /**
  12995. * Gets the ray of the controller in the direction the controller is pointing
  12996. * @param length the length the resulting ray should be
  12997. * @returns a ray in the direction the controller is pointing
  12998. */
  12999. getForwardRay(length?: number): Ray;
  13000. }
  13001. }
  13002. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  13003. import { Observable } from "babylonjs/Misc/observable";
  13004. import { Scene } from "babylonjs/scene";
  13005. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13006. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  13007. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  13008. /**
  13009. * Defines the WebVRController object that represents controllers tracked in 3D space
  13010. */
  13011. export abstract class WebVRController extends PoseEnabledController {
  13012. /**
  13013. * Internal, the default controller model for the controller
  13014. */
  13015. protected _defaultModel: AbstractMesh;
  13016. /**
  13017. * Fired when the trigger state has changed
  13018. */
  13019. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  13020. /**
  13021. * Fired when the main button state has changed
  13022. */
  13023. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13024. /**
  13025. * Fired when the secondary button state has changed
  13026. */
  13027. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13028. /**
  13029. * Fired when the pad state has changed
  13030. */
  13031. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  13032. /**
  13033. * Fired when controllers stick values have changed
  13034. */
  13035. onPadValuesChangedObservable: Observable<StickValues>;
  13036. /**
  13037. * Array of button availible on the controller
  13038. */
  13039. protected _buttons: Array<MutableGamepadButton>;
  13040. private _onButtonStateChange;
  13041. /**
  13042. * Fired when a controller button's state has changed
  13043. * @param callback the callback containing the button that was modified
  13044. */
  13045. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  13046. /**
  13047. * X and Y axis corrisponding to the controllers joystick
  13048. */
  13049. pad: StickValues;
  13050. /**
  13051. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  13052. */
  13053. hand: string;
  13054. /**
  13055. * The default controller model for the controller
  13056. */
  13057. readonly defaultModel: AbstractMesh;
  13058. /**
  13059. * Creates a new WebVRController from a gamepad
  13060. * @param vrGamepad the gamepad that the WebVRController should be created from
  13061. */
  13062. constructor(vrGamepad: any);
  13063. /**
  13064. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  13065. */
  13066. update(): void;
  13067. /**
  13068. * Function to be called when a button is modified
  13069. */
  13070. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  13071. /**
  13072. * Loads a mesh and attaches it to the controller
  13073. * @param scene the scene the mesh should be added to
  13074. * @param meshLoaded callback for when the mesh has been loaded
  13075. */
  13076. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  13077. private _setButtonValue;
  13078. private _changes;
  13079. private _checkChanges;
  13080. /**
  13081. * Disposes of th webVRCOntroller
  13082. */
  13083. dispose(): void;
  13084. }
  13085. }
  13086. declare module "babylonjs/Lights/hemisphericLight" {
  13087. import { Nullable } from "babylonjs/types";
  13088. import { Scene } from "babylonjs/scene";
  13089. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  13090. import { Effect } from "babylonjs/Materials/effect";
  13091. import { Light } from "babylonjs/Lights/light";
  13092. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  13093. /**
  13094. * The HemisphericLight simulates the ambient environment light,
  13095. * so the passed direction is the light reflection direction, not the incoming direction.
  13096. */
  13097. export class HemisphericLight extends Light {
  13098. /**
  13099. * The groundColor is the light in the opposite direction to the one specified during creation.
  13100. * 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.
  13101. */
  13102. groundColor: Color3;
  13103. /**
  13104. * The light reflection direction, not the incoming direction.
  13105. */
  13106. direction: Vector3;
  13107. /**
  13108. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  13109. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  13110. * The HemisphericLight can't cast shadows.
  13111. * Documentation : https://doc.babylonjs.com/babylon101/lights
  13112. * @param name The friendly name of the light
  13113. * @param direction The direction of the light reflection
  13114. * @param scene The scene the light belongs to
  13115. */
  13116. constructor(name: string, direction: Vector3, scene: Scene);
  13117. protected _buildUniformLayout(): void;
  13118. /**
  13119. * Returns the string "HemisphericLight".
  13120. * @return The class name
  13121. */
  13122. getClassName(): string;
  13123. /**
  13124. * Sets the HemisphericLight direction towards the passed target (Vector3).
  13125. * Returns the updated direction.
  13126. * @param target The target the direction should point to
  13127. * @return The computed direction
  13128. */
  13129. setDirectionToTarget(target: Vector3): Vector3;
  13130. /**
  13131. * Returns the shadow generator associated to the light.
  13132. * @returns Always null for hemispheric lights because it does not support shadows.
  13133. */
  13134. getShadowGenerator(): Nullable<IShadowGenerator>;
  13135. /**
  13136. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13137. * @param effect The effect to update
  13138. * @param lightIndex The index of the light in the effect to update
  13139. * @returns The hemispheric light
  13140. */
  13141. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13142. /**
  13143. * Computes the world matrix of the node
  13144. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13145. * @param useWasUpdatedFlag defines a reserved property
  13146. * @returns the world matrix
  13147. */
  13148. computeWorldMatrix(): Matrix;
  13149. /**
  13150. * Returns the integer 3.
  13151. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13152. */
  13153. getTypeID(): number;
  13154. /**
  13155. * Prepares the list of defines specific to the light type.
  13156. * @param defines the list of defines
  13157. * @param lightIndex defines the index of the light for the effect
  13158. */
  13159. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  13160. }
  13161. }
  13162. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  13163. /** @hidden */
  13164. export var vrMultiviewToSingleviewPixelShader: {
  13165. name: string;
  13166. shader: string;
  13167. };
  13168. }
  13169. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  13170. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13171. import { Scene } from "babylonjs/scene";
  13172. /**
  13173. * Renders to multiple views with a single draw call
  13174. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  13175. */
  13176. export class MultiviewRenderTarget extends RenderTargetTexture {
  13177. /**
  13178. * Creates a multiview render target
  13179. * @param scene scene used with the render target
  13180. * @param size the size of the render target (used for each view)
  13181. */
  13182. constructor(scene: Scene, size?: number | {
  13183. width: number;
  13184. height: number;
  13185. } | {
  13186. ratio: number;
  13187. });
  13188. /**
  13189. * @hidden
  13190. * @param faceIndex the face index, if its a cube texture
  13191. */
  13192. _bindFrameBuffer(faceIndex?: number): void;
  13193. /**
  13194. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  13195. * @returns the view count
  13196. */
  13197. getViewCount(): number;
  13198. }
  13199. }
  13200. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  13201. import { Camera } from "babylonjs/Cameras/camera";
  13202. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13203. import { Nullable } from "babylonjs/types";
  13204. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13205. import { Matrix } from "babylonjs/Maths/math";
  13206. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  13207. module "babylonjs/Engines/engine" {
  13208. interface Engine {
  13209. /**
  13210. * Creates a new multiview render target
  13211. * @param width defines the width of the texture
  13212. * @param height defines the height of the texture
  13213. * @returns the created multiview texture
  13214. */
  13215. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  13216. /**
  13217. * Binds a multiview framebuffer to be drawn to
  13218. * @param multiviewTexture texture to bind
  13219. */
  13220. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  13221. }
  13222. }
  13223. module "babylonjs/Cameras/camera" {
  13224. interface Camera {
  13225. /**
  13226. * @hidden
  13227. * 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)
  13228. */
  13229. _useMultiviewToSingleView: boolean;
  13230. /**
  13231. * @hidden
  13232. * 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)
  13233. */
  13234. _multiviewTexture: Nullable<RenderTargetTexture>;
  13235. /**
  13236. * @hidden
  13237. * ensures the multiview texture of the camera exists and has the specified width/height
  13238. * @param width height to set on the multiview texture
  13239. * @param height width to set on the multiview texture
  13240. */
  13241. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  13242. }
  13243. }
  13244. module "babylonjs/scene" {
  13245. interface Scene {
  13246. /** @hidden */
  13247. _transformMatrixR: Matrix;
  13248. /** @hidden */
  13249. _multiviewSceneUbo: Nullable<UniformBuffer>;
  13250. /** @hidden */
  13251. _createMultiviewUbo(): void;
  13252. /** @hidden */
  13253. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  13254. /** @hidden */
  13255. _renderMultiviewToSingleView(camera: Camera): void;
  13256. }
  13257. }
  13258. }
  13259. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  13260. import { Camera } from "babylonjs/Cameras/camera";
  13261. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13262. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  13263. import "babylonjs/Engines/Extensions/engine.multiview";
  13264. /**
  13265. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  13266. * This will not be used for webXR as it supports displaying texture arrays directly
  13267. */
  13268. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  13269. /**
  13270. * Initializes a VRMultiviewToSingleview
  13271. * @param name name of the post process
  13272. * @param camera camera to be applied to
  13273. * @param scaleFactor scaling factor to the size of the output texture
  13274. */
  13275. constructor(name: string, camera: Camera, scaleFactor: number);
  13276. }
  13277. }
  13278. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  13279. declare module "babylonjs/Cameras/VR/webVRCamera" {
  13280. import { Nullable } from "babylonjs/types";
  13281. import { Observable } from "babylonjs/Misc/observable";
  13282. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  13283. import { Scene } from "babylonjs/scene";
  13284. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  13285. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  13286. import { Node } from "babylonjs/node";
  13287. import { Ray } from "babylonjs/Culling/ray";
  13288. import "babylonjs/Cameras/RigModes/webVRRigMode";
  13289. /**
  13290. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13291. * IMPORTANT!! The data is right-hand data.
  13292. * @export
  13293. * @interface DevicePose
  13294. */
  13295. export interface DevicePose {
  13296. /**
  13297. * The position of the device, values in array are [x,y,z].
  13298. */
  13299. readonly position: Nullable<Float32Array>;
  13300. /**
  13301. * The linearVelocity of the device, values in array are [x,y,z].
  13302. */
  13303. readonly linearVelocity: Nullable<Float32Array>;
  13304. /**
  13305. * The linearAcceleration of the device, values in array are [x,y,z].
  13306. */
  13307. readonly linearAcceleration: Nullable<Float32Array>;
  13308. /**
  13309. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13310. */
  13311. readonly orientation: Nullable<Float32Array>;
  13312. /**
  13313. * The angularVelocity of the device, values in array are [x,y,z].
  13314. */
  13315. readonly angularVelocity: Nullable<Float32Array>;
  13316. /**
  13317. * The angularAcceleration of the device, values in array are [x,y,z].
  13318. */
  13319. readonly angularAcceleration: Nullable<Float32Array>;
  13320. }
  13321. /**
  13322. * Interface representing a pose controlled object in Babylon.
  13323. * A pose controlled object has both regular pose values as well as pose values
  13324. * from an external device such as a VR head mounted display
  13325. */
  13326. export interface PoseControlled {
  13327. /**
  13328. * The position of the object in babylon space.
  13329. */
  13330. position: Vector3;
  13331. /**
  13332. * The rotation quaternion of the object in babylon space.
  13333. */
  13334. rotationQuaternion: Quaternion;
  13335. /**
  13336. * The position of the device in babylon space.
  13337. */
  13338. devicePosition?: Vector3;
  13339. /**
  13340. * The rotation quaternion of the device in babylon space.
  13341. */
  13342. deviceRotationQuaternion: Quaternion;
  13343. /**
  13344. * The raw pose coming from the device.
  13345. */
  13346. rawPose: Nullable<DevicePose>;
  13347. /**
  13348. * The scale of the device to be used when translating from device space to babylon space.
  13349. */
  13350. deviceScaleFactor: number;
  13351. /**
  13352. * Updates the poseControlled values based on the input device pose.
  13353. * @param poseData the pose data to update the object with
  13354. */
  13355. updateFromDevice(poseData: DevicePose): void;
  13356. }
  13357. /**
  13358. * Set of options to customize the webVRCamera
  13359. */
  13360. export interface WebVROptions {
  13361. /**
  13362. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13363. */
  13364. trackPosition?: boolean;
  13365. /**
  13366. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13367. */
  13368. positionScale?: number;
  13369. /**
  13370. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13371. */
  13372. displayName?: string;
  13373. /**
  13374. * Should the native controller meshes be initialized. (default: true)
  13375. */
  13376. controllerMeshes?: boolean;
  13377. /**
  13378. * Creating a default HemiLight only on controllers. (default: true)
  13379. */
  13380. defaultLightingOnControllers?: boolean;
  13381. /**
  13382. * If you don't want to use the default VR button of the helper. (default: false)
  13383. */
  13384. useCustomVRButton?: boolean;
  13385. /**
  13386. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13387. */
  13388. customVRButton?: HTMLButtonElement;
  13389. /**
  13390. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13391. */
  13392. rayLength?: number;
  13393. /**
  13394. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13395. */
  13396. defaultHeight?: number;
  13397. /**
  13398. * If multiview should be used if availible (default: false)
  13399. */
  13400. useMultiview?: boolean;
  13401. }
  13402. /**
  13403. * This represents a WebVR camera.
  13404. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13405. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13406. */
  13407. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13408. private webVROptions;
  13409. /**
  13410. * @hidden
  13411. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13412. */
  13413. _vrDevice: any;
  13414. /**
  13415. * The rawPose of the vrDevice.
  13416. */
  13417. rawPose: Nullable<DevicePose>;
  13418. private _onVREnabled;
  13419. private _specsVersion;
  13420. private _attached;
  13421. private _frameData;
  13422. protected _descendants: Array<Node>;
  13423. private _deviceRoomPosition;
  13424. /** @hidden */
  13425. _deviceRoomRotationQuaternion: Quaternion;
  13426. private _standingMatrix;
  13427. /**
  13428. * Represents device position in babylon space.
  13429. */
  13430. devicePosition: Vector3;
  13431. /**
  13432. * Represents device rotation in babylon space.
  13433. */
  13434. deviceRotationQuaternion: Quaternion;
  13435. /**
  13436. * The scale of the device to be used when translating from device space to babylon space.
  13437. */
  13438. deviceScaleFactor: number;
  13439. private _deviceToWorld;
  13440. private _worldToDevice;
  13441. /**
  13442. * References to the webVR controllers for the vrDevice.
  13443. */
  13444. controllers: Array<WebVRController>;
  13445. /**
  13446. * Emits an event when a controller is attached.
  13447. */
  13448. onControllersAttachedObservable: Observable<WebVRController[]>;
  13449. /**
  13450. * Emits an event when a controller's mesh has been loaded;
  13451. */
  13452. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13453. /**
  13454. * Emits an event when the HMD's pose has been updated.
  13455. */
  13456. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13457. private _poseSet;
  13458. /**
  13459. * If the rig cameras be used as parent instead of this camera.
  13460. */
  13461. rigParenting: boolean;
  13462. private _lightOnControllers;
  13463. private _defaultHeight?;
  13464. /**
  13465. * Instantiates a WebVRFreeCamera.
  13466. * @param name The name of the WebVRFreeCamera
  13467. * @param position The starting anchor position for the camera
  13468. * @param scene The scene the camera belongs to
  13469. * @param webVROptions a set of customizable options for the webVRCamera
  13470. */
  13471. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13472. /**
  13473. * Gets the device distance from the ground in meters.
  13474. * @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.
  13475. */
  13476. deviceDistanceToRoomGround(): number;
  13477. /**
  13478. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13479. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13480. */
  13481. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13482. /**
  13483. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13484. * @returns A promise with a boolean set to if the standing matrix is supported.
  13485. */
  13486. useStandingMatrixAsync(): Promise<boolean>;
  13487. /**
  13488. * Disposes the camera
  13489. */
  13490. dispose(): void;
  13491. /**
  13492. * Gets a vrController by name.
  13493. * @param name The name of the controller to retreive
  13494. * @returns the controller matching the name specified or null if not found
  13495. */
  13496. getControllerByName(name: string): Nullable<WebVRController>;
  13497. private _leftController;
  13498. /**
  13499. * The controller corrisponding to the users left hand.
  13500. */
  13501. readonly leftController: Nullable<WebVRController>;
  13502. private _rightController;
  13503. /**
  13504. * The controller corrisponding to the users right hand.
  13505. */
  13506. readonly rightController: Nullable<WebVRController>;
  13507. /**
  13508. * Casts a ray forward from the vrCamera's gaze.
  13509. * @param length Length of the ray (default: 100)
  13510. * @returns the ray corrisponding to the gaze
  13511. */
  13512. getForwardRay(length?: number): Ray;
  13513. /**
  13514. * @hidden
  13515. * Updates the camera based on device's frame data
  13516. */
  13517. _checkInputs(): void;
  13518. /**
  13519. * Updates the poseControlled values based on the input device pose.
  13520. * @param poseData Pose coming from the device
  13521. */
  13522. updateFromDevice(poseData: DevicePose): void;
  13523. private _htmlElementAttached;
  13524. private _detachIfAttached;
  13525. /**
  13526. * WebVR's attach control will start broadcasting frames to the device.
  13527. * Note that in certain browsers (chrome for example) this function must be called
  13528. * within a user-interaction callback. Example:
  13529. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13530. *
  13531. * @param element html element to attach the vrDevice to
  13532. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13533. */
  13534. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13535. /**
  13536. * Detaches the camera from the html element and disables VR
  13537. *
  13538. * @param element html element to detach from
  13539. */
  13540. detachControl(element: HTMLElement): void;
  13541. /**
  13542. * @returns the name of this class
  13543. */
  13544. getClassName(): string;
  13545. /**
  13546. * Calls resetPose on the vrDisplay
  13547. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13548. */
  13549. resetToCurrentRotation(): void;
  13550. /**
  13551. * @hidden
  13552. * Updates the rig cameras (left and right eye)
  13553. */
  13554. _updateRigCameras(): void;
  13555. private _workingVector;
  13556. private _oneVector;
  13557. private _workingMatrix;
  13558. private updateCacheCalled;
  13559. private _correctPositionIfNotTrackPosition;
  13560. /**
  13561. * @hidden
  13562. * Updates the cached values of the camera
  13563. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13564. */
  13565. _updateCache(ignoreParentClass?: boolean): void;
  13566. /**
  13567. * @hidden
  13568. * Get current device position in babylon world
  13569. */
  13570. _computeDevicePosition(): void;
  13571. /**
  13572. * Updates the current device position and rotation in the babylon world
  13573. */
  13574. update(): void;
  13575. /**
  13576. * @hidden
  13577. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13578. * @returns an identity matrix
  13579. */
  13580. _getViewMatrix(): Matrix;
  13581. private _tmpMatrix;
  13582. /**
  13583. * This function is called by the two RIG cameras.
  13584. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13585. * @hidden
  13586. */
  13587. _getWebVRViewMatrix(): Matrix;
  13588. /** @hidden */
  13589. _getWebVRProjectionMatrix(): Matrix;
  13590. private _onGamepadConnectedObserver;
  13591. private _onGamepadDisconnectedObserver;
  13592. private _updateCacheWhenTrackingDisabledObserver;
  13593. /**
  13594. * Initializes the controllers and their meshes
  13595. */
  13596. initControllers(): void;
  13597. }
  13598. }
  13599. declare module "babylonjs/PostProcesses/postProcess" {
  13600. import { Nullable } from "babylonjs/types";
  13601. import { SmartArray } from "babylonjs/Misc/smartArray";
  13602. import { Observable } from "babylonjs/Misc/observable";
  13603. import { Color4, Vector2 } from "babylonjs/Maths/math";
  13604. import { Camera } from "babylonjs/Cameras/camera";
  13605. import { Effect } from "babylonjs/Materials/effect";
  13606. import "babylonjs/Shaders/postprocess.vertex";
  13607. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13608. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13609. import { Engine } from "babylonjs/Engines/engine";
  13610. /**
  13611. * Size options for a post process
  13612. */
  13613. export type PostProcessOptions = {
  13614. width: number;
  13615. height: number;
  13616. };
  13617. /**
  13618. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13619. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13620. */
  13621. export class PostProcess {
  13622. /** Name of the PostProcess. */
  13623. name: string;
  13624. /**
  13625. * Gets or sets the unique id of the post process
  13626. */
  13627. uniqueId: number;
  13628. /**
  13629. * Width of the texture to apply the post process on
  13630. */
  13631. width: number;
  13632. /**
  13633. * Height of the texture to apply the post process on
  13634. */
  13635. height: number;
  13636. /**
  13637. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13638. * @hidden
  13639. */
  13640. _outputTexture: Nullable<InternalTexture>;
  13641. /**
  13642. * Sampling mode used by the shader
  13643. * See https://doc.babylonjs.com/classes/3.1/texture
  13644. */
  13645. renderTargetSamplingMode: number;
  13646. /**
  13647. * Clear color to use when screen clearing
  13648. */
  13649. clearColor: Color4;
  13650. /**
  13651. * If the buffer needs to be cleared before applying the post process. (default: true)
  13652. * Should be set to false if shader will overwrite all previous pixels.
  13653. */
  13654. autoClear: boolean;
  13655. /**
  13656. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13657. */
  13658. alphaMode: number;
  13659. /**
  13660. * Sets the setAlphaBlendConstants of the babylon engine
  13661. */
  13662. alphaConstants: Color4;
  13663. /**
  13664. * Animations to be used for the post processing
  13665. */
  13666. animations: import("babylonjs/Animations/animation").Animation[];
  13667. /**
  13668. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13669. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13670. */
  13671. enablePixelPerfectMode: boolean;
  13672. /**
  13673. * Force the postprocess to be applied without taking in account viewport
  13674. */
  13675. forceFullscreenViewport: boolean;
  13676. /**
  13677. * List of inspectable custom properties (used by the Inspector)
  13678. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13679. */
  13680. inspectableCustomProperties: IInspectable[];
  13681. /**
  13682. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13683. *
  13684. * | Value | Type | Description |
  13685. * | ----- | ----------------------------------- | ----------- |
  13686. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13687. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13688. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13689. *
  13690. */
  13691. scaleMode: number;
  13692. /**
  13693. * Force textures to be a power of two (default: false)
  13694. */
  13695. alwaysForcePOT: boolean;
  13696. private _samples;
  13697. /**
  13698. * Number of sample textures (default: 1)
  13699. */
  13700. samples: number;
  13701. /**
  13702. * Modify the scale of the post process to be the same as the viewport (default: false)
  13703. */
  13704. adaptScaleToCurrentViewport: boolean;
  13705. private _camera;
  13706. private _scene;
  13707. private _engine;
  13708. private _options;
  13709. private _reusable;
  13710. private _textureType;
  13711. /**
  13712. * Smart array of input and output textures for the post process.
  13713. * @hidden
  13714. */
  13715. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  13716. /**
  13717. * The index in _textures that corresponds to the output texture.
  13718. * @hidden
  13719. */
  13720. _currentRenderTextureInd: number;
  13721. private _effect;
  13722. private _samplers;
  13723. private _fragmentUrl;
  13724. private _vertexUrl;
  13725. private _parameters;
  13726. private _scaleRatio;
  13727. protected _indexParameters: any;
  13728. private _shareOutputWithPostProcess;
  13729. private _texelSize;
  13730. private _forcedOutputTexture;
  13731. /**
  13732. * Returns the fragment url or shader name used in the post process.
  13733. * @returns the fragment url or name in the shader store.
  13734. */
  13735. getEffectName(): string;
  13736. /**
  13737. * An event triggered when the postprocess is activated.
  13738. */
  13739. onActivateObservable: Observable<Camera>;
  13740. private _onActivateObserver;
  13741. /**
  13742. * A function that is added to the onActivateObservable
  13743. */
  13744. onActivate: Nullable<(camera: Camera) => void>;
  13745. /**
  13746. * An event triggered when the postprocess changes its size.
  13747. */
  13748. onSizeChangedObservable: Observable<PostProcess>;
  13749. private _onSizeChangedObserver;
  13750. /**
  13751. * A function that is added to the onSizeChangedObservable
  13752. */
  13753. onSizeChanged: (postProcess: PostProcess) => void;
  13754. /**
  13755. * An event triggered when the postprocess applies its effect.
  13756. */
  13757. onApplyObservable: Observable<Effect>;
  13758. private _onApplyObserver;
  13759. /**
  13760. * A function that is added to the onApplyObservable
  13761. */
  13762. onApply: (effect: Effect) => void;
  13763. /**
  13764. * An event triggered before rendering the postprocess
  13765. */
  13766. onBeforeRenderObservable: Observable<Effect>;
  13767. private _onBeforeRenderObserver;
  13768. /**
  13769. * A function that is added to the onBeforeRenderObservable
  13770. */
  13771. onBeforeRender: (effect: Effect) => void;
  13772. /**
  13773. * An event triggered after rendering the postprocess
  13774. */
  13775. onAfterRenderObservable: Observable<Effect>;
  13776. private _onAfterRenderObserver;
  13777. /**
  13778. * A function that is added to the onAfterRenderObservable
  13779. */
  13780. onAfterRender: (efect: Effect) => void;
  13781. /**
  13782. * 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
  13783. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13784. */
  13785. inputTexture: InternalTexture;
  13786. /**
  13787. * Gets the camera which post process is applied to.
  13788. * @returns The camera the post process is applied to.
  13789. */
  13790. getCamera(): Camera;
  13791. /**
  13792. * Gets the texel size of the postprocess.
  13793. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13794. */
  13795. readonly texelSize: Vector2;
  13796. /**
  13797. * Creates a new instance PostProcess
  13798. * @param name The name of the PostProcess.
  13799. * @param fragmentUrl The url of the fragment shader to be used.
  13800. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13801. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13802. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13803. * @param camera The camera to apply the render pass to.
  13804. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13805. * @param engine The engine which the post process will be applied. (default: current engine)
  13806. * @param reusable If the post process can be reused on the same frame. (default: false)
  13807. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13808. * @param textureType Type of textures used when performing the post process. (default: 0)
  13809. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13810. * @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
  13811. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13812. */
  13813. constructor(
  13814. /** Name of the PostProcess. */
  13815. 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);
  13816. /**
  13817. * Gets a string idenfifying the name of the class
  13818. * @returns "PostProcess" string
  13819. */
  13820. getClassName(): string;
  13821. /**
  13822. * Gets the engine which this post process belongs to.
  13823. * @returns The engine the post process was enabled with.
  13824. */
  13825. getEngine(): Engine;
  13826. /**
  13827. * The effect that is created when initializing the post process.
  13828. * @returns The created effect corrisponding the the postprocess.
  13829. */
  13830. getEffect(): Effect;
  13831. /**
  13832. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13833. * @param postProcess The post process to share the output with.
  13834. * @returns This post process.
  13835. */
  13836. shareOutputWith(postProcess: PostProcess): PostProcess;
  13837. /**
  13838. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13839. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13840. */
  13841. useOwnOutput(): void;
  13842. /**
  13843. * Updates the effect with the current post process compile time values and recompiles the shader.
  13844. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13845. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13846. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13847. * @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
  13848. * @param onCompiled Called when the shader has been compiled.
  13849. * @param onError Called if there is an error when compiling a shader.
  13850. */
  13851. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13852. /**
  13853. * The post process is reusable if it can be used multiple times within one frame.
  13854. * @returns If the post process is reusable
  13855. */
  13856. isReusable(): boolean;
  13857. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13858. markTextureDirty(): void;
  13859. /**
  13860. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13861. * 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.
  13862. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13863. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13864. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13865. * @returns The target texture that was bound to be written to.
  13866. */
  13867. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13868. /**
  13869. * If the post process is supported.
  13870. */
  13871. readonly isSupported: boolean;
  13872. /**
  13873. * The aspect ratio of the output texture.
  13874. */
  13875. readonly aspectRatio: number;
  13876. /**
  13877. * Get a value indicating if the post-process is ready to be used
  13878. * @returns true if the post-process is ready (shader is compiled)
  13879. */
  13880. isReady(): boolean;
  13881. /**
  13882. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13883. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13884. */
  13885. apply(): Nullable<Effect>;
  13886. private _disposeTextures;
  13887. /**
  13888. * Disposes the post process.
  13889. * @param camera The camera to dispose the post process on.
  13890. */
  13891. dispose(camera?: Camera): void;
  13892. }
  13893. }
  13894. declare module "babylonjs/PostProcesses/postProcessManager" {
  13895. import { Nullable } from "babylonjs/types";
  13896. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13897. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13898. import { Scene } from "babylonjs/scene";
  13899. /**
  13900. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13901. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13902. */
  13903. export class PostProcessManager {
  13904. private _scene;
  13905. private _indexBuffer;
  13906. private _vertexBuffers;
  13907. /**
  13908. * Creates a new instance PostProcess
  13909. * @param scene The scene that the post process is associated with.
  13910. */
  13911. constructor(scene: Scene);
  13912. private _prepareBuffers;
  13913. private _buildIndexBuffer;
  13914. /**
  13915. * Rebuilds the vertex buffers of the manager.
  13916. * @hidden
  13917. */
  13918. _rebuild(): void;
  13919. /**
  13920. * Prepares a frame to be run through a post process.
  13921. * @param sourceTexture The input texture to the post procesess. (default: null)
  13922. * @param postProcesses An array of post processes to be run. (default: null)
  13923. * @returns True if the post processes were able to be run.
  13924. * @hidden
  13925. */
  13926. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13927. /**
  13928. * Manually render a set of post processes to a texture.
  13929. * @param postProcesses An array of post processes to be run.
  13930. * @param targetTexture The target texture to render to.
  13931. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13932. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13933. * @param lodLevel defines which lod of the texture to render to
  13934. */
  13935. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13936. /**
  13937. * Finalize the result of the output of the postprocesses.
  13938. * @param doNotPresent If true the result will not be displayed to the screen.
  13939. * @param targetTexture The target texture to render to.
  13940. * @param faceIndex The index of the face to bind the target texture to.
  13941. * @param postProcesses The array of post processes to render.
  13942. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13943. * @hidden
  13944. */
  13945. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13946. /**
  13947. * Disposes of the post process manager.
  13948. */
  13949. dispose(): void;
  13950. }
  13951. }
  13952. declare module "babylonjs/Layers/layerSceneComponent" {
  13953. import { Scene } from "babylonjs/scene";
  13954. import { ISceneComponent } from "babylonjs/sceneComponent";
  13955. import { Layer } from "babylonjs/Layers/layer";
  13956. module "babylonjs/abstractScene" {
  13957. interface AbstractScene {
  13958. /**
  13959. * The list of layers (background and foreground) of the scene
  13960. */
  13961. layers: Array<Layer>;
  13962. }
  13963. }
  13964. /**
  13965. * Defines the layer scene component responsible to manage any layers
  13966. * in a given scene.
  13967. */
  13968. export class LayerSceneComponent implements ISceneComponent {
  13969. /**
  13970. * The component name helpfull to identify the component in the list of scene components.
  13971. */
  13972. readonly name: string;
  13973. /**
  13974. * The scene the component belongs to.
  13975. */
  13976. scene: Scene;
  13977. private _engine;
  13978. /**
  13979. * Creates a new instance of the component for the given scene
  13980. * @param scene Defines the scene to register the component in
  13981. */
  13982. constructor(scene: Scene);
  13983. /**
  13984. * Registers the component in a given scene
  13985. */
  13986. register(): void;
  13987. /**
  13988. * Rebuilds the elements related to this component in case of
  13989. * context lost for instance.
  13990. */
  13991. rebuild(): void;
  13992. /**
  13993. * Disposes the component and the associated ressources.
  13994. */
  13995. dispose(): void;
  13996. private _draw;
  13997. private _drawCameraPredicate;
  13998. private _drawCameraBackground;
  13999. private _drawCameraForeground;
  14000. private _drawRenderTargetPredicate;
  14001. private _drawRenderTargetBackground;
  14002. private _drawRenderTargetForeground;
  14003. }
  14004. }
  14005. declare module "babylonjs/Shaders/layer.fragment" {
  14006. /** @hidden */
  14007. export var layerPixelShader: {
  14008. name: string;
  14009. shader: string;
  14010. };
  14011. }
  14012. declare module "babylonjs/Shaders/layer.vertex" {
  14013. /** @hidden */
  14014. export var layerVertexShader: {
  14015. name: string;
  14016. shader: string;
  14017. };
  14018. }
  14019. declare module "babylonjs/Layers/layer" {
  14020. import { Observable } from "babylonjs/Misc/observable";
  14021. import { Nullable } from "babylonjs/types";
  14022. import { Scene } from "babylonjs/scene";
  14023. import { Vector2, Color4 } from "babylonjs/Maths/math";
  14024. import { Texture } from "babylonjs/Materials/Textures/texture";
  14025. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14026. import "babylonjs/Shaders/layer.fragment";
  14027. import "babylonjs/Shaders/layer.vertex";
  14028. /**
  14029. * This represents a full screen 2d layer.
  14030. * This can be useful to display a picture in the background of your scene for instance.
  14031. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14032. */
  14033. export class Layer {
  14034. /**
  14035. * Define the name of the layer.
  14036. */
  14037. name: string;
  14038. /**
  14039. * Define the texture the layer should display.
  14040. */
  14041. texture: Nullable<Texture>;
  14042. /**
  14043. * Is the layer in background or foreground.
  14044. */
  14045. isBackground: boolean;
  14046. /**
  14047. * Define the color of the layer (instead of texture).
  14048. */
  14049. color: Color4;
  14050. /**
  14051. * Define the scale of the layer in order to zoom in out of the texture.
  14052. */
  14053. scale: Vector2;
  14054. /**
  14055. * Define an offset for the layer in order to shift the texture.
  14056. */
  14057. offset: Vector2;
  14058. /**
  14059. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  14060. */
  14061. alphaBlendingMode: number;
  14062. /**
  14063. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  14064. * Alpha test will not mix with the background color in case of transparency.
  14065. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  14066. */
  14067. alphaTest: boolean;
  14068. /**
  14069. * Define a mask to restrict the layer to only some of the scene cameras.
  14070. */
  14071. layerMask: number;
  14072. /**
  14073. * Define the list of render target the layer is visible into.
  14074. */
  14075. renderTargetTextures: RenderTargetTexture[];
  14076. /**
  14077. * Define if the layer is only used in renderTarget or if it also
  14078. * renders in the main frame buffer of the canvas.
  14079. */
  14080. renderOnlyInRenderTargetTextures: boolean;
  14081. private _scene;
  14082. private _vertexBuffers;
  14083. private _indexBuffer;
  14084. private _effect;
  14085. private _alphaTestEffect;
  14086. /**
  14087. * An event triggered when the layer is disposed.
  14088. */
  14089. onDisposeObservable: Observable<Layer>;
  14090. private _onDisposeObserver;
  14091. /**
  14092. * Back compatibility with callback before the onDisposeObservable existed.
  14093. * The set callback will be triggered when the layer has been disposed.
  14094. */
  14095. onDispose: () => void;
  14096. /**
  14097. * An event triggered before rendering the scene
  14098. */
  14099. onBeforeRenderObservable: Observable<Layer>;
  14100. private _onBeforeRenderObserver;
  14101. /**
  14102. * Back compatibility with callback before the onBeforeRenderObservable existed.
  14103. * The set callback will be triggered just before rendering the layer.
  14104. */
  14105. onBeforeRender: () => void;
  14106. /**
  14107. * An event triggered after rendering the scene
  14108. */
  14109. onAfterRenderObservable: Observable<Layer>;
  14110. private _onAfterRenderObserver;
  14111. /**
  14112. * Back compatibility with callback before the onAfterRenderObservable existed.
  14113. * The set callback will be triggered just after rendering the layer.
  14114. */
  14115. onAfterRender: () => void;
  14116. /**
  14117. * Instantiates a new layer.
  14118. * This represents a full screen 2d layer.
  14119. * This can be useful to display a picture in the background of your scene for instance.
  14120. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14121. * @param name Define the name of the layer in the scene
  14122. * @param imgUrl Define the url of the texture to display in the layer
  14123. * @param scene Define the scene the layer belongs to
  14124. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  14125. * @param color Defines a color for the layer
  14126. */
  14127. constructor(
  14128. /**
  14129. * Define the name of the layer.
  14130. */
  14131. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  14132. private _createIndexBuffer;
  14133. /** @hidden */
  14134. _rebuild(): void;
  14135. /**
  14136. * Renders the layer in the scene.
  14137. */
  14138. render(): void;
  14139. /**
  14140. * Disposes and releases the associated ressources.
  14141. */
  14142. dispose(): void;
  14143. }
  14144. }
  14145. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  14146. import { Scene } from "babylonjs/scene";
  14147. import { ISceneComponent } from "babylonjs/sceneComponent";
  14148. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14149. module "babylonjs/abstractScene" {
  14150. interface AbstractScene {
  14151. /**
  14152. * The list of procedural textures added to the scene
  14153. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14154. */
  14155. proceduralTextures: Array<ProceduralTexture>;
  14156. }
  14157. }
  14158. /**
  14159. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14160. * in a given scene.
  14161. */
  14162. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14163. /**
  14164. * The component name helpfull to identify the component in the list of scene components.
  14165. */
  14166. readonly name: string;
  14167. /**
  14168. * The scene the component belongs to.
  14169. */
  14170. scene: Scene;
  14171. /**
  14172. * Creates a new instance of the component for the given scene
  14173. * @param scene Defines the scene to register the component in
  14174. */
  14175. constructor(scene: Scene);
  14176. /**
  14177. * Registers the component in a given scene
  14178. */
  14179. register(): void;
  14180. /**
  14181. * Rebuilds the elements related to this component in case of
  14182. * context lost for instance.
  14183. */
  14184. rebuild(): void;
  14185. /**
  14186. * Disposes the component and the associated ressources.
  14187. */
  14188. dispose(): void;
  14189. private _beforeClear;
  14190. }
  14191. }
  14192. declare module "babylonjs/Shaders/procedural.vertex" {
  14193. /** @hidden */
  14194. export var proceduralVertexShader: {
  14195. name: string;
  14196. shader: string;
  14197. };
  14198. }
  14199. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  14200. import { Observable } from "babylonjs/Misc/observable";
  14201. import { Nullable } from "babylonjs/types";
  14202. import { Scene } from "babylonjs/scene";
  14203. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  14204. import { Effect } from "babylonjs/Materials/effect";
  14205. import { Texture } from "babylonjs/Materials/Textures/texture";
  14206. import "babylonjs/Shaders/procedural.vertex";
  14207. /**
  14208. * 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.
  14209. * This is the base class of any Procedural texture and contains most of the shareable code.
  14210. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14211. */
  14212. export class ProceduralTexture extends Texture {
  14213. isCube: boolean;
  14214. /**
  14215. * Define if the texture is enabled or not (disabled texture will not render)
  14216. */
  14217. isEnabled: boolean;
  14218. /**
  14219. * Define if the texture must be cleared before rendering (default is true)
  14220. */
  14221. autoClear: boolean;
  14222. /**
  14223. * Callback called when the texture is generated
  14224. */
  14225. onGenerated: () => void;
  14226. /**
  14227. * Event raised when the texture is generated
  14228. */
  14229. onGeneratedObservable: Observable<ProceduralTexture>;
  14230. /** @hidden */
  14231. _generateMipMaps: boolean;
  14232. /** @hidden **/
  14233. _effect: Effect;
  14234. /** @hidden */
  14235. _textures: {
  14236. [key: string]: Texture;
  14237. };
  14238. private _size;
  14239. private _currentRefreshId;
  14240. private _refreshRate;
  14241. private _vertexBuffers;
  14242. private _indexBuffer;
  14243. private _uniforms;
  14244. private _samplers;
  14245. private _fragment;
  14246. private _floats;
  14247. private _ints;
  14248. private _floatsArrays;
  14249. private _colors3;
  14250. private _colors4;
  14251. private _vectors2;
  14252. private _vectors3;
  14253. private _matrices;
  14254. private _fallbackTexture;
  14255. private _fallbackTextureUsed;
  14256. private _engine;
  14257. private _cachedDefines;
  14258. private _contentUpdateId;
  14259. private _contentData;
  14260. /**
  14261. * Instantiates a new procedural texture.
  14262. * 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.
  14263. * This is the base class of any Procedural texture and contains most of the shareable code.
  14264. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14265. * @param name Define the name of the texture
  14266. * @param size Define the size of the texture to create
  14267. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14268. * @param scene Define the scene the texture belongs to
  14269. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14270. * @param generateMipMaps Define if the texture should creates mip maps or not
  14271. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14272. */
  14273. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14274. /**
  14275. * The effect that is created when initializing the post process.
  14276. * @returns The created effect corrisponding the the postprocess.
  14277. */
  14278. getEffect(): Effect;
  14279. /**
  14280. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14281. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14282. */
  14283. getContent(): Nullable<ArrayBufferView>;
  14284. private _createIndexBuffer;
  14285. /** @hidden */
  14286. _rebuild(): void;
  14287. /**
  14288. * Resets the texture in order to recreate its associated resources.
  14289. * This can be called in case of context loss
  14290. */
  14291. reset(): void;
  14292. protected _getDefines(): string;
  14293. /**
  14294. * Is the texture ready to be used ? (rendered at least once)
  14295. * @returns true if ready, otherwise, false.
  14296. */
  14297. isReady(): boolean;
  14298. /**
  14299. * Resets the refresh counter of the texture and start bak from scratch.
  14300. * Could be useful to regenerate the texture if it is setup to render only once.
  14301. */
  14302. resetRefreshCounter(): void;
  14303. /**
  14304. * Set the fragment shader to use in order to render the texture.
  14305. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14306. */
  14307. setFragment(fragment: any): void;
  14308. /**
  14309. * Define the refresh rate of the texture or the rendering frequency.
  14310. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14311. */
  14312. refreshRate: number;
  14313. /** @hidden */
  14314. _shouldRender(): boolean;
  14315. /**
  14316. * Get the size the texture is rendering at.
  14317. * @returns the size (texture is always squared)
  14318. */
  14319. getRenderSize(): number;
  14320. /**
  14321. * Resize the texture to new value.
  14322. * @param size Define the new size the texture should have
  14323. * @param generateMipMaps Define whether the new texture should create mip maps
  14324. */
  14325. resize(size: number, generateMipMaps: boolean): void;
  14326. private _checkUniform;
  14327. /**
  14328. * Set a texture in the shader program used to render.
  14329. * @param name Define the name of the uniform samplers as defined in the shader
  14330. * @param texture Define the texture to bind to this sampler
  14331. * @return the texture itself allowing "fluent" like uniform updates
  14332. */
  14333. setTexture(name: string, texture: Texture): ProceduralTexture;
  14334. /**
  14335. * Set a float in the shader.
  14336. * @param name Define the name of the uniform as defined in the shader
  14337. * @param value Define the value to give to the uniform
  14338. * @return the texture itself allowing "fluent" like uniform updates
  14339. */
  14340. setFloat(name: string, value: number): ProceduralTexture;
  14341. /**
  14342. * Set a int in the shader.
  14343. * @param name Define the name of the uniform as defined in the shader
  14344. * @param value Define the value to give to the uniform
  14345. * @return the texture itself allowing "fluent" like uniform updates
  14346. */
  14347. setInt(name: string, value: number): ProceduralTexture;
  14348. /**
  14349. * Set an array of floats in the shader.
  14350. * @param name Define the name of the uniform as defined in the shader
  14351. * @param value Define the value to give to the uniform
  14352. * @return the texture itself allowing "fluent" like uniform updates
  14353. */
  14354. setFloats(name: string, value: number[]): ProceduralTexture;
  14355. /**
  14356. * Set a vec3 in the shader from a Color3.
  14357. * @param name Define the name of the uniform as defined in the shader
  14358. * @param value Define the value to give to the uniform
  14359. * @return the texture itself allowing "fluent" like uniform updates
  14360. */
  14361. setColor3(name: string, value: Color3): ProceduralTexture;
  14362. /**
  14363. * Set a vec4 in the shader from a Color4.
  14364. * @param name Define the name of the uniform as defined in the shader
  14365. * @param value Define the value to give to the uniform
  14366. * @return the texture itself allowing "fluent" like uniform updates
  14367. */
  14368. setColor4(name: string, value: Color4): ProceduralTexture;
  14369. /**
  14370. * Set a vec2 in the shader from a Vector2.
  14371. * @param name Define the name of the uniform as defined in the shader
  14372. * @param value Define the value to give to the uniform
  14373. * @return the texture itself allowing "fluent" like uniform updates
  14374. */
  14375. setVector2(name: string, value: Vector2): ProceduralTexture;
  14376. /**
  14377. * Set a vec3 in the shader from a Vector3.
  14378. * @param name Define the name of the uniform as defined in the shader
  14379. * @param value Define the value to give to the uniform
  14380. * @return the texture itself allowing "fluent" like uniform updates
  14381. */
  14382. setVector3(name: string, value: Vector3): ProceduralTexture;
  14383. /**
  14384. * Set a mat4 in the shader from a MAtrix.
  14385. * @param name Define the name of the uniform as defined in the shader
  14386. * @param value Define the value to give to the uniform
  14387. * @return the texture itself allowing "fluent" like uniform updates
  14388. */
  14389. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14390. /**
  14391. * Render the texture to its associated render target.
  14392. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14393. */
  14394. render(useCameraPostProcess?: boolean): void;
  14395. /**
  14396. * Clone the texture.
  14397. * @returns the cloned texture
  14398. */
  14399. clone(): ProceduralTexture;
  14400. /**
  14401. * Dispose the texture and release its asoociated resources.
  14402. */
  14403. dispose(): void;
  14404. }
  14405. }
  14406. declare module "babylonjs/Particles/baseParticleSystem" {
  14407. import { Nullable } from "babylonjs/types";
  14408. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14409. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14410. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14411. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14412. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14413. import { Scene } from "babylonjs/scene";
  14414. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14415. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14416. import { Texture } from "babylonjs/Materials/Textures/texture";
  14417. import { Animation } from "babylonjs/Animations/animation";
  14418. /**
  14419. * This represents the base class for particle system in Babylon.
  14420. * 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.
  14421. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14422. * @example https://doc.babylonjs.com/babylon101/particles
  14423. */
  14424. export class BaseParticleSystem {
  14425. /**
  14426. * Source color is added to the destination color without alpha affecting the result
  14427. */
  14428. static BLENDMODE_ONEONE: number;
  14429. /**
  14430. * Blend current color and particle color using particle’s alpha
  14431. */
  14432. static BLENDMODE_STANDARD: number;
  14433. /**
  14434. * Add current color and particle color multiplied by particle’s alpha
  14435. */
  14436. static BLENDMODE_ADD: number;
  14437. /**
  14438. * Multiply current color with particle color
  14439. */
  14440. static BLENDMODE_MULTIPLY: number;
  14441. /**
  14442. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14443. */
  14444. static BLENDMODE_MULTIPLYADD: number;
  14445. /**
  14446. * List of animations used by the particle system.
  14447. */
  14448. animations: Animation[];
  14449. /**
  14450. * The id of the Particle system.
  14451. */
  14452. id: string;
  14453. /**
  14454. * The friendly name of the Particle system.
  14455. */
  14456. name: string;
  14457. /**
  14458. * The rendering group used by the Particle system to chose when to render.
  14459. */
  14460. renderingGroupId: number;
  14461. /**
  14462. * The emitter represents the Mesh or position we are attaching the particle system to.
  14463. */
  14464. emitter: Nullable<AbstractMesh | Vector3>;
  14465. /**
  14466. * The maximum number of particles to emit per frame
  14467. */
  14468. emitRate: number;
  14469. /**
  14470. * If you want to launch only a few particles at once, that can be done, as well.
  14471. */
  14472. manualEmitCount: number;
  14473. /**
  14474. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14475. */
  14476. updateSpeed: number;
  14477. /**
  14478. * The amount of time the particle system is running (depends of the overall update speed).
  14479. */
  14480. targetStopDuration: number;
  14481. /**
  14482. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14483. */
  14484. disposeOnStop: boolean;
  14485. /**
  14486. * Minimum power of emitting particles.
  14487. */
  14488. minEmitPower: number;
  14489. /**
  14490. * Maximum power of emitting particles.
  14491. */
  14492. maxEmitPower: number;
  14493. /**
  14494. * Minimum life time of emitting particles.
  14495. */
  14496. minLifeTime: number;
  14497. /**
  14498. * Maximum life time of emitting particles.
  14499. */
  14500. maxLifeTime: number;
  14501. /**
  14502. * Minimum Size of emitting particles.
  14503. */
  14504. minSize: number;
  14505. /**
  14506. * Maximum Size of emitting particles.
  14507. */
  14508. maxSize: number;
  14509. /**
  14510. * Minimum scale of emitting particles on X axis.
  14511. */
  14512. minScaleX: number;
  14513. /**
  14514. * Maximum scale of emitting particles on X axis.
  14515. */
  14516. maxScaleX: number;
  14517. /**
  14518. * Minimum scale of emitting particles on Y axis.
  14519. */
  14520. minScaleY: number;
  14521. /**
  14522. * Maximum scale of emitting particles on Y axis.
  14523. */
  14524. maxScaleY: number;
  14525. /**
  14526. * Gets or sets the minimal initial rotation in radians.
  14527. */
  14528. minInitialRotation: number;
  14529. /**
  14530. * Gets or sets the maximal initial rotation in radians.
  14531. */
  14532. maxInitialRotation: number;
  14533. /**
  14534. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14535. */
  14536. minAngularSpeed: number;
  14537. /**
  14538. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14539. */
  14540. maxAngularSpeed: number;
  14541. /**
  14542. * The texture used to render each particle. (this can be a spritesheet)
  14543. */
  14544. particleTexture: Nullable<Texture>;
  14545. /**
  14546. * The layer mask we are rendering the particles through.
  14547. */
  14548. layerMask: number;
  14549. /**
  14550. * This can help using your own shader to render the particle system.
  14551. * The according effect will be created
  14552. */
  14553. customShader: any;
  14554. /**
  14555. * By default particle system starts as soon as they are created. This prevents the
  14556. * automatic start to happen and let you decide when to start emitting particles.
  14557. */
  14558. preventAutoStart: boolean;
  14559. private _noiseTexture;
  14560. /**
  14561. * Gets or sets a texture used to add random noise to particle positions
  14562. */
  14563. noiseTexture: Nullable<ProceduralTexture>;
  14564. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14565. noiseStrength: Vector3;
  14566. /**
  14567. * Callback triggered when the particle animation is ending.
  14568. */
  14569. onAnimationEnd: Nullable<() => void>;
  14570. /**
  14571. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14572. */
  14573. blendMode: number;
  14574. /**
  14575. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14576. * to override the particles.
  14577. */
  14578. forceDepthWrite: boolean;
  14579. /** 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 */
  14580. preWarmCycles: number;
  14581. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14582. preWarmStepOffset: number;
  14583. /**
  14584. * 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)
  14585. */
  14586. spriteCellChangeSpeed: number;
  14587. /**
  14588. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14589. */
  14590. startSpriteCellID: number;
  14591. /**
  14592. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14593. */
  14594. endSpriteCellID: number;
  14595. /**
  14596. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14597. */
  14598. spriteCellWidth: number;
  14599. /**
  14600. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14601. */
  14602. spriteCellHeight: number;
  14603. /**
  14604. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14605. */
  14606. spriteRandomStartCell: boolean;
  14607. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14608. translationPivot: Vector2;
  14609. /** @hidden */
  14610. protected _isAnimationSheetEnabled: boolean;
  14611. /**
  14612. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14613. */
  14614. beginAnimationOnStart: boolean;
  14615. /**
  14616. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14617. */
  14618. beginAnimationFrom: number;
  14619. /**
  14620. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14621. */
  14622. beginAnimationTo: number;
  14623. /**
  14624. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14625. */
  14626. beginAnimationLoop: boolean;
  14627. /**
  14628. * Gets or sets a world offset applied to all particles
  14629. */
  14630. worldOffset: Vector3;
  14631. /**
  14632. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14633. */
  14634. isAnimationSheetEnabled: boolean;
  14635. /**
  14636. * Get hosting scene
  14637. * @returns the scene
  14638. */
  14639. getScene(): Scene;
  14640. /**
  14641. * You can use gravity if you want to give an orientation to your particles.
  14642. */
  14643. gravity: Vector3;
  14644. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14645. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14646. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14647. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14648. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14649. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14650. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14651. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14652. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14653. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14654. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14655. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14656. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14657. /**
  14658. * Defines the delay in milliseconds before starting the system (0 by default)
  14659. */
  14660. startDelay: number;
  14661. /**
  14662. * Gets the current list of drag gradients.
  14663. * You must use addDragGradient and removeDragGradient to udpate this list
  14664. * @returns the list of drag gradients
  14665. */
  14666. getDragGradients(): Nullable<Array<FactorGradient>>;
  14667. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14668. limitVelocityDamping: number;
  14669. /**
  14670. * Gets the current list of limit velocity gradients.
  14671. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14672. * @returns the list of limit velocity gradients
  14673. */
  14674. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14675. /**
  14676. * Gets the current list of color gradients.
  14677. * You must use addColorGradient and removeColorGradient to udpate this list
  14678. * @returns the list of color gradients
  14679. */
  14680. getColorGradients(): Nullable<Array<ColorGradient>>;
  14681. /**
  14682. * Gets the current list of size gradients.
  14683. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14684. * @returns the list of size gradients
  14685. */
  14686. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14687. /**
  14688. * Gets the current list of color remap gradients.
  14689. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14690. * @returns the list of color remap gradients
  14691. */
  14692. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14693. /**
  14694. * Gets the current list of alpha remap gradients.
  14695. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14696. * @returns the list of alpha remap gradients
  14697. */
  14698. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14699. /**
  14700. * Gets the current list of life time gradients.
  14701. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14702. * @returns the list of life time gradients
  14703. */
  14704. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14705. /**
  14706. * Gets the current list of angular speed gradients.
  14707. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14708. * @returns the list of angular speed gradients
  14709. */
  14710. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14711. /**
  14712. * Gets the current list of velocity gradients.
  14713. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14714. * @returns the list of velocity gradients
  14715. */
  14716. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14717. /**
  14718. * Gets the current list of start size gradients.
  14719. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14720. * @returns the list of start size gradients
  14721. */
  14722. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14723. /**
  14724. * Gets the current list of emit rate gradients.
  14725. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14726. * @returns the list of emit rate gradients
  14727. */
  14728. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14729. /**
  14730. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14731. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14732. */
  14733. direction1: Vector3;
  14734. /**
  14735. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14736. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14737. */
  14738. direction2: Vector3;
  14739. /**
  14740. * 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.
  14741. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14742. */
  14743. minEmitBox: Vector3;
  14744. /**
  14745. * 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.
  14746. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14747. */
  14748. maxEmitBox: Vector3;
  14749. /**
  14750. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14751. */
  14752. color1: Color4;
  14753. /**
  14754. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14755. */
  14756. color2: Color4;
  14757. /**
  14758. * Color the particle will have at the end of its lifetime
  14759. */
  14760. colorDead: Color4;
  14761. /**
  14762. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14763. */
  14764. textureMask: Color4;
  14765. /**
  14766. * The particle emitter type defines the emitter used by the particle system.
  14767. * It can be for example box, sphere, or cone...
  14768. */
  14769. particleEmitterType: IParticleEmitterType;
  14770. /** @hidden */
  14771. _isSubEmitter: boolean;
  14772. /**
  14773. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14774. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14775. */
  14776. billboardMode: number;
  14777. protected _isBillboardBased: boolean;
  14778. /**
  14779. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14780. */
  14781. isBillboardBased: boolean;
  14782. /**
  14783. * The scene the particle system belongs to.
  14784. */
  14785. protected _scene: Scene;
  14786. /**
  14787. * Local cache of defines for image processing.
  14788. */
  14789. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14790. /**
  14791. * Default configuration related to image processing available in the standard Material.
  14792. */
  14793. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14794. /**
  14795. * Gets the image processing configuration used either in this material.
  14796. */
  14797. /**
  14798. * Sets the Default image processing configuration used either in the this material.
  14799. *
  14800. * If sets to null, the scene one is in use.
  14801. */
  14802. imageProcessingConfiguration: ImageProcessingConfiguration;
  14803. /**
  14804. * Attaches a new image processing configuration to the Standard Material.
  14805. * @param configuration
  14806. */
  14807. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14808. /** @hidden */
  14809. protected _reset(): void;
  14810. /** @hidden */
  14811. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14812. /**
  14813. * Instantiates a particle system.
  14814. * 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.
  14815. * @param name The name of the particle system
  14816. */
  14817. constructor(name: string);
  14818. /**
  14819. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14820. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14821. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14822. * @returns the emitter
  14823. */
  14824. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14825. /**
  14826. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14827. * @param radius The radius of the hemisphere to emit from
  14828. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14829. * @returns the emitter
  14830. */
  14831. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14832. /**
  14833. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14834. * @param radius The radius of the sphere to emit from
  14835. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14836. * @returns the emitter
  14837. */
  14838. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14839. /**
  14840. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14841. * @param radius The radius of the sphere to emit from
  14842. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14843. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14844. * @returns the emitter
  14845. */
  14846. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14847. /**
  14848. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14849. * @param radius The radius of the emission cylinder
  14850. * @param height The height of the emission cylinder
  14851. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14852. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14853. * @returns the emitter
  14854. */
  14855. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14856. /**
  14857. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14858. * @param radius The radius of the cylinder to emit from
  14859. * @param height The height of the emission cylinder
  14860. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14861. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14862. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14863. * @returns the emitter
  14864. */
  14865. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14866. /**
  14867. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14868. * @param radius The radius of the cone to emit from
  14869. * @param angle The base angle of the cone
  14870. * @returns the emitter
  14871. */
  14872. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14873. /**
  14874. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14875. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14876. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14877. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14878. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14879. * @returns the emitter
  14880. */
  14881. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14882. }
  14883. }
  14884. declare module "babylonjs/Particles/subEmitter" {
  14885. import { Scene } from "babylonjs/scene";
  14886. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  14887. /**
  14888. * Type of sub emitter
  14889. */
  14890. export enum SubEmitterType {
  14891. /**
  14892. * Attached to the particle over it's lifetime
  14893. */
  14894. ATTACHED = 0,
  14895. /**
  14896. * Created when the particle dies
  14897. */
  14898. END = 1
  14899. }
  14900. /**
  14901. * Sub emitter class used to emit particles from an existing particle
  14902. */
  14903. export class SubEmitter {
  14904. /**
  14905. * the particle system to be used by the sub emitter
  14906. */
  14907. particleSystem: ParticleSystem;
  14908. /**
  14909. * Type of the submitter (Default: END)
  14910. */
  14911. type: SubEmitterType;
  14912. /**
  14913. * 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)
  14914. * Note: This only is supported when using an emitter of type Mesh
  14915. */
  14916. inheritDirection: boolean;
  14917. /**
  14918. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14919. */
  14920. inheritedVelocityAmount: number;
  14921. /**
  14922. * Creates a sub emitter
  14923. * @param particleSystem the particle system to be used by the sub emitter
  14924. */
  14925. constructor(
  14926. /**
  14927. * the particle system to be used by the sub emitter
  14928. */
  14929. particleSystem: ParticleSystem);
  14930. /**
  14931. * Clones the sub emitter
  14932. * @returns the cloned sub emitter
  14933. */
  14934. clone(): SubEmitter;
  14935. /**
  14936. * Serialize current object to a JSON object
  14937. * @returns the serialized object
  14938. */
  14939. serialize(): any;
  14940. /** @hidden */
  14941. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14942. /**
  14943. * Creates a new SubEmitter from a serialized JSON version
  14944. * @param serializationObject defines the JSON object to read from
  14945. * @param scene defines the hosting scene
  14946. * @param rootUrl defines the rootUrl for data loading
  14947. * @returns a new SubEmitter
  14948. */
  14949. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14950. /** Release associated resources */
  14951. dispose(): void;
  14952. }
  14953. }
  14954. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  14955. /** @hidden */
  14956. export var clipPlaneFragmentDeclaration: {
  14957. name: string;
  14958. shader: string;
  14959. };
  14960. }
  14961. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  14962. /** @hidden */
  14963. export var imageProcessingDeclaration: {
  14964. name: string;
  14965. shader: string;
  14966. };
  14967. }
  14968. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  14969. /** @hidden */
  14970. export var imageProcessingFunctions: {
  14971. name: string;
  14972. shader: string;
  14973. };
  14974. }
  14975. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  14976. /** @hidden */
  14977. export var clipPlaneFragment: {
  14978. name: string;
  14979. shader: string;
  14980. };
  14981. }
  14982. declare module "babylonjs/Shaders/particles.fragment" {
  14983. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  14984. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  14985. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  14986. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  14987. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  14988. /** @hidden */
  14989. export var particlesPixelShader: {
  14990. name: string;
  14991. shader: string;
  14992. };
  14993. }
  14994. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  14995. /** @hidden */
  14996. export var clipPlaneVertexDeclaration: {
  14997. name: string;
  14998. shader: string;
  14999. };
  15000. }
  15001. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  15002. /** @hidden */
  15003. export var clipPlaneVertex: {
  15004. name: string;
  15005. shader: string;
  15006. };
  15007. }
  15008. declare module "babylonjs/Shaders/particles.vertex" {
  15009. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15010. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15011. /** @hidden */
  15012. export var particlesVertexShader: {
  15013. name: string;
  15014. shader: string;
  15015. };
  15016. }
  15017. declare module "babylonjs/Particles/particleSystem" {
  15018. import { Nullable } from "babylonjs/types";
  15019. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  15020. import { Observable } from "babylonjs/Misc/observable";
  15021. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  15022. import { Effect } from "babylonjs/Materials/effect";
  15023. import { Scene, IDisposable } from "babylonjs/scene";
  15024. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  15025. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  15026. import { Particle } from "babylonjs/Particles/particle";
  15027. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15028. import "babylonjs/Shaders/particles.fragment";
  15029. import "babylonjs/Shaders/particles.vertex";
  15030. /**
  15031. * This represents a particle system in Babylon.
  15032. * 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.
  15033. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15034. * @example https://doc.babylonjs.com/babylon101/particles
  15035. */
  15036. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15037. /**
  15038. * Billboard mode will only apply to Y axis
  15039. */
  15040. static readonly BILLBOARDMODE_Y: number;
  15041. /**
  15042. * Billboard mode will apply to all axes
  15043. */
  15044. static readonly BILLBOARDMODE_ALL: number;
  15045. /**
  15046. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15047. */
  15048. static readonly BILLBOARDMODE_STRETCHED: number;
  15049. /**
  15050. * This function can be defined to provide custom update for active particles.
  15051. * This function will be called instead of regular update (age, position, color, etc.).
  15052. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15053. */
  15054. updateFunction: (particles: Particle[]) => void;
  15055. private _emitterWorldMatrix;
  15056. /**
  15057. * This function can be defined to specify initial direction for every new particle.
  15058. * It by default use the emitterType defined function
  15059. */
  15060. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  15061. /**
  15062. * This function can be defined to specify initial position for every new particle.
  15063. * It by default use the emitterType defined function
  15064. */
  15065. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  15066. /**
  15067. * @hidden
  15068. */
  15069. _inheritedVelocityOffset: Vector3;
  15070. /**
  15071. * An event triggered when the system is disposed
  15072. */
  15073. onDisposeObservable: Observable<ParticleSystem>;
  15074. private _onDisposeObserver;
  15075. /**
  15076. * Sets a callback that will be triggered when the system is disposed
  15077. */
  15078. onDispose: () => void;
  15079. private _particles;
  15080. private _epsilon;
  15081. private _capacity;
  15082. private _stockParticles;
  15083. private _newPartsExcess;
  15084. private _vertexData;
  15085. private _vertexBuffer;
  15086. private _vertexBuffers;
  15087. private _spriteBuffer;
  15088. private _indexBuffer;
  15089. private _effect;
  15090. private _customEffect;
  15091. private _cachedDefines;
  15092. private _scaledColorStep;
  15093. private _colorDiff;
  15094. private _scaledDirection;
  15095. private _scaledGravity;
  15096. private _currentRenderId;
  15097. private _alive;
  15098. private _useInstancing;
  15099. private _started;
  15100. private _stopped;
  15101. private _actualFrame;
  15102. private _scaledUpdateSpeed;
  15103. private _vertexBufferSize;
  15104. /** @hidden */
  15105. _currentEmitRateGradient: Nullable<FactorGradient>;
  15106. /** @hidden */
  15107. _currentEmitRate1: number;
  15108. /** @hidden */
  15109. _currentEmitRate2: number;
  15110. /** @hidden */
  15111. _currentStartSizeGradient: Nullable<FactorGradient>;
  15112. /** @hidden */
  15113. _currentStartSize1: number;
  15114. /** @hidden */
  15115. _currentStartSize2: number;
  15116. private readonly _rawTextureWidth;
  15117. private _rampGradientsTexture;
  15118. private _useRampGradients;
  15119. /** Gets or sets a boolean indicating that ramp gradients must be used
  15120. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15121. */
  15122. useRampGradients: boolean;
  15123. /**
  15124. * 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.
  15125. * 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: [])
  15126. */
  15127. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15128. private _subEmitters;
  15129. /**
  15130. * @hidden
  15131. * If the particle systems emitter should be disposed when the particle system is disposed
  15132. */
  15133. _disposeEmitterOnDispose: boolean;
  15134. /**
  15135. * The current active Sub-systems, this property is used by the root particle system only.
  15136. */
  15137. activeSubSystems: Array<ParticleSystem>;
  15138. private _rootParticleSystem;
  15139. /**
  15140. * Gets the current list of active particles
  15141. */
  15142. readonly particles: Particle[];
  15143. /**
  15144. * Returns the string "ParticleSystem"
  15145. * @returns a string containing the class name
  15146. */
  15147. getClassName(): string;
  15148. /**
  15149. * Instantiates a particle system.
  15150. * 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.
  15151. * @param name The name of the particle system
  15152. * @param capacity The max number of particles alive at the same time
  15153. * @param scene The scene the particle system belongs to
  15154. * @param customEffect a custom effect used to change the way particles are rendered by default
  15155. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15156. * @param epsilon Offset used to render the particles
  15157. */
  15158. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15159. private _addFactorGradient;
  15160. private _removeFactorGradient;
  15161. /**
  15162. * Adds a new life time gradient
  15163. * @param gradient defines the gradient to use (between 0 and 1)
  15164. * @param factor defines the life time factor to affect to the specified gradient
  15165. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15166. * @returns the current particle system
  15167. */
  15168. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15169. /**
  15170. * Remove a specific life time gradient
  15171. * @param gradient defines the gradient to remove
  15172. * @returns the current particle system
  15173. */
  15174. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15175. /**
  15176. * Adds a new size gradient
  15177. * @param gradient defines the gradient to use (between 0 and 1)
  15178. * @param factor defines the size factor to affect to the specified gradient
  15179. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15180. * @returns the current particle system
  15181. */
  15182. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15183. /**
  15184. * Remove a specific size gradient
  15185. * @param gradient defines the gradient to remove
  15186. * @returns the current particle system
  15187. */
  15188. removeSizeGradient(gradient: number): IParticleSystem;
  15189. /**
  15190. * Adds a new color remap gradient
  15191. * @param gradient defines the gradient to use (between 0 and 1)
  15192. * @param min defines the color remap minimal range
  15193. * @param max defines the color remap maximal range
  15194. * @returns the current particle system
  15195. */
  15196. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15197. /**
  15198. * Remove a specific color remap gradient
  15199. * @param gradient defines the gradient to remove
  15200. * @returns the current particle system
  15201. */
  15202. removeColorRemapGradient(gradient: number): IParticleSystem;
  15203. /**
  15204. * Adds a new alpha remap gradient
  15205. * @param gradient defines the gradient to use (between 0 and 1)
  15206. * @param min defines the alpha remap minimal range
  15207. * @param max defines the alpha remap maximal range
  15208. * @returns the current particle system
  15209. */
  15210. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15211. /**
  15212. * Remove a specific alpha remap gradient
  15213. * @param gradient defines the gradient to remove
  15214. * @returns the current particle system
  15215. */
  15216. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15217. /**
  15218. * Adds a new angular speed gradient
  15219. * @param gradient defines the gradient to use (between 0 and 1)
  15220. * @param factor defines the angular speed to affect to the specified gradient
  15221. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15222. * @returns the current particle system
  15223. */
  15224. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15225. /**
  15226. * Remove a specific angular speed gradient
  15227. * @param gradient defines the gradient to remove
  15228. * @returns the current particle system
  15229. */
  15230. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15231. /**
  15232. * Adds a new velocity gradient
  15233. * @param gradient defines the gradient to use (between 0 and 1)
  15234. * @param factor defines the velocity to affect to the specified gradient
  15235. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15236. * @returns the current particle system
  15237. */
  15238. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15239. /**
  15240. * Remove a specific velocity gradient
  15241. * @param gradient defines the gradient to remove
  15242. * @returns the current particle system
  15243. */
  15244. removeVelocityGradient(gradient: number): IParticleSystem;
  15245. /**
  15246. * Adds a new limit velocity gradient
  15247. * @param gradient defines the gradient to use (between 0 and 1)
  15248. * @param factor defines the limit velocity value to affect to the specified gradient
  15249. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15250. * @returns the current particle system
  15251. */
  15252. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15253. /**
  15254. * Remove a specific limit velocity gradient
  15255. * @param gradient defines the gradient to remove
  15256. * @returns the current particle system
  15257. */
  15258. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15259. /**
  15260. * Adds a new drag gradient
  15261. * @param gradient defines the gradient to use (between 0 and 1)
  15262. * @param factor defines the drag value to affect to the specified gradient
  15263. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15264. * @returns the current particle system
  15265. */
  15266. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15267. /**
  15268. * Remove a specific drag gradient
  15269. * @param gradient defines the gradient to remove
  15270. * @returns the current particle system
  15271. */
  15272. removeDragGradient(gradient: number): IParticleSystem;
  15273. /**
  15274. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15275. * @param gradient defines the gradient to use (between 0 and 1)
  15276. * @param factor defines the emit rate value to affect to the specified gradient
  15277. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15278. * @returns the current particle system
  15279. */
  15280. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15281. /**
  15282. * Remove a specific emit rate gradient
  15283. * @param gradient defines the gradient to remove
  15284. * @returns the current particle system
  15285. */
  15286. removeEmitRateGradient(gradient: number): IParticleSystem;
  15287. /**
  15288. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15289. * @param gradient defines the gradient to use (between 0 and 1)
  15290. * @param factor defines the start size value to affect to the specified gradient
  15291. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15292. * @returns the current particle system
  15293. */
  15294. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15295. /**
  15296. * Remove a specific start size gradient
  15297. * @param gradient defines the gradient to remove
  15298. * @returns the current particle system
  15299. */
  15300. removeStartSizeGradient(gradient: number): IParticleSystem;
  15301. private _createRampGradientTexture;
  15302. /**
  15303. * Gets the current list of ramp gradients.
  15304. * You must use addRampGradient and removeRampGradient to udpate this list
  15305. * @returns the list of ramp gradients
  15306. */
  15307. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15308. /**
  15309. * Adds a new ramp gradient used to remap particle colors
  15310. * @param gradient defines the gradient to use (between 0 and 1)
  15311. * @param color defines the color to affect to the specified gradient
  15312. * @returns the current particle system
  15313. */
  15314. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15315. /**
  15316. * Remove a specific ramp gradient
  15317. * @param gradient defines the gradient to remove
  15318. * @returns the current particle system
  15319. */
  15320. removeRampGradient(gradient: number): ParticleSystem;
  15321. /**
  15322. * Adds a new color gradient
  15323. * @param gradient defines the gradient to use (between 0 and 1)
  15324. * @param color1 defines the color to affect to the specified gradient
  15325. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15326. * @returns this particle system
  15327. */
  15328. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15329. /**
  15330. * Remove a specific color gradient
  15331. * @param gradient defines the gradient to remove
  15332. * @returns this particle system
  15333. */
  15334. removeColorGradient(gradient: number): IParticleSystem;
  15335. private _fetchR;
  15336. protected _reset(): void;
  15337. private _resetEffect;
  15338. private _createVertexBuffers;
  15339. private _createIndexBuffer;
  15340. /**
  15341. * Gets the maximum number of particles active at the same time.
  15342. * @returns The max number of active particles.
  15343. */
  15344. getCapacity(): number;
  15345. /**
  15346. * Gets whether there are still active particles in the system.
  15347. * @returns True if it is alive, otherwise false.
  15348. */
  15349. isAlive(): boolean;
  15350. /**
  15351. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15352. * @returns True if it has been started, otherwise false.
  15353. */
  15354. isStarted(): boolean;
  15355. private _prepareSubEmitterInternalArray;
  15356. /**
  15357. * Starts the particle system and begins to emit
  15358. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15359. */
  15360. start(delay?: number): void;
  15361. /**
  15362. * Stops the particle system.
  15363. * @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.
  15364. */
  15365. stop(stopSubEmitters?: boolean): void;
  15366. /**
  15367. * Remove all active particles
  15368. */
  15369. reset(): void;
  15370. /**
  15371. * @hidden (for internal use only)
  15372. */
  15373. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15374. /**
  15375. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15376. * Its lifetime will start back at 0.
  15377. */
  15378. recycleParticle: (particle: Particle) => void;
  15379. private _stopSubEmitters;
  15380. private _createParticle;
  15381. private _removeFromRoot;
  15382. private _emitFromParticle;
  15383. private _update;
  15384. /** @hidden */
  15385. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15386. /** @hidden */
  15387. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15388. /** @hidden */
  15389. private _getEffect;
  15390. /**
  15391. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15392. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15393. */
  15394. animate(preWarmOnly?: boolean): void;
  15395. private _appendParticleVertices;
  15396. /**
  15397. * Rebuilds the particle system.
  15398. */
  15399. rebuild(): void;
  15400. /**
  15401. * Is this system ready to be used/rendered
  15402. * @return true if the system is ready
  15403. */
  15404. isReady(): boolean;
  15405. private _render;
  15406. /**
  15407. * Renders the particle system in its current state.
  15408. * @returns the current number of particles
  15409. */
  15410. render(): number;
  15411. /**
  15412. * Disposes the particle system and free the associated resources
  15413. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15414. */
  15415. dispose(disposeTexture?: boolean): void;
  15416. /**
  15417. * Clones the particle system.
  15418. * @param name The name of the cloned object
  15419. * @param newEmitter The new emitter to use
  15420. * @returns the cloned particle system
  15421. */
  15422. clone(name: string, newEmitter: any): ParticleSystem;
  15423. /**
  15424. * Serializes the particle system to a JSON object.
  15425. * @returns the JSON object
  15426. */
  15427. serialize(): any;
  15428. /** @hidden */
  15429. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15430. /** @hidden */
  15431. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15432. /**
  15433. * Parses a JSON object to create a particle system.
  15434. * @param parsedParticleSystem The JSON object to parse
  15435. * @param scene The scene to create the particle system in
  15436. * @param rootUrl The root url to use to load external dependencies like texture
  15437. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15438. * @returns the Parsed particle system
  15439. */
  15440. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15441. }
  15442. }
  15443. declare module "babylonjs/Particles/particle" {
  15444. import { Nullable } from "babylonjs/types";
  15445. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15446. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15447. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15448. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15449. /**
  15450. * A particle represents one of the element emitted by a particle system.
  15451. * This is mainly define by its coordinates, direction, velocity and age.
  15452. */
  15453. export class Particle {
  15454. /**
  15455. * The particle system the particle belongs to.
  15456. */
  15457. particleSystem: ParticleSystem;
  15458. private static _Count;
  15459. /**
  15460. * Unique ID of the particle
  15461. */
  15462. id: number;
  15463. /**
  15464. * The world position of the particle in the scene.
  15465. */
  15466. position: Vector3;
  15467. /**
  15468. * The world direction of the particle in the scene.
  15469. */
  15470. direction: Vector3;
  15471. /**
  15472. * The color of the particle.
  15473. */
  15474. color: Color4;
  15475. /**
  15476. * The color change of the particle per step.
  15477. */
  15478. colorStep: Color4;
  15479. /**
  15480. * Defines how long will the life of the particle be.
  15481. */
  15482. lifeTime: number;
  15483. /**
  15484. * The current age of the particle.
  15485. */
  15486. age: number;
  15487. /**
  15488. * The current size of the particle.
  15489. */
  15490. size: number;
  15491. /**
  15492. * The current scale of the particle.
  15493. */
  15494. scale: Vector2;
  15495. /**
  15496. * The current angle of the particle.
  15497. */
  15498. angle: number;
  15499. /**
  15500. * Defines how fast is the angle changing.
  15501. */
  15502. angularSpeed: number;
  15503. /**
  15504. * Defines the cell index used by the particle to be rendered from a sprite.
  15505. */
  15506. cellIndex: number;
  15507. /**
  15508. * The information required to support color remapping
  15509. */
  15510. remapData: Vector4;
  15511. /** @hidden */
  15512. _randomCellOffset?: number;
  15513. /** @hidden */
  15514. _initialDirection: Nullable<Vector3>;
  15515. /** @hidden */
  15516. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15517. /** @hidden */
  15518. _initialStartSpriteCellID: number;
  15519. /** @hidden */
  15520. _initialEndSpriteCellID: number;
  15521. /** @hidden */
  15522. _currentColorGradient: Nullable<ColorGradient>;
  15523. /** @hidden */
  15524. _currentColor1: Color4;
  15525. /** @hidden */
  15526. _currentColor2: Color4;
  15527. /** @hidden */
  15528. _currentSizeGradient: Nullable<FactorGradient>;
  15529. /** @hidden */
  15530. _currentSize1: number;
  15531. /** @hidden */
  15532. _currentSize2: number;
  15533. /** @hidden */
  15534. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15535. /** @hidden */
  15536. _currentAngularSpeed1: number;
  15537. /** @hidden */
  15538. _currentAngularSpeed2: number;
  15539. /** @hidden */
  15540. _currentVelocityGradient: Nullable<FactorGradient>;
  15541. /** @hidden */
  15542. _currentVelocity1: number;
  15543. /** @hidden */
  15544. _currentVelocity2: number;
  15545. /** @hidden */
  15546. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15547. /** @hidden */
  15548. _currentLimitVelocity1: number;
  15549. /** @hidden */
  15550. _currentLimitVelocity2: number;
  15551. /** @hidden */
  15552. _currentDragGradient: Nullable<FactorGradient>;
  15553. /** @hidden */
  15554. _currentDrag1: number;
  15555. /** @hidden */
  15556. _currentDrag2: number;
  15557. /** @hidden */
  15558. _randomNoiseCoordinates1: Vector3;
  15559. /** @hidden */
  15560. _randomNoiseCoordinates2: Vector3;
  15561. /**
  15562. * Creates a new instance Particle
  15563. * @param particleSystem the particle system the particle belongs to
  15564. */
  15565. constructor(
  15566. /**
  15567. * The particle system the particle belongs to.
  15568. */
  15569. particleSystem: ParticleSystem);
  15570. private updateCellInfoFromSystem;
  15571. /**
  15572. * Defines how the sprite cell index is updated for the particle
  15573. */
  15574. updateCellIndex(): void;
  15575. /** @hidden */
  15576. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15577. /** @hidden */
  15578. _inheritParticleInfoToSubEmitters(): void;
  15579. /** @hidden */
  15580. _reset(): void;
  15581. /**
  15582. * Copy the properties of particle to another one.
  15583. * @param other the particle to copy the information to.
  15584. */
  15585. copyTo(other: Particle): void;
  15586. }
  15587. }
  15588. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15589. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15590. import { Effect } from "babylonjs/Materials/effect";
  15591. import { Particle } from "babylonjs/Particles/particle";
  15592. /**
  15593. * Particle emitter represents a volume emitting particles.
  15594. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15595. */
  15596. export interface IParticleEmitterType {
  15597. /**
  15598. * Called by the particle System when the direction is computed for the created particle.
  15599. * @param worldMatrix is the world matrix of the particle system
  15600. * @param directionToUpdate is the direction vector to update with the result
  15601. * @param particle is the particle we are computed the direction for
  15602. */
  15603. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15604. /**
  15605. * Called by the particle System when the position is computed for the created particle.
  15606. * @param worldMatrix is the world matrix of the particle system
  15607. * @param positionToUpdate is the position vector to update with the result
  15608. * @param particle is the particle we are computed the position for
  15609. */
  15610. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15611. /**
  15612. * Clones the current emitter and returns a copy of it
  15613. * @returns the new emitter
  15614. */
  15615. clone(): IParticleEmitterType;
  15616. /**
  15617. * Called by the GPUParticleSystem to setup the update shader
  15618. * @param effect defines the update shader
  15619. */
  15620. applyToShader(effect: Effect): void;
  15621. /**
  15622. * Returns a string to use to update the GPU particles update shader
  15623. * @returns the effect defines string
  15624. */
  15625. getEffectDefines(): string;
  15626. /**
  15627. * Returns a string representing the class name
  15628. * @returns a string containing the class name
  15629. */
  15630. getClassName(): string;
  15631. /**
  15632. * Serializes the particle system to a JSON object.
  15633. * @returns the JSON object
  15634. */
  15635. serialize(): any;
  15636. /**
  15637. * Parse properties from a JSON object
  15638. * @param serializationObject defines the JSON object
  15639. */
  15640. parse(serializationObject: any): void;
  15641. }
  15642. }
  15643. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15644. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15645. import { Effect } from "babylonjs/Materials/effect";
  15646. import { Particle } from "babylonjs/Particles/particle";
  15647. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15648. /**
  15649. * Particle emitter emitting particles from the inside of a box.
  15650. * It emits the particles randomly between 2 given directions.
  15651. */
  15652. export class BoxParticleEmitter implements IParticleEmitterType {
  15653. /**
  15654. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15655. */
  15656. direction1: Vector3;
  15657. /**
  15658. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15659. */
  15660. direction2: Vector3;
  15661. /**
  15662. * 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.
  15663. */
  15664. minEmitBox: Vector3;
  15665. /**
  15666. * 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.
  15667. */
  15668. maxEmitBox: Vector3;
  15669. /**
  15670. * Creates a new instance BoxParticleEmitter
  15671. */
  15672. constructor();
  15673. /**
  15674. * Called by the particle System when the direction is computed for the created particle.
  15675. * @param worldMatrix is the world matrix of the particle system
  15676. * @param directionToUpdate is the direction vector to update with the result
  15677. * @param particle is the particle we are computed the direction for
  15678. */
  15679. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15680. /**
  15681. * Called by the particle System when the position is computed for the created particle.
  15682. * @param worldMatrix is the world matrix of the particle system
  15683. * @param positionToUpdate is the position vector to update with the result
  15684. * @param particle is the particle we are computed the position for
  15685. */
  15686. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15687. /**
  15688. * Clones the current emitter and returns a copy of it
  15689. * @returns the new emitter
  15690. */
  15691. clone(): BoxParticleEmitter;
  15692. /**
  15693. * Called by the GPUParticleSystem to setup the update shader
  15694. * @param effect defines the update shader
  15695. */
  15696. applyToShader(effect: Effect): void;
  15697. /**
  15698. * Returns a string to use to update the GPU particles update shader
  15699. * @returns a string containng the defines string
  15700. */
  15701. getEffectDefines(): string;
  15702. /**
  15703. * Returns the string "BoxParticleEmitter"
  15704. * @returns a string containing the class name
  15705. */
  15706. getClassName(): string;
  15707. /**
  15708. * Serializes the particle system to a JSON object.
  15709. * @returns the JSON object
  15710. */
  15711. serialize(): any;
  15712. /**
  15713. * Parse properties from a JSON object
  15714. * @param serializationObject defines the JSON object
  15715. */
  15716. parse(serializationObject: any): void;
  15717. }
  15718. }
  15719. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  15720. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15721. import { Effect } from "babylonjs/Materials/effect";
  15722. import { Particle } from "babylonjs/Particles/particle";
  15723. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15724. /**
  15725. * Particle emitter emitting particles from the inside of a cone.
  15726. * It emits the particles alongside the cone volume from the base to the particle.
  15727. * The emission direction might be randomized.
  15728. */
  15729. export class ConeParticleEmitter implements IParticleEmitterType {
  15730. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15731. directionRandomizer: number;
  15732. private _radius;
  15733. private _angle;
  15734. private _height;
  15735. /**
  15736. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15737. */
  15738. radiusRange: number;
  15739. /**
  15740. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15741. */
  15742. heightRange: number;
  15743. /**
  15744. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15745. */
  15746. emitFromSpawnPointOnly: boolean;
  15747. /**
  15748. * Gets or sets the radius of the emission cone
  15749. */
  15750. radius: number;
  15751. /**
  15752. * Gets or sets the angle of the emission cone
  15753. */
  15754. angle: number;
  15755. private _buildHeight;
  15756. /**
  15757. * Creates a new instance ConeParticleEmitter
  15758. * @param radius the radius of the emission cone (1 by default)
  15759. * @param angle the cone base angle (PI by default)
  15760. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15761. */
  15762. constructor(radius?: number, angle?: number,
  15763. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15764. directionRandomizer?: number);
  15765. /**
  15766. * Called by the particle System when the direction is computed for the created particle.
  15767. * @param worldMatrix is the world matrix of the particle system
  15768. * @param directionToUpdate is the direction vector to update with the result
  15769. * @param particle is the particle we are computed the direction for
  15770. */
  15771. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15772. /**
  15773. * Called by the particle System when the position is computed for the created particle.
  15774. * @param worldMatrix is the world matrix of the particle system
  15775. * @param positionToUpdate is the position vector to update with the result
  15776. * @param particle is the particle we are computed the position for
  15777. */
  15778. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15779. /**
  15780. * Clones the current emitter and returns a copy of it
  15781. * @returns the new emitter
  15782. */
  15783. clone(): ConeParticleEmitter;
  15784. /**
  15785. * Called by the GPUParticleSystem to setup the update shader
  15786. * @param effect defines the update shader
  15787. */
  15788. applyToShader(effect: Effect): void;
  15789. /**
  15790. * Returns a string to use to update the GPU particles update shader
  15791. * @returns a string containng the defines string
  15792. */
  15793. getEffectDefines(): string;
  15794. /**
  15795. * Returns the string "ConeParticleEmitter"
  15796. * @returns a string containing the class name
  15797. */
  15798. getClassName(): string;
  15799. /**
  15800. * Serializes the particle system to a JSON object.
  15801. * @returns the JSON object
  15802. */
  15803. serialize(): any;
  15804. /**
  15805. * Parse properties from a JSON object
  15806. * @param serializationObject defines the JSON object
  15807. */
  15808. parse(serializationObject: any): void;
  15809. }
  15810. }
  15811. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  15812. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15813. import { Effect } from "babylonjs/Materials/effect";
  15814. import { Particle } from "babylonjs/Particles/particle";
  15815. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15816. /**
  15817. * Particle emitter emitting particles from the inside of a cylinder.
  15818. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15819. */
  15820. export class CylinderParticleEmitter implements IParticleEmitterType {
  15821. /**
  15822. * The radius of the emission cylinder.
  15823. */
  15824. radius: number;
  15825. /**
  15826. * The height of the emission cylinder.
  15827. */
  15828. height: number;
  15829. /**
  15830. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15831. */
  15832. radiusRange: number;
  15833. /**
  15834. * How much to randomize the particle direction [0-1].
  15835. */
  15836. directionRandomizer: number;
  15837. /**
  15838. * Creates a new instance CylinderParticleEmitter
  15839. * @param radius the radius of the emission cylinder (1 by default)
  15840. * @param height the height of the emission cylinder (1 by default)
  15841. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15842. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15843. */
  15844. constructor(
  15845. /**
  15846. * The radius of the emission cylinder.
  15847. */
  15848. radius?: number,
  15849. /**
  15850. * The height of the emission cylinder.
  15851. */
  15852. height?: number,
  15853. /**
  15854. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15855. */
  15856. radiusRange?: number,
  15857. /**
  15858. * How much to randomize the particle direction [0-1].
  15859. */
  15860. directionRandomizer?: number);
  15861. /**
  15862. * Called by the particle System when the direction is computed for the created particle.
  15863. * @param worldMatrix is the world matrix of the particle system
  15864. * @param directionToUpdate is the direction vector to update with the result
  15865. * @param particle is the particle we are computed the direction for
  15866. */
  15867. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15868. /**
  15869. * Called by the particle System when the position is computed for the created particle.
  15870. * @param worldMatrix is the world matrix of the particle system
  15871. * @param positionToUpdate is the position vector to update with the result
  15872. * @param particle is the particle we are computed the position for
  15873. */
  15874. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15875. /**
  15876. * Clones the current emitter and returns a copy of it
  15877. * @returns the new emitter
  15878. */
  15879. clone(): CylinderParticleEmitter;
  15880. /**
  15881. * Called by the GPUParticleSystem to setup the update shader
  15882. * @param effect defines the update shader
  15883. */
  15884. applyToShader(effect: Effect): void;
  15885. /**
  15886. * Returns a string to use to update the GPU particles update shader
  15887. * @returns a string containng the defines string
  15888. */
  15889. getEffectDefines(): string;
  15890. /**
  15891. * Returns the string "CylinderParticleEmitter"
  15892. * @returns a string containing the class name
  15893. */
  15894. getClassName(): string;
  15895. /**
  15896. * Serializes the particle system to a JSON object.
  15897. * @returns the JSON object
  15898. */
  15899. serialize(): any;
  15900. /**
  15901. * Parse properties from a JSON object
  15902. * @param serializationObject defines the JSON object
  15903. */
  15904. parse(serializationObject: any): void;
  15905. }
  15906. /**
  15907. * Particle emitter emitting particles from the inside of a cylinder.
  15908. * It emits the particles randomly between two vectors.
  15909. */
  15910. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15911. /**
  15912. * The min limit of the emission direction.
  15913. */
  15914. direction1: Vector3;
  15915. /**
  15916. * The max limit of the emission direction.
  15917. */
  15918. direction2: Vector3;
  15919. /**
  15920. * Creates a new instance CylinderDirectedParticleEmitter
  15921. * @param radius the radius of the emission cylinder (1 by default)
  15922. * @param height the height of the emission cylinder (1 by default)
  15923. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15924. * @param direction1 the min limit of the emission direction (up vector by default)
  15925. * @param direction2 the max limit of the emission direction (up vector by default)
  15926. */
  15927. constructor(radius?: number, height?: number, radiusRange?: number,
  15928. /**
  15929. * The min limit of the emission direction.
  15930. */
  15931. direction1?: Vector3,
  15932. /**
  15933. * The max limit of the emission direction.
  15934. */
  15935. direction2?: Vector3);
  15936. /**
  15937. * Called by the particle System when the direction is computed for the created particle.
  15938. * @param worldMatrix is the world matrix of the particle system
  15939. * @param directionToUpdate is the direction vector to update with the result
  15940. * @param particle is the particle we are computed the direction for
  15941. */
  15942. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15943. /**
  15944. * Clones the current emitter and returns a copy of it
  15945. * @returns the new emitter
  15946. */
  15947. clone(): CylinderDirectedParticleEmitter;
  15948. /**
  15949. * Called by the GPUParticleSystem to setup the update shader
  15950. * @param effect defines the update shader
  15951. */
  15952. applyToShader(effect: Effect): void;
  15953. /**
  15954. * Returns a string to use to update the GPU particles update shader
  15955. * @returns a string containng the defines string
  15956. */
  15957. getEffectDefines(): string;
  15958. /**
  15959. * Returns the string "CylinderDirectedParticleEmitter"
  15960. * @returns a string containing the class name
  15961. */
  15962. getClassName(): string;
  15963. /**
  15964. * Serializes the particle system to a JSON object.
  15965. * @returns the JSON object
  15966. */
  15967. serialize(): any;
  15968. /**
  15969. * Parse properties from a JSON object
  15970. * @param serializationObject defines the JSON object
  15971. */
  15972. parse(serializationObject: any): void;
  15973. }
  15974. }
  15975. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  15976. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15977. import { Effect } from "babylonjs/Materials/effect";
  15978. import { Particle } from "babylonjs/Particles/particle";
  15979. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15980. /**
  15981. * Particle emitter emitting particles from the inside of a hemisphere.
  15982. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15983. */
  15984. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15985. /**
  15986. * The radius of the emission hemisphere.
  15987. */
  15988. radius: number;
  15989. /**
  15990. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15991. */
  15992. radiusRange: number;
  15993. /**
  15994. * How much to randomize the particle direction [0-1].
  15995. */
  15996. directionRandomizer: number;
  15997. /**
  15998. * Creates a new instance HemisphericParticleEmitter
  15999. * @param radius the radius of the emission hemisphere (1 by default)
  16000. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16001. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16002. */
  16003. constructor(
  16004. /**
  16005. * The radius of the emission hemisphere.
  16006. */
  16007. radius?: number,
  16008. /**
  16009. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16010. */
  16011. radiusRange?: number,
  16012. /**
  16013. * How much to randomize the particle direction [0-1].
  16014. */
  16015. directionRandomizer?: number);
  16016. /**
  16017. * Called by the particle System when the direction is computed for the created particle.
  16018. * @param worldMatrix is the world matrix of the particle system
  16019. * @param directionToUpdate is the direction vector to update with the result
  16020. * @param particle is the particle we are computed the direction for
  16021. */
  16022. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16023. /**
  16024. * Called by the particle System when the position is computed for the created particle.
  16025. * @param worldMatrix is the world matrix of the particle system
  16026. * @param positionToUpdate is the position vector to update with the result
  16027. * @param particle is the particle we are computed the position for
  16028. */
  16029. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16030. /**
  16031. * Clones the current emitter and returns a copy of it
  16032. * @returns the new emitter
  16033. */
  16034. clone(): HemisphericParticleEmitter;
  16035. /**
  16036. * Called by the GPUParticleSystem to setup the update shader
  16037. * @param effect defines the update shader
  16038. */
  16039. applyToShader(effect: Effect): void;
  16040. /**
  16041. * Returns a string to use to update the GPU particles update shader
  16042. * @returns a string containng the defines string
  16043. */
  16044. getEffectDefines(): string;
  16045. /**
  16046. * Returns the string "HemisphericParticleEmitter"
  16047. * @returns a string containing the class name
  16048. */
  16049. getClassName(): string;
  16050. /**
  16051. * Serializes the particle system to a JSON object.
  16052. * @returns the JSON object
  16053. */
  16054. serialize(): any;
  16055. /**
  16056. * Parse properties from a JSON object
  16057. * @param serializationObject defines the JSON object
  16058. */
  16059. parse(serializationObject: any): void;
  16060. }
  16061. }
  16062. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  16063. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16064. import { Effect } from "babylonjs/Materials/effect";
  16065. import { Particle } from "babylonjs/Particles/particle";
  16066. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16067. /**
  16068. * Particle emitter emitting particles from a point.
  16069. * It emits the particles randomly between 2 given directions.
  16070. */
  16071. export class PointParticleEmitter implements IParticleEmitterType {
  16072. /**
  16073. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16074. */
  16075. direction1: Vector3;
  16076. /**
  16077. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16078. */
  16079. direction2: Vector3;
  16080. /**
  16081. * Creates a new instance PointParticleEmitter
  16082. */
  16083. constructor();
  16084. /**
  16085. * Called by the particle System when the direction is computed for the created particle.
  16086. * @param worldMatrix is the world matrix of the particle system
  16087. * @param directionToUpdate is the direction vector to update with the result
  16088. * @param particle is the particle we are computed the direction for
  16089. */
  16090. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16091. /**
  16092. * Called by the particle System when the position is computed for the created particle.
  16093. * @param worldMatrix is the world matrix of the particle system
  16094. * @param positionToUpdate is the position vector to update with the result
  16095. * @param particle is the particle we are computed the position for
  16096. */
  16097. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16098. /**
  16099. * Clones the current emitter and returns a copy of it
  16100. * @returns the new emitter
  16101. */
  16102. clone(): PointParticleEmitter;
  16103. /**
  16104. * Called by the GPUParticleSystem to setup the update shader
  16105. * @param effect defines the update shader
  16106. */
  16107. applyToShader(effect: Effect): void;
  16108. /**
  16109. * Returns a string to use to update the GPU particles update shader
  16110. * @returns a string containng the defines string
  16111. */
  16112. getEffectDefines(): string;
  16113. /**
  16114. * Returns the string "PointParticleEmitter"
  16115. * @returns a string containing the class name
  16116. */
  16117. getClassName(): string;
  16118. /**
  16119. * Serializes the particle system to a JSON object.
  16120. * @returns the JSON object
  16121. */
  16122. serialize(): any;
  16123. /**
  16124. * Parse properties from a JSON object
  16125. * @param serializationObject defines the JSON object
  16126. */
  16127. parse(serializationObject: any): void;
  16128. }
  16129. }
  16130. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  16131. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16132. import { Effect } from "babylonjs/Materials/effect";
  16133. import { Particle } from "babylonjs/Particles/particle";
  16134. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16135. /**
  16136. * Particle emitter emitting particles from the inside of a sphere.
  16137. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16138. */
  16139. export class SphereParticleEmitter implements IParticleEmitterType {
  16140. /**
  16141. * The radius of the emission sphere.
  16142. */
  16143. radius: number;
  16144. /**
  16145. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16146. */
  16147. radiusRange: number;
  16148. /**
  16149. * How much to randomize the particle direction [0-1].
  16150. */
  16151. directionRandomizer: number;
  16152. /**
  16153. * Creates a new instance SphereParticleEmitter
  16154. * @param radius the radius of the emission sphere (1 by default)
  16155. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16156. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16157. */
  16158. constructor(
  16159. /**
  16160. * The radius of the emission sphere.
  16161. */
  16162. radius?: number,
  16163. /**
  16164. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16165. */
  16166. radiusRange?: number,
  16167. /**
  16168. * How much to randomize the particle direction [0-1].
  16169. */
  16170. directionRandomizer?: number);
  16171. /**
  16172. * Called by the particle System when the direction is computed for the created particle.
  16173. * @param worldMatrix is the world matrix of the particle system
  16174. * @param directionToUpdate is the direction vector to update with the result
  16175. * @param particle is the particle we are computed the direction for
  16176. */
  16177. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16178. /**
  16179. * Called by the particle System when the position is computed for the created particle.
  16180. * @param worldMatrix is the world matrix of the particle system
  16181. * @param positionToUpdate is the position vector to update with the result
  16182. * @param particle is the particle we are computed the position for
  16183. */
  16184. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16185. /**
  16186. * Clones the current emitter and returns a copy of it
  16187. * @returns the new emitter
  16188. */
  16189. clone(): SphereParticleEmitter;
  16190. /**
  16191. * Called by the GPUParticleSystem to setup the update shader
  16192. * @param effect defines the update shader
  16193. */
  16194. applyToShader(effect: Effect): void;
  16195. /**
  16196. * Returns a string to use to update the GPU particles update shader
  16197. * @returns a string containng the defines string
  16198. */
  16199. getEffectDefines(): string;
  16200. /**
  16201. * Returns the string "SphereParticleEmitter"
  16202. * @returns a string containing the class name
  16203. */
  16204. getClassName(): string;
  16205. /**
  16206. * Serializes the particle system to a JSON object.
  16207. * @returns the JSON object
  16208. */
  16209. serialize(): any;
  16210. /**
  16211. * Parse properties from a JSON object
  16212. * @param serializationObject defines the JSON object
  16213. */
  16214. parse(serializationObject: any): void;
  16215. }
  16216. /**
  16217. * Particle emitter emitting particles from the inside of a sphere.
  16218. * It emits the particles randomly between two vectors.
  16219. */
  16220. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16221. /**
  16222. * The min limit of the emission direction.
  16223. */
  16224. direction1: Vector3;
  16225. /**
  16226. * The max limit of the emission direction.
  16227. */
  16228. direction2: Vector3;
  16229. /**
  16230. * Creates a new instance SphereDirectedParticleEmitter
  16231. * @param radius the radius of the emission sphere (1 by default)
  16232. * @param direction1 the min limit of the emission direction (up vector by default)
  16233. * @param direction2 the max limit of the emission direction (up vector by default)
  16234. */
  16235. constructor(radius?: number,
  16236. /**
  16237. * The min limit of the emission direction.
  16238. */
  16239. direction1?: Vector3,
  16240. /**
  16241. * The max limit of the emission direction.
  16242. */
  16243. direction2?: Vector3);
  16244. /**
  16245. * Called by the particle System when the direction is computed for the created particle.
  16246. * @param worldMatrix is the world matrix of the particle system
  16247. * @param directionToUpdate is the direction vector to update with the result
  16248. * @param particle is the particle we are computed the direction for
  16249. */
  16250. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16251. /**
  16252. * Clones the current emitter and returns a copy of it
  16253. * @returns the new emitter
  16254. */
  16255. clone(): SphereDirectedParticleEmitter;
  16256. /**
  16257. * Called by the GPUParticleSystem to setup the update shader
  16258. * @param effect defines the update shader
  16259. */
  16260. applyToShader(effect: Effect): void;
  16261. /**
  16262. * Returns a string to use to update the GPU particles update shader
  16263. * @returns a string containng the defines string
  16264. */
  16265. getEffectDefines(): string;
  16266. /**
  16267. * Returns the string "SphereDirectedParticleEmitter"
  16268. * @returns a string containing the class name
  16269. */
  16270. getClassName(): string;
  16271. /**
  16272. * Serializes the particle system to a JSON object.
  16273. * @returns the JSON object
  16274. */
  16275. serialize(): any;
  16276. /**
  16277. * Parse properties from a JSON object
  16278. * @param serializationObject defines the JSON object
  16279. */
  16280. parse(serializationObject: any): void;
  16281. }
  16282. }
  16283. declare module "babylonjs/Particles/EmitterTypes/index" {
  16284. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  16285. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  16286. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  16287. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  16288. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16289. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  16290. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  16291. }
  16292. declare module "babylonjs/Particles/IParticleSystem" {
  16293. import { Nullable } from "babylonjs/types";
  16294. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  16295. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16296. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16297. import { Texture } from "babylonjs/Materials/Textures/texture";
  16298. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16299. import { Scene } from "babylonjs/scene";
  16300. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  16301. import { Animation } from "babylonjs/Animations/animation";
  16302. /**
  16303. * Interface representing a particle system in Babylon.js.
  16304. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16305. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16306. */
  16307. export interface IParticleSystem {
  16308. /**
  16309. * List of animations used by the particle system.
  16310. */
  16311. animations: Animation[];
  16312. /**
  16313. * The id of the Particle system.
  16314. */
  16315. id: string;
  16316. /**
  16317. * The name of the Particle system.
  16318. */
  16319. name: string;
  16320. /**
  16321. * The emitter represents the Mesh or position we are attaching the particle system to.
  16322. */
  16323. emitter: Nullable<AbstractMesh | Vector3>;
  16324. /**
  16325. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16326. */
  16327. isBillboardBased: boolean;
  16328. /**
  16329. * The rendering group used by the Particle system to chose when to render.
  16330. */
  16331. renderingGroupId: number;
  16332. /**
  16333. * The layer mask we are rendering the particles through.
  16334. */
  16335. layerMask: number;
  16336. /**
  16337. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16338. */
  16339. updateSpeed: number;
  16340. /**
  16341. * The amount of time the particle system is running (depends of the overall update speed).
  16342. */
  16343. targetStopDuration: number;
  16344. /**
  16345. * The texture used to render each particle. (this can be a spritesheet)
  16346. */
  16347. particleTexture: Nullable<Texture>;
  16348. /**
  16349. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16350. */
  16351. blendMode: number;
  16352. /**
  16353. * Minimum life time of emitting particles.
  16354. */
  16355. minLifeTime: number;
  16356. /**
  16357. * Maximum life time of emitting particles.
  16358. */
  16359. maxLifeTime: number;
  16360. /**
  16361. * Minimum Size of emitting particles.
  16362. */
  16363. minSize: number;
  16364. /**
  16365. * Maximum Size of emitting particles.
  16366. */
  16367. maxSize: number;
  16368. /**
  16369. * Minimum scale of emitting particles on X axis.
  16370. */
  16371. minScaleX: number;
  16372. /**
  16373. * Maximum scale of emitting particles on X axis.
  16374. */
  16375. maxScaleX: number;
  16376. /**
  16377. * Minimum scale of emitting particles on Y axis.
  16378. */
  16379. minScaleY: number;
  16380. /**
  16381. * Maximum scale of emitting particles on Y axis.
  16382. */
  16383. maxScaleY: number;
  16384. /**
  16385. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16386. */
  16387. color1: Color4;
  16388. /**
  16389. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16390. */
  16391. color2: Color4;
  16392. /**
  16393. * Color the particle will have at the end of its lifetime.
  16394. */
  16395. colorDead: Color4;
  16396. /**
  16397. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16398. */
  16399. emitRate: number;
  16400. /**
  16401. * You can use gravity if you want to give an orientation to your particles.
  16402. */
  16403. gravity: Vector3;
  16404. /**
  16405. * Minimum power of emitting particles.
  16406. */
  16407. minEmitPower: number;
  16408. /**
  16409. * Maximum power of emitting particles.
  16410. */
  16411. maxEmitPower: number;
  16412. /**
  16413. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16414. */
  16415. minAngularSpeed: number;
  16416. /**
  16417. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16418. */
  16419. maxAngularSpeed: number;
  16420. /**
  16421. * Gets or sets the minimal initial rotation in radians.
  16422. */
  16423. minInitialRotation: number;
  16424. /**
  16425. * Gets or sets the maximal initial rotation in radians.
  16426. */
  16427. maxInitialRotation: number;
  16428. /**
  16429. * The particle emitter type defines the emitter used by the particle system.
  16430. * It can be for example box, sphere, or cone...
  16431. */
  16432. particleEmitterType: Nullable<IParticleEmitterType>;
  16433. /**
  16434. * Defines the delay in milliseconds before starting the system (0 by default)
  16435. */
  16436. startDelay: number;
  16437. /**
  16438. * 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
  16439. */
  16440. preWarmCycles: number;
  16441. /**
  16442. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16443. */
  16444. preWarmStepOffset: number;
  16445. /**
  16446. * 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)
  16447. */
  16448. spriteCellChangeSpeed: number;
  16449. /**
  16450. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16451. */
  16452. startSpriteCellID: number;
  16453. /**
  16454. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16455. */
  16456. endSpriteCellID: number;
  16457. /**
  16458. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16459. */
  16460. spriteCellWidth: number;
  16461. /**
  16462. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16463. */
  16464. spriteCellHeight: number;
  16465. /**
  16466. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16467. */
  16468. spriteRandomStartCell: boolean;
  16469. /**
  16470. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16471. */
  16472. isAnimationSheetEnabled: boolean;
  16473. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16474. translationPivot: Vector2;
  16475. /**
  16476. * Gets or sets a texture used to add random noise to particle positions
  16477. */
  16478. noiseTexture: Nullable<BaseTexture>;
  16479. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16480. noiseStrength: Vector3;
  16481. /**
  16482. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16483. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16484. */
  16485. billboardMode: number;
  16486. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16487. limitVelocityDamping: number;
  16488. /**
  16489. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16490. */
  16491. beginAnimationOnStart: boolean;
  16492. /**
  16493. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16494. */
  16495. beginAnimationFrom: number;
  16496. /**
  16497. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16498. */
  16499. beginAnimationTo: number;
  16500. /**
  16501. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16502. */
  16503. beginAnimationLoop: boolean;
  16504. /**
  16505. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16506. */
  16507. disposeOnStop: boolean;
  16508. /**
  16509. * Gets the maximum number of particles active at the same time.
  16510. * @returns The max number of active particles.
  16511. */
  16512. getCapacity(): number;
  16513. /**
  16514. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16515. * @returns True if it has been started, otherwise false.
  16516. */
  16517. isStarted(): boolean;
  16518. /**
  16519. * Animates the particle system for this frame.
  16520. */
  16521. animate(): void;
  16522. /**
  16523. * Renders the particle system in its current state.
  16524. * @returns the current number of particles
  16525. */
  16526. render(): number;
  16527. /**
  16528. * Dispose the particle system and frees its associated resources.
  16529. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16530. */
  16531. dispose(disposeTexture?: boolean): void;
  16532. /**
  16533. * Clones the particle system.
  16534. * @param name The name of the cloned object
  16535. * @param newEmitter The new emitter to use
  16536. * @returns the cloned particle system
  16537. */
  16538. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16539. /**
  16540. * Serializes the particle system to a JSON object.
  16541. * @returns the JSON object
  16542. */
  16543. serialize(): any;
  16544. /**
  16545. * Rebuild the particle system
  16546. */
  16547. rebuild(): void;
  16548. /**
  16549. * Starts the particle system and begins to emit
  16550. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16551. */
  16552. start(delay?: number): void;
  16553. /**
  16554. * Stops the particle system.
  16555. */
  16556. stop(): void;
  16557. /**
  16558. * Remove all active particles
  16559. */
  16560. reset(): void;
  16561. /**
  16562. * Is this system ready to be used/rendered
  16563. * @return true if the system is ready
  16564. */
  16565. isReady(): boolean;
  16566. /**
  16567. * Adds a new color gradient
  16568. * @param gradient defines the gradient to use (between 0 and 1)
  16569. * @param color1 defines the color to affect to the specified gradient
  16570. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16571. * @returns the current particle system
  16572. */
  16573. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16574. /**
  16575. * Remove a specific color gradient
  16576. * @param gradient defines the gradient to remove
  16577. * @returns the current particle system
  16578. */
  16579. removeColorGradient(gradient: number): IParticleSystem;
  16580. /**
  16581. * Adds a new size gradient
  16582. * @param gradient defines the gradient to use (between 0 and 1)
  16583. * @param factor defines the size factor to affect to the specified gradient
  16584. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16585. * @returns the current particle system
  16586. */
  16587. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16588. /**
  16589. * Remove a specific size gradient
  16590. * @param gradient defines the gradient to remove
  16591. * @returns the current particle system
  16592. */
  16593. removeSizeGradient(gradient: number): IParticleSystem;
  16594. /**
  16595. * Gets the current list of color gradients.
  16596. * You must use addColorGradient and removeColorGradient to udpate this list
  16597. * @returns the list of color gradients
  16598. */
  16599. getColorGradients(): Nullable<Array<ColorGradient>>;
  16600. /**
  16601. * Gets the current list of size gradients.
  16602. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16603. * @returns the list of size gradients
  16604. */
  16605. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16606. /**
  16607. * Gets the current list of angular speed gradients.
  16608. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16609. * @returns the list of angular speed gradients
  16610. */
  16611. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16612. /**
  16613. * Adds a new angular speed gradient
  16614. * @param gradient defines the gradient to use (between 0 and 1)
  16615. * @param factor defines the angular speed to affect to the specified gradient
  16616. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16617. * @returns the current particle system
  16618. */
  16619. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16620. /**
  16621. * Remove a specific angular speed gradient
  16622. * @param gradient defines the gradient to remove
  16623. * @returns the current particle system
  16624. */
  16625. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16626. /**
  16627. * Gets the current list of velocity gradients.
  16628. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16629. * @returns the list of velocity gradients
  16630. */
  16631. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16632. /**
  16633. * Adds a new velocity gradient
  16634. * @param gradient defines the gradient to use (between 0 and 1)
  16635. * @param factor defines the velocity to affect to the specified gradient
  16636. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16637. * @returns the current particle system
  16638. */
  16639. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16640. /**
  16641. * Remove a specific velocity gradient
  16642. * @param gradient defines the gradient to remove
  16643. * @returns the current particle system
  16644. */
  16645. removeVelocityGradient(gradient: number): IParticleSystem;
  16646. /**
  16647. * Gets the current list of limit velocity gradients.
  16648. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16649. * @returns the list of limit velocity gradients
  16650. */
  16651. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16652. /**
  16653. * Adds a new limit velocity gradient
  16654. * @param gradient defines the gradient to use (between 0 and 1)
  16655. * @param factor defines the limit velocity to affect to the specified gradient
  16656. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16657. * @returns the current particle system
  16658. */
  16659. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16660. /**
  16661. * Remove a specific limit velocity gradient
  16662. * @param gradient defines the gradient to remove
  16663. * @returns the current particle system
  16664. */
  16665. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16666. /**
  16667. * Adds a new drag gradient
  16668. * @param gradient defines the gradient to use (between 0 and 1)
  16669. * @param factor defines the drag to affect to the specified gradient
  16670. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16671. * @returns the current particle system
  16672. */
  16673. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16674. /**
  16675. * Remove a specific drag gradient
  16676. * @param gradient defines the gradient to remove
  16677. * @returns the current particle system
  16678. */
  16679. removeDragGradient(gradient: number): IParticleSystem;
  16680. /**
  16681. * Gets the current list of drag gradients.
  16682. * You must use addDragGradient and removeDragGradient to udpate this list
  16683. * @returns the list of drag gradients
  16684. */
  16685. getDragGradients(): Nullable<Array<FactorGradient>>;
  16686. /**
  16687. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16688. * @param gradient defines the gradient to use (between 0 and 1)
  16689. * @param factor defines the emit rate to affect to the specified gradient
  16690. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16691. * @returns the current particle system
  16692. */
  16693. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16694. /**
  16695. * Remove a specific emit rate gradient
  16696. * @param gradient defines the gradient to remove
  16697. * @returns the current particle system
  16698. */
  16699. removeEmitRateGradient(gradient: number): IParticleSystem;
  16700. /**
  16701. * Gets the current list of emit rate gradients.
  16702. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16703. * @returns the list of emit rate gradients
  16704. */
  16705. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16706. /**
  16707. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16708. * @param gradient defines the gradient to use (between 0 and 1)
  16709. * @param factor defines the start size to affect to the specified gradient
  16710. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16711. * @returns the current particle system
  16712. */
  16713. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16714. /**
  16715. * Remove a specific start size gradient
  16716. * @param gradient defines the gradient to remove
  16717. * @returns the current particle system
  16718. */
  16719. removeStartSizeGradient(gradient: number): IParticleSystem;
  16720. /**
  16721. * Gets the current list of start size gradients.
  16722. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16723. * @returns the list of start size gradients
  16724. */
  16725. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16726. /**
  16727. * Adds a new life time gradient
  16728. * @param gradient defines the gradient to use (between 0 and 1)
  16729. * @param factor defines the life time factor to affect to the specified gradient
  16730. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16731. * @returns the current particle system
  16732. */
  16733. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16734. /**
  16735. * Remove a specific life time gradient
  16736. * @param gradient defines the gradient to remove
  16737. * @returns the current particle system
  16738. */
  16739. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16740. /**
  16741. * Gets the current list of life time gradients.
  16742. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16743. * @returns the list of life time gradients
  16744. */
  16745. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16746. /**
  16747. * Gets the current list of color gradients.
  16748. * You must use addColorGradient and removeColorGradient to udpate this list
  16749. * @returns the list of color gradients
  16750. */
  16751. getColorGradients(): Nullable<Array<ColorGradient>>;
  16752. /**
  16753. * Adds a new ramp gradient used to remap particle colors
  16754. * @param gradient defines the gradient to use (between 0 and 1)
  16755. * @param color defines the color to affect to the specified gradient
  16756. * @returns the current particle system
  16757. */
  16758. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16759. /**
  16760. * Gets the current list of ramp gradients.
  16761. * You must use addRampGradient and removeRampGradient to udpate this list
  16762. * @returns the list of ramp gradients
  16763. */
  16764. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16765. /** Gets or sets a boolean indicating that ramp gradients must be used
  16766. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16767. */
  16768. useRampGradients: boolean;
  16769. /**
  16770. * Adds a new color remap gradient
  16771. * @param gradient defines the gradient to use (between 0 and 1)
  16772. * @param min defines the color remap minimal range
  16773. * @param max defines the color remap maximal range
  16774. * @returns the current particle system
  16775. */
  16776. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16777. /**
  16778. * Gets the current list of color remap gradients.
  16779. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16780. * @returns the list of color remap gradients
  16781. */
  16782. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16783. /**
  16784. * Adds a new alpha remap gradient
  16785. * @param gradient defines the gradient to use (between 0 and 1)
  16786. * @param min defines the alpha remap minimal range
  16787. * @param max defines the alpha remap maximal range
  16788. * @returns the current particle system
  16789. */
  16790. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16791. /**
  16792. * Gets the current list of alpha remap gradients.
  16793. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16794. * @returns the list of alpha remap gradients
  16795. */
  16796. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16797. /**
  16798. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16799. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16800. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16801. * @returns the emitter
  16802. */
  16803. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16804. /**
  16805. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16806. * @param radius The radius of the hemisphere to emit from
  16807. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16808. * @returns the emitter
  16809. */
  16810. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16811. /**
  16812. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16813. * @param radius The radius of the sphere to emit from
  16814. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16815. * @returns the emitter
  16816. */
  16817. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16818. /**
  16819. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16820. * @param radius The radius of the sphere to emit from
  16821. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16822. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16823. * @returns the emitter
  16824. */
  16825. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16826. /**
  16827. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16828. * @param radius The radius of the emission cylinder
  16829. * @param height The height of the emission cylinder
  16830. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16831. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16832. * @returns the emitter
  16833. */
  16834. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16835. /**
  16836. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16837. * @param radius The radius of the cylinder to emit from
  16838. * @param height The height of the emission cylinder
  16839. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16840. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16841. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16842. * @returns the emitter
  16843. */
  16844. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16845. /**
  16846. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16847. * @param radius The radius of the cone to emit from
  16848. * @param angle The base angle of the cone
  16849. * @returns the emitter
  16850. */
  16851. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16852. /**
  16853. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16854. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16855. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16856. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16857. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16858. * @returns the emitter
  16859. */
  16860. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16861. /**
  16862. * Get hosting scene
  16863. * @returns the scene
  16864. */
  16865. getScene(): Scene;
  16866. }
  16867. }
  16868. declare module "babylonjs/Meshes/instancedMesh" {
  16869. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16870. import { Vector3 } from "babylonjs/Maths/math";
  16871. import { Camera } from "babylonjs/Cameras/camera";
  16872. import { Node } from "babylonjs/node";
  16873. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16874. import { Mesh } from "babylonjs/Meshes/mesh";
  16875. import { Material } from "babylonjs/Materials/material";
  16876. import { Skeleton } from "babylonjs/Bones/skeleton";
  16877. /**
  16878. * Creates an instance based on a source mesh.
  16879. */
  16880. export class InstancedMesh extends AbstractMesh {
  16881. private _sourceMesh;
  16882. private _currentLOD;
  16883. /** @hidden */
  16884. _indexInSourceMeshInstanceArray: number;
  16885. constructor(name: string, source: Mesh);
  16886. /**
  16887. * Returns the string "InstancedMesh".
  16888. */
  16889. getClassName(): string;
  16890. /**
  16891. * If the source mesh receives shadows
  16892. */
  16893. readonly receiveShadows: boolean;
  16894. /**
  16895. * The material of the source mesh
  16896. */
  16897. readonly material: Nullable<Material>;
  16898. /**
  16899. * Visibility of the source mesh
  16900. */
  16901. readonly visibility: number;
  16902. /**
  16903. * Skeleton of the source mesh
  16904. */
  16905. readonly skeleton: Nullable<Skeleton>;
  16906. /**
  16907. * Rendering ground id of the source mesh
  16908. */
  16909. renderingGroupId: number;
  16910. /**
  16911. * Returns the total number of vertices (integer).
  16912. */
  16913. getTotalVertices(): number;
  16914. /**
  16915. * Returns a positive integer : the total number of indices in this mesh geometry.
  16916. * @returns the numner of indices or zero if the mesh has no geometry.
  16917. */
  16918. getTotalIndices(): number;
  16919. /**
  16920. * The source mesh of the instance
  16921. */
  16922. readonly sourceMesh: Mesh;
  16923. /**
  16924. * Is this node ready to be used/rendered
  16925. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16926. * @return {boolean} is it ready
  16927. */
  16928. isReady(completeCheck?: boolean): boolean;
  16929. /**
  16930. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16931. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16932. * @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.
  16933. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16934. */
  16935. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16936. /**
  16937. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16938. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16939. * The `data` are either a numeric array either a Float32Array.
  16940. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16941. * 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).
  16942. * Note that a new underlying VertexBuffer object is created each call.
  16943. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16944. *
  16945. * Possible `kind` values :
  16946. * - VertexBuffer.PositionKind
  16947. * - VertexBuffer.UVKind
  16948. * - VertexBuffer.UV2Kind
  16949. * - VertexBuffer.UV3Kind
  16950. * - VertexBuffer.UV4Kind
  16951. * - VertexBuffer.UV5Kind
  16952. * - VertexBuffer.UV6Kind
  16953. * - VertexBuffer.ColorKind
  16954. * - VertexBuffer.MatricesIndicesKind
  16955. * - VertexBuffer.MatricesIndicesExtraKind
  16956. * - VertexBuffer.MatricesWeightsKind
  16957. * - VertexBuffer.MatricesWeightsExtraKind
  16958. *
  16959. * Returns the Mesh.
  16960. */
  16961. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16962. /**
  16963. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16964. * If the mesh has no geometry, it is simply returned as it is.
  16965. * The `data` are either a numeric array either a Float32Array.
  16966. * No new underlying VertexBuffer object is created.
  16967. * 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.
  16968. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16969. *
  16970. * Possible `kind` values :
  16971. * - VertexBuffer.PositionKind
  16972. * - VertexBuffer.UVKind
  16973. * - VertexBuffer.UV2Kind
  16974. * - VertexBuffer.UV3Kind
  16975. * - VertexBuffer.UV4Kind
  16976. * - VertexBuffer.UV5Kind
  16977. * - VertexBuffer.UV6Kind
  16978. * - VertexBuffer.ColorKind
  16979. * - VertexBuffer.MatricesIndicesKind
  16980. * - VertexBuffer.MatricesIndicesExtraKind
  16981. * - VertexBuffer.MatricesWeightsKind
  16982. * - VertexBuffer.MatricesWeightsExtraKind
  16983. *
  16984. * Returns the Mesh.
  16985. */
  16986. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16987. /**
  16988. * Sets the mesh indices.
  16989. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16990. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16991. * This method creates a new index buffer each call.
  16992. * Returns the Mesh.
  16993. */
  16994. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16995. /**
  16996. * Boolean : True if the mesh owns the requested kind of data.
  16997. */
  16998. isVerticesDataPresent(kind: string): boolean;
  16999. /**
  17000. * Returns an array of indices (IndicesArray).
  17001. */
  17002. getIndices(): Nullable<IndicesArray>;
  17003. readonly _positions: Nullable<Vector3[]>;
  17004. /**
  17005. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  17006. * This means the mesh underlying bounding box and sphere are recomputed.
  17007. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  17008. * @returns the current mesh
  17009. */
  17010. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  17011. /** @hidden */
  17012. _preActivate(): InstancedMesh;
  17013. /** @hidden */
  17014. _activate(renderId: number): boolean;
  17015. /**
  17016. * Returns the current associated LOD AbstractMesh.
  17017. */
  17018. getLOD(camera: Camera): AbstractMesh;
  17019. /** @hidden */
  17020. _syncSubMeshes(): InstancedMesh;
  17021. /** @hidden */
  17022. _generatePointsArray(): boolean;
  17023. /**
  17024. * Creates a new InstancedMesh from the current mesh.
  17025. * - name (string) : the cloned mesh name
  17026. * - newParent (optional Node) : the optional Node to parent the clone to.
  17027. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  17028. *
  17029. * Returns the clone.
  17030. */
  17031. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  17032. /**
  17033. * Disposes the InstancedMesh.
  17034. * Returns nothing.
  17035. */
  17036. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17037. }
  17038. }
  17039. declare module "babylonjs/Materials/shaderMaterial" {
  17040. import { Scene } from "babylonjs/scene";
  17041. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  17042. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17043. import { Mesh } from "babylonjs/Meshes/mesh";
  17044. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  17045. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17046. import { Texture } from "babylonjs/Materials/Textures/texture";
  17047. import { Material } from "babylonjs/Materials/material";
  17048. /**
  17049. * Defines the options associated with the creation of a shader material.
  17050. */
  17051. export interface IShaderMaterialOptions {
  17052. /**
  17053. * Does the material work in alpha blend mode
  17054. */
  17055. needAlphaBlending: boolean;
  17056. /**
  17057. * Does the material work in alpha test mode
  17058. */
  17059. needAlphaTesting: boolean;
  17060. /**
  17061. * The list of attribute names used in the shader
  17062. */
  17063. attributes: string[];
  17064. /**
  17065. * The list of unifrom names used in the shader
  17066. */
  17067. uniforms: string[];
  17068. /**
  17069. * The list of UBO names used in the shader
  17070. */
  17071. uniformBuffers: string[];
  17072. /**
  17073. * The list of sampler names used in the shader
  17074. */
  17075. samplers: string[];
  17076. /**
  17077. * The list of defines used in the shader
  17078. */
  17079. defines: string[];
  17080. }
  17081. /**
  17082. * 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.
  17083. *
  17084. * This returned material effects how the mesh will look based on the code in the shaders.
  17085. *
  17086. * @see http://doc.babylonjs.com/how_to/shader_material
  17087. */
  17088. export class ShaderMaterial extends Material {
  17089. private _shaderPath;
  17090. private _options;
  17091. private _textures;
  17092. private _textureArrays;
  17093. private _floats;
  17094. private _ints;
  17095. private _floatsArrays;
  17096. private _colors3;
  17097. private _colors3Arrays;
  17098. private _colors4;
  17099. private _vectors2;
  17100. private _vectors3;
  17101. private _vectors4;
  17102. private _matrices;
  17103. private _matrices3x3;
  17104. private _matrices2x2;
  17105. private _vectors2Arrays;
  17106. private _vectors3Arrays;
  17107. private _cachedWorldViewMatrix;
  17108. private _renderId;
  17109. /**
  17110. * Instantiate a new shader material.
  17111. * 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.
  17112. * This returned material effects how the mesh will look based on the code in the shaders.
  17113. * @see http://doc.babylonjs.com/how_to/shader_material
  17114. * @param name Define the name of the material in the scene
  17115. * @param scene Define the scene the material belongs to
  17116. * @param shaderPath Defines the route to the shader code in one of three ways:
  17117. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17118. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  17119. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17120. * @param options Define the options used to create the shader
  17121. */
  17122. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17123. /**
  17124. * Gets the options used to compile the shader.
  17125. * They can be modified to trigger a new compilation
  17126. */
  17127. readonly options: IShaderMaterialOptions;
  17128. /**
  17129. * Gets the current class name of the material e.g. "ShaderMaterial"
  17130. * Mainly use in serialization.
  17131. * @returns the class name
  17132. */
  17133. getClassName(): string;
  17134. /**
  17135. * Specifies if the material will require alpha blending
  17136. * @returns a boolean specifying if alpha blending is needed
  17137. */
  17138. needAlphaBlending(): boolean;
  17139. /**
  17140. * Specifies if this material should be rendered in alpha test mode
  17141. * @returns a boolean specifying if an alpha test is needed.
  17142. */
  17143. needAlphaTesting(): boolean;
  17144. private _checkUniform;
  17145. /**
  17146. * Set a texture in the shader.
  17147. * @param name Define the name of the uniform samplers as defined in the shader
  17148. * @param texture Define the texture to bind to this sampler
  17149. * @return the material itself allowing "fluent" like uniform updates
  17150. */
  17151. setTexture(name: string, texture: Texture): ShaderMaterial;
  17152. /**
  17153. * Set a texture array in the shader.
  17154. * @param name Define the name of the uniform sampler array as defined in the shader
  17155. * @param textures Define the list of textures to bind to this sampler
  17156. * @return the material itself allowing "fluent" like uniform updates
  17157. */
  17158. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  17159. /**
  17160. * Set a float in the shader.
  17161. * @param name Define the name of the uniform as defined in the shader
  17162. * @param value Define the value to give to the uniform
  17163. * @return the material itself allowing "fluent" like uniform updates
  17164. */
  17165. setFloat(name: string, value: number): ShaderMaterial;
  17166. /**
  17167. * Set a int in the shader.
  17168. * @param name Define the name of the uniform as defined in the shader
  17169. * @param value Define the value to give to the uniform
  17170. * @return the material itself allowing "fluent" like uniform updates
  17171. */
  17172. setInt(name: string, value: number): ShaderMaterial;
  17173. /**
  17174. * Set an array of floats in the shader.
  17175. * @param name Define the name of the uniform as defined in the shader
  17176. * @param value Define the value to give to the uniform
  17177. * @return the material itself allowing "fluent" like uniform updates
  17178. */
  17179. setFloats(name: string, value: number[]): ShaderMaterial;
  17180. /**
  17181. * Set a vec3 in the shader from a Color3.
  17182. * @param name Define the name of the uniform as defined in the shader
  17183. * @param value Define the value to give to the uniform
  17184. * @return the material itself allowing "fluent" like uniform updates
  17185. */
  17186. setColor3(name: string, value: Color3): ShaderMaterial;
  17187. /**
  17188. * Set a vec3 array in the shader from a Color3 array.
  17189. * @param name Define the name of the uniform as defined in the shader
  17190. * @param value Define the value to give to the uniform
  17191. * @return the material itself allowing "fluent" like uniform updates
  17192. */
  17193. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17194. /**
  17195. * Set a vec4 in the shader from a Color4.
  17196. * @param name Define the name of the uniform as defined in the shader
  17197. * @param value Define the value to give to the uniform
  17198. * @return the material itself allowing "fluent" like uniform updates
  17199. */
  17200. setColor4(name: string, value: Color4): ShaderMaterial;
  17201. /**
  17202. * Set a vec2 in the shader from a Vector2.
  17203. * @param name Define the name of the uniform as defined in the shader
  17204. * @param value Define the value to give to the uniform
  17205. * @return the material itself allowing "fluent" like uniform updates
  17206. */
  17207. setVector2(name: string, value: Vector2): ShaderMaterial;
  17208. /**
  17209. * Set a vec3 in the shader from a Vector3.
  17210. * @param name Define the name of the uniform as defined in the shader
  17211. * @param value Define the value to give to the uniform
  17212. * @return the material itself allowing "fluent" like uniform updates
  17213. */
  17214. setVector3(name: string, value: Vector3): ShaderMaterial;
  17215. /**
  17216. * Set a vec4 in the shader from a Vector4.
  17217. * @param name Define the name of the uniform as defined in the shader
  17218. * @param value Define the value to give to the uniform
  17219. * @return the material itself allowing "fluent" like uniform updates
  17220. */
  17221. setVector4(name: string, value: Vector4): ShaderMaterial;
  17222. /**
  17223. * Set a mat4 in the shader from a Matrix.
  17224. * @param name Define the name of the uniform as defined in the shader
  17225. * @param value Define the value to give to the uniform
  17226. * @return the material itself allowing "fluent" like uniform updates
  17227. */
  17228. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17229. /**
  17230. * Set a mat3 in the shader from a Float32Array.
  17231. * @param name Define the name of the uniform as defined in the shader
  17232. * @param value Define the value to give to the uniform
  17233. * @return the material itself allowing "fluent" like uniform updates
  17234. */
  17235. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  17236. /**
  17237. * Set a mat2 in the shader from a Float32Array.
  17238. * @param name Define the name of the uniform as defined in the shader
  17239. * @param value Define the value to give to the uniform
  17240. * @return the material itself allowing "fluent" like uniform updates
  17241. */
  17242. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17243. /**
  17244. * Set a vec2 array in the shader from a number array.
  17245. * @param name Define the name of the uniform as defined in the shader
  17246. * @param value Define the value to give to the uniform
  17247. * @return the material itself allowing "fluent" like uniform updates
  17248. */
  17249. setArray2(name: string, value: number[]): ShaderMaterial;
  17250. /**
  17251. * Set a vec3 array in the shader from a number array.
  17252. * @param name Define the name of the uniform as defined in the shader
  17253. * @param value Define the value to give to the uniform
  17254. * @return the material itself allowing "fluent" like uniform updates
  17255. */
  17256. setArray3(name: string, value: number[]): ShaderMaterial;
  17257. private _checkCache;
  17258. /**
  17259. * Specifies that the submesh is ready to be used
  17260. * @param mesh defines the mesh to check
  17261. * @param subMesh defines which submesh to check
  17262. * @param useInstances specifies that instances should be used
  17263. * @returns a boolean indicating that the submesh is ready or not
  17264. */
  17265. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17266. /**
  17267. * Checks if the material is ready to render the requested mesh
  17268. * @param mesh Define the mesh to render
  17269. * @param useInstances Define whether or not the material is used with instances
  17270. * @returns true if ready, otherwise false
  17271. */
  17272. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17273. /**
  17274. * Binds the world matrix to the material
  17275. * @param world defines the world transformation matrix
  17276. */
  17277. bindOnlyWorldMatrix(world: Matrix): void;
  17278. /**
  17279. * Binds the material to the mesh
  17280. * @param world defines the world transformation matrix
  17281. * @param mesh defines the mesh to bind the material to
  17282. */
  17283. bind(world: Matrix, mesh?: Mesh): void;
  17284. /**
  17285. * Gets the active textures from the material
  17286. * @returns an array of textures
  17287. */
  17288. getActiveTextures(): BaseTexture[];
  17289. /**
  17290. * Specifies if the material uses a texture
  17291. * @param texture defines the texture to check against the material
  17292. * @returns a boolean specifying if the material uses the texture
  17293. */
  17294. hasTexture(texture: BaseTexture): boolean;
  17295. /**
  17296. * Makes a duplicate of the material, and gives it a new name
  17297. * @param name defines the new name for the duplicated material
  17298. * @returns the cloned material
  17299. */
  17300. clone(name: string): ShaderMaterial;
  17301. /**
  17302. * Disposes the material
  17303. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17304. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17305. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17306. */
  17307. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17308. /**
  17309. * Serializes this material in a JSON representation
  17310. * @returns the serialized material object
  17311. */
  17312. serialize(): any;
  17313. /**
  17314. * Creates a shader material from parsed shader material data
  17315. * @param source defines the JSON represnetation of the material
  17316. * @param scene defines the hosting scene
  17317. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17318. * @returns a new material
  17319. */
  17320. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17321. }
  17322. }
  17323. declare module "babylonjs/Shaders/color.fragment" {
  17324. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17325. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17326. /** @hidden */
  17327. export var colorPixelShader: {
  17328. name: string;
  17329. shader: string;
  17330. };
  17331. }
  17332. declare module "babylonjs/Shaders/color.vertex" {
  17333. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17334. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17335. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17336. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17337. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17338. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17339. /** @hidden */
  17340. export var colorVertexShader: {
  17341. name: string;
  17342. shader: string;
  17343. };
  17344. }
  17345. declare module "babylonjs/Meshes/linesMesh" {
  17346. import { Nullable } from "babylonjs/types";
  17347. import { Scene } from "babylonjs/scene";
  17348. import { Color3 } from "babylonjs/Maths/math";
  17349. import { Node } from "babylonjs/node";
  17350. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17351. import { Mesh } from "babylonjs/Meshes/mesh";
  17352. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17353. import { Effect } from "babylonjs/Materials/effect";
  17354. import { Material } from "babylonjs/Materials/material";
  17355. import "babylonjs/Shaders/color.fragment";
  17356. import "babylonjs/Shaders/color.vertex";
  17357. /**
  17358. * Line mesh
  17359. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17360. */
  17361. export class LinesMesh extends Mesh {
  17362. /**
  17363. * If vertex color should be applied to the mesh
  17364. */
  17365. useVertexColor?: boolean | undefined;
  17366. /**
  17367. * If vertex alpha should be applied to the mesh
  17368. */
  17369. useVertexAlpha?: boolean | undefined;
  17370. /**
  17371. * Color of the line (Default: White)
  17372. */
  17373. color: Color3;
  17374. /**
  17375. * Alpha of the line (Default: 1)
  17376. */
  17377. alpha: number;
  17378. /**
  17379. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17380. * This margin is expressed in world space coordinates, so its value may vary.
  17381. * Default value is 0.1
  17382. */
  17383. intersectionThreshold: number;
  17384. private _colorShader;
  17385. /**
  17386. * Creates a new LinesMesh
  17387. * @param name defines the name
  17388. * @param scene defines the hosting scene
  17389. * @param parent defines the parent mesh if any
  17390. * @param source defines the optional source LinesMesh used to clone data from
  17391. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17392. * When false, achieved by calling a clone(), also passing False.
  17393. * This will make creation of children, recursive.
  17394. * @param useVertexColor defines if this LinesMesh supports vertex color
  17395. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17396. */
  17397. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17398. /**
  17399. * If vertex color should be applied to the mesh
  17400. */
  17401. useVertexColor?: boolean | undefined,
  17402. /**
  17403. * If vertex alpha should be applied to the mesh
  17404. */
  17405. useVertexAlpha?: boolean | undefined);
  17406. private _addClipPlaneDefine;
  17407. private _removeClipPlaneDefine;
  17408. isReady(): boolean;
  17409. /**
  17410. * Returns the string "LineMesh"
  17411. */
  17412. getClassName(): string;
  17413. /**
  17414. * @hidden
  17415. */
  17416. /**
  17417. * @hidden
  17418. */
  17419. material: Material;
  17420. /**
  17421. * @hidden
  17422. */
  17423. readonly checkCollisions: boolean;
  17424. /** @hidden */
  17425. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17426. /** @hidden */
  17427. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17428. /**
  17429. * Disposes of the line mesh
  17430. * @param doNotRecurse If children should be disposed
  17431. */
  17432. dispose(doNotRecurse?: boolean): void;
  17433. /**
  17434. * Returns a new LineMesh object cloned from the current one.
  17435. */
  17436. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17437. /**
  17438. * Creates a new InstancedLinesMesh object from the mesh model.
  17439. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17440. * @param name defines the name of the new instance
  17441. * @returns a new InstancedLinesMesh
  17442. */
  17443. createInstance(name: string): InstancedLinesMesh;
  17444. }
  17445. /**
  17446. * Creates an instance based on a source LinesMesh
  17447. */
  17448. export class InstancedLinesMesh extends InstancedMesh {
  17449. /**
  17450. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17451. * This margin is expressed in world space coordinates, so its value may vary.
  17452. * Initilized with the intersectionThreshold value of the source LinesMesh
  17453. */
  17454. intersectionThreshold: number;
  17455. constructor(name: string, source: LinesMesh);
  17456. /**
  17457. * Returns the string "InstancedLinesMesh".
  17458. */
  17459. getClassName(): string;
  17460. }
  17461. }
  17462. declare module "babylonjs/Shaders/line.fragment" {
  17463. /** @hidden */
  17464. export var linePixelShader: {
  17465. name: string;
  17466. shader: string;
  17467. };
  17468. }
  17469. declare module "babylonjs/Shaders/line.vertex" {
  17470. /** @hidden */
  17471. export var lineVertexShader: {
  17472. name: string;
  17473. shader: string;
  17474. };
  17475. }
  17476. declare module "babylonjs/Rendering/edgesRenderer" {
  17477. import { Nullable } from "babylonjs/types";
  17478. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17479. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17480. import { Vector3 } from "babylonjs/Maths/math";
  17481. import { IDisposable } from "babylonjs/scene";
  17482. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17483. import "babylonjs/Shaders/line.fragment";
  17484. import "babylonjs/Shaders/line.vertex";
  17485. module "babylonjs/Meshes/abstractMesh" {
  17486. interface AbstractMesh {
  17487. /**
  17488. * Disables the mesh edge rendering mode
  17489. * @returns the currentAbstractMesh
  17490. */
  17491. disableEdgesRendering(): AbstractMesh;
  17492. /**
  17493. * Enables the edge rendering mode on the mesh.
  17494. * This mode makes the mesh edges visible
  17495. * @param epsilon defines the maximal distance between two angles to detect a face
  17496. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17497. * @returns the currentAbstractMesh
  17498. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17499. */
  17500. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17501. /**
  17502. * Gets the edgesRenderer associated with the mesh
  17503. */
  17504. edgesRenderer: Nullable<EdgesRenderer>;
  17505. }
  17506. }
  17507. module "babylonjs/Meshes/linesMesh" {
  17508. interface LinesMesh {
  17509. /**
  17510. * Enables the edge rendering mode on the mesh.
  17511. * This mode makes the mesh edges visible
  17512. * @param epsilon defines the maximal distance between two angles to detect a face
  17513. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17514. * @returns the currentAbstractMesh
  17515. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17516. */
  17517. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17518. }
  17519. }
  17520. module "babylonjs/Meshes/linesMesh" {
  17521. interface InstancedLinesMesh {
  17522. /**
  17523. * Enables the edge rendering mode on the mesh.
  17524. * This mode makes the mesh edges visible
  17525. * @param epsilon defines the maximal distance between two angles to detect a face
  17526. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17527. * @returns the current InstancedLinesMesh
  17528. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17529. */
  17530. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17531. }
  17532. }
  17533. /**
  17534. * Defines the minimum contract an Edges renderer should follow.
  17535. */
  17536. export interface IEdgesRenderer extends IDisposable {
  17537. /**
  17538. * Gets or sets a boolean indicating if the edgesRenderer is active
  17539. */
  17540. isEnabled: boolean;
  17541. /**
  17542. * Renders the edges of the attached mesh,
  17543. */
  17544. render(): void;
  17545. /**
  17546. * Checks wether or not the edges renderer is ready to render.
  17547. * @return true if ready, otherwise false.
  17548. */
  17549. isReady(): boolean;
  17550. }
  17551. /**
  17552. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17553. */
  17554. export class EdgesRenderer implements IEdgesRenderer {
  17555. /**
  17556. * Define the size of the edges with an orthographic camera
  17557. */
  17558. edgesWidthScalerForOrthographic: number;
  17559. /**
  17560. * Define the size of the edges with a perspective camera
  17561. */
  17562. edgesWidthScalerForPerspective: number;
  17563. protected _source: AbstractMesh;
  17564. protected _linesPositions: number[];
  17565. protected _linesNormals: number[];
  17566. protected _linesIndices: number[];
  17567. protected _epsilon: number;
  17568. protected _indicesCount: number;
  17569. protected _lineShader: ShaderMaterial;
  17570. protected _ib: WebGLBuffer;
  17571. protected _buffers: {
  17572. [key: string]: Nullable<VertexBuffer>;
  17573. };
  17574. protected _checkVerticesInsteadOfIndices: boolean;
  17575. private _meshRebuildObserver;
  17576. private _meshDisposeObserver;
  17577. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17578. isEnabled: boolean;
  17579. /**
  17580. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17581. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17582. * @param source Mesh used to create edges
  17583. * @param epsilon sum of angles in adjacency to check for edge
  17584. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17585. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17586. */
  17587. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17588. protected _prepareRessources(): void;
  17589. /** @hidden */
  17590. _rebuild(): void;
  17591. /**
  17592. * Releases the required resources for the edges renderer
  17593. */
  17594. dispose(): void;
  17595. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17596. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17597. /**
  17598. * Checks if the pair of p0 and p1 is en edge
  17599. * @param faceIndex
  17600. * @param edge
  17601. * @param faceNormals
  17602. * @param p0
  17603. * @param p1
  17604. * @private
  17605. */
  17606. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17607. /**
  17608. * push line into the position, normal and index buffer
  17609. * @protected
  17610. */
  17611. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17612. /**
  17613. * Generates lines edges from adjacencjes
  17614. * @private
  17615. */
  17616. _generateEdgesLines(): void;
  17617. /**
  17618. * Checks wether or not the edges renderer is ready to render.
  17619. * @return true if ready, otherwise false.
  17620. */
  17621. isReady(): boolean;
  17622. /**
  17623. * Renders the edges of the attached mesh,
  17624. */
  17625. render(): void;
  17626. }
  17627. /**
  17628. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17629. */
  17630. export class LineEdgesRenderer extends EdgesRenderer {
  17631. /**
  17632. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17633. * @param source LineMesh used to generate edges
  17634. * @param epsilon not important (specified angle for edge detection)
  17635. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17636. */
  17637. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17638. /**
  17639. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17640. */
  17641. _generateEdgesLines(): void;
  17642. }
  17643. }
  17644. declare module "babylonjs/Rendering/renderingGroup" {
  17645. import { SmartArray } from "babylonjs/Misc/smartArray";
  17646. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17647. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17648. import { Nullable } from "babylonjs/types";
  17649. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17650. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17651. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17652. import { Material } from "babylonjs/Materials/material";
  17653. import { Scene } from "babylonjs/scene";
  17654. /**
  17655. * This represents the object necessary to create a rendering group.
  17656. * This is exclusively used and created by the rendering manager.
  17657. * To modify the behavior, you use the available helpers in your scene or meshes.
  17658. * @hidden
  17659. */
  17660. export class RenderingGroup {
  17661. index: number;
  17662. private _scene;
  17663. private _opaqueSubMeshes;
  17664. private _transparentSubMeshes;
  17665. private _alphaTestSubMeshes;
  17666. private _depthOnlySubMeshes;
  17667. private _particleSystems;
  17668. private _spriteManagers;
  17669. private _opaqueSortCompareFn;
  17670. private _alphaTestSortCompareFn;
  17671. private _transparentSortCompareFn;
  17672. private _renderOpaque;
  17673. private _renderAlphaTest;
  17674. private _renderTransparent;
  17675. /** @hidden */
  17676. _edgesRenderers: SmartArray<IEdgesRenderer>;
  17677. onBeforeTransparentRendering: () => void;
  17678. /**
  17679. * Set the opaque sort comparison function.
  17680. * If null the sub meshes will be render in the order they were created
  17681. */
  17682. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17683. /**
  17684. * Set the alpha test sort comparison function.
  17685. * If null the sub meshes will be render in the order they were created
  17686. */
  17687. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17688. /**
  17689. * Set the transparent sort comparison function.
  17690. * If null the sub meshes will be render in the order they were created
  17691. */
  17692. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17693. /**
  17694. * Creates a new rendering group.
  17695. * @param index The rendering group index
  17696. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17697. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17698. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17699. */
  17700. 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>);
  17701. /**
  17702. * Render all the sub meshes contained in the group.
  17703. * @param customRenderFunction Used to override the default render behaviour of the group.
  17704. * @returns true if rendered some submeshes.
  17705. */
  17706. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17707. /**
  17708. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17709. * @param subMeshes The submeshes to render
  17710. */
  17711. private renderOpaqueSorted;
  17712. /**
  17713. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17714. * @param subMeshes The submeshes to render
  17715. */
  17716. private renderAlphaTestSorted;
  17717. /**
  17718. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17719. * @param subMeshes The submeshes to render
  17720. */
  17721. private renderTransparentSorted;
  17722. /**
  17723. * Renders the submeshes in a specified order.
  17724. * @param subMeshes The submeshes to sort before render
  17725. * @param sortCompareFn The comparison function use to sort
  17726. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17727. * @param transparent Specifies to activate blending if true
  17728. */
  17729. private static renderSorted;
  17730. /**
  17731. * Renders the submeshes in the order they were dispatched (no sort applied).
  17732. * @param subMeshes The submeshes to render
  17733. */
  17734. private static renderUnsorted;
  17735. /**
  17736. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17737. * are rendered back to front if in the same alpha index.
  17738. *
  17739. * @param a The first submesh
  17740. * @param b The second submesh
  17741. * @returns The result of the comparison
  17742. */
  17743. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17744. /**
  17745. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17746. * are rendered back to front.
  17747. *
  17748. * @param a The first submesh
  17749. * @param b The second submesh
  17750. * @returns The result of the comparison
  17751. */
  17752. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17753. /**
  17754. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17755. * are rendered front to back (prevent overdraw).
  17756. *
  17757. * @param a The first submesh
  17758. * @param b The second submesh
  17759. * @returns The result of the comparison
  17760. */
  17761. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17762. /**
  17763. * Resets the different lists of submeshes to prepare a new frame.
  17764. */
  17765. prepare(): void;
  17766. dispose(): void;
  17767. /**
  17768. * Inserts the submesh in its correct queue depending on its material.
  17769. * @param subMesh The submesh to dispatch
  17770. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17771. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17772. */
  17773. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17774. dispatchSprites(spriteManager: ISpriteManager): void;
  17775. dispatchParticles(particleSystem: IParticleSystem): void;
  17776. private _renderParticles;
  17777. private _renderSprites;
  17778. }
  17779. }
  17780. declare module "babylonjs/Rendering/renderingManager" {
  17781. import { Nullable } from "babylonjs/types";
  17782. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17783. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17784. import { SmartArray } from "babylonjs/Misc/smartArray";
  17785. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17786. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17787. import { Material } from "babylonjs/Materials/material";
  17788. import { Scene } from "babylonjs/scene";
  17789. import { Camera } from "babylonjs/Cameras/camera";
  17790. /**
  17791. * Interface describing the different options available in the rendering manager
  17792. * regarding Auto Clear between groups.
  17793. */
  17794. export interface IRenderingManagerAutoClearSetup {
  17795. /**
  17796. * Defines whether or not autoclear is enable.
  17797. */
  17798. autoClear: boolean;
  17799. /**
  17800. * Defines whether or not to autoclear the depth buffer.
  17801. */
  17802. depth: boolean;
  17803. /**
  17804. * Defines whether or not to autoclear the stencil buffer.
  17805. */
  17806. stencil: boolean;
  17807. }
  17808. /**
  17809. * This class is used by the onRenderingGroupObservable
  17810. */
  17811. export class RenderingGroupInfo {
  17812. /**
  17813. * The Scene that being rendered
  17814. */
  17815. scene: Scene;
  17816. /**
  17817. * The camera currently used for the rendering pass
  17818. */
  17819. camera: Nullable<Camera>;
  17820. /**
  17821. * The ID of the renderingGroup being processed
  17822. */
  17823. renderingGroupId: number;
  17824. }
  17825. /**
  17826. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17827. * It is enable to manage the different groups as well as the different necessary sort functions.
  17828. * This should not be used directly aside of the few static configurations
  17829. */
  17830. export class RenderingManager {
  17831. /**
  17832. * The max id used for rendering groups (not included)
  17833. */
  17834. static MAX_RENDERINGGROUPS: number;
  17835. /**
  17836. * The min id used for rendering groups (included)
  17837. */
  17838. static MIN_RENDERINGGROUPS: number;
  17839. /**
  17840. * Used to globally prevent autoclearing scenes.
  17841. */
  17842. static AUTOCLEAR: boolean;
  17843. /**
  17844. * @hidden
  17845. */
  17846. _useSceneAutoClearSetup: boolean;
  17847. private _scene;
  17848. private _renderingGroups;
  17849. private _depthStencilBufferAlreadyCleaned;
  17850. private _autoClearDepthStencil;
  17851. private _customOpaqueSortCompareFn;
  17852. private _customAlphaTestSortCompareFn;
  17853. private _customTransparentSortCompareFn;
  17854. private _renderingGroupInfo;
  17855. /**
  17856. * Instantiates a new rendering group for a particular scene
  17857. * @param scene Defines the scene the groups belongs to
  17858. */
  17859. constructor(scene: Scene);
  17860. private _clearDepthStencilBuffer;
  17861. /**
  17862. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17863. * @hidden
  17864. */
  17865. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17866. /**
  17867. * Resets the different information of the group to prepare a new frame
  17868. * @hidden
  17869. */
  17870. reset(): void;
  17871. /**
  17872. * Dispose and release the group and its associated resources.
  17873. * @hidden
  17874. */
  17875. dispose(): void;
  17876. /**
  17877. * Clear the info related to rendering groups preventing retention points during dispose.
  17878. */
  17879. freeRenderingGroups(): void;
  17880. private _prepareRenderingGroup;
  17881. /**
  17882. * Add a sprite manager to the rendering manager in order to render it this frame.
  17883. * @param spriteManager Define the sprite manager to render
  17884. */
  17885. dispatchSprites(spriteManager: ISpriteManager): void;
  17886. /**
  17887. * Add a particle system to the rendering manager in order to render it this frame.
  17888. * @param particleSystem Define the particle system to render
  17889. */
  17890. dispatchParticles(particleSystem: IParticleSystem): void;
  17891. /**
  17892. * Add a submesh to the manager in order to render it this frame
  17893. * @param subMesh The submesh to dispatch
  17894. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17895. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17896. */
  17897. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17898. /**
  17899. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17900. * This allowed control for front to back rendering or reversly depending of the special needs.
  17901. *
  17902. * @param renderingGroupId The rendering group id corresponding to its index
  17903. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17904. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17905. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17906. */
  17907. 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;
  17908. /**
  17909. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17910. *
  17911. * @param renderingGroupId The rendering group id corresponding to its index
  17912. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17913. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17914. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17915. */
  17916. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17917. /**
  17918. * Gets the current auto clear configuration for one rendering group of the rendering
  17919. * manager.
  17920. * @param index the rendering group index to get the information for
  17921. * @returns The auto clear setup for the requested rendering group
  17922. */
  17923. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17924. }
  17925. }
  17926. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  17927. import { Observable } from "babylonjs/Misc/observable";
  17928. import { SmartArray } from "babylonjs/Misc/smartArray";
  17929. import { Nullable } from "babylonjs/types";
  17930. import { Camera } from "babylonjs/Cameras/camera";
  17931. import { Scene } from "babylonjs/scene";
  17932. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  17933. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  17934. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17935. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17936. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17937. import { Texture } from "babylonjs/Materials/Textures/texture";
  17938. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17939. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  17940. import { Engine } from "babylonjs/Engines/engine";
  17941. /**
  17942. * This Helps creating a texture that will be created from a camera in your scene.
  17943. * It is basically a dynamic texture that could be used to create special effects for instance.
  17944. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17945. */
  17946. export class RenderTargetTexture extends Texture {
  17947. isCube: boolean;
  17948. /**
  17949. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17950. */
  17951. static readonly REFRESHRATE_RENDER_ONCE: number;
  17952. /**
  17953. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17954. */
  17955. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17956. /**
  17957. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17958. * the central point of your effect and can save a lot of performances.
  17959. */
  17960. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17961. /**
  17962. * Use this predicate to dynamically define the list of mesh you want to render.
  17963. * If set, the renderList property will be overwritten.
  17964. */
  17965. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17966. private _renderList;
  17967. /**
  17968. * Use this list to define the list of mesh you want to render.
  17969. */
  17970. renderList: Nullable<Array<AbstractMesh>>;
  17971. private _hookArray;
  17972. /**
  17973. * Define if particles should be rendered in your texture.
  17974. */
  17975. renderParticles: boolean;
  17976. /**
  17977. * Define if sprites should be rendered in your texture.
  17978. */
  17979. renderSprites: boolean;
  17980. /**
  17981. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17982. */
  17983. coordinatesMode: number;
  17984. /**
  17985. * Define the camera used to render the texture.
  17986. */
  17987. activeCamera: Nullable<Camera>;
  17988. /**
  17989. * Override the render function of the texture with your own one.
  17990. */
  17991. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17992. /**
  17993. * Define if camera post processes should be use while rendering the texture.
  17994. */
  17995. useCameraPostProcesses: boolean;
  17996. /**
  17997. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17998. */
  17999. ignoreCameraViewport: boolean;
  18000. private _postProcessManager;
  18001. private _postProcesses;
  18002. private _resizeObserver;
  18003. /**
  18004. * An event triggered when the texture is unbind.
  18005. */
  18006. onBeforeBindObservable: Observable<RenderTargetTexture>;
  18007. /**
  18008. * An event triggered when the texture is unbind.
  18009. */
  18010. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  18011. private _onAfterUnbindObserver;
  18012. /**
  18013. * Set a after unbind callback in the texture.
  18014. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  18015. */
  18016. onAfterUnbind: () => void;
  18017. /**
  18018. * An event triggered before rendering the texture
  18019. */
  18020. onBeforeRenderObservable: Observable<number>;
  18021. private _onBeforeRenderObserver;
  18022. /**
  18023. * Set a before render callback in the texture.
  18024. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  18025. */
  18026. onBeforeRender: (faceIndex: number) => void;
  18027. /**
  18028. * An event triggered after rendering the texture
  18029. */
  18030. onAfterRenderObservable: Observable<number>;
  18031. private _onAfterRenderObserver;
  18032. /**
  18033. * Set a after render callback in the texture.
  18034. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  18035. */
  18036. onAfterRender: (faceIndex: number) => void;
  18037. /**
  18038. * An event triggered after the texture clear
  18039. */
  18040. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  18041. private _onClearObserver;
  18042. /**
  18043. * Set a clear callback in the texture.
  18044. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  18045. */
  18046. onClear: (Engine: Engine) => void;
  18047. /**
  18048. * Define the clear color of the Render Target if it should be different from the scene.
  18049. */
  18050. clearColor: Color4;
  18051. protected _size: number | {
  18052. width: number;
  18053. height: number;
  18054. };
  18055. protected _initialSizeParameter: number | {
  18056. width: number;
  18057. height: number;
  18058. } | {
  18059. ratio: number;
  18060. };
  18061. protected _sizeRatio: Nullable<number>;
  18062. /** @hidden */
  18063. _generateMipMaps: boolean;
  18064. protected _renderingManager: RenderingManager;
  18065. /** @hidden */
  18066. _waitingRenderList: string[];
  18067. protected _doNotChangeAspectRatio: boolean;
  18068. protected _currentRefreshId: number;
  18069. protected _refreshRate: number;
  18070. protected _textureMatrix: Matrix;
  18071. protected _samples: number;
  18072. protected _renderTargetOptions: RenderTargetCreationOptions;
  18073. /**
  18074. * Gets render target creation options that were used.
  18075. */
  18076. readonly renderTargetOptions: RenderTargetCreationOptions;
  18077. protected _engine: Engine;
  18078. protected _onRatioRescale(): void;
  18079. /**
  18080. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  18081. * It must define where the camera used to render the texture is set
  18082. */
  18083. boundingBoxPosition: Vector3;
  18084. private _boundingBoxSize;
  18085. /**
  18086. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  18087. * When defined, the cubemap will switch to local mode
  18088. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  18089. * @example https://www.babylonjs-playground.com/#RNASML
  18090. */
  18091. boundingBoxSize: Vector3;
  18092. /**
  18093. * In case the RTT has been created with a depth texture, get the associated
  18094. * depth texture.
  18095. * Otherwise, return null.
  18096. */
  18097. depthStencilTexture: Nullable<InternalTexture>;
  18098. /**
  18099. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  18100. * or used a shadow, depth texture...
  18101. * @param name The friendly name of the texture
  18102. * @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)
  18103. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  18104. * @param generateMipMaps True if mip maps need to be generated after render.
  18105. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  18106. * @param type The type of the buffer in the RTT (int, half float, float...)
  18107. * @param isCube True if a cube texture needs to be created
  18108. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  18109. * @param generateDepthBuffer True to generate a depth buffer
  18110. * @param generateStencilBuffer True to generate a stencil buffer
  18111. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  18112. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  18113. * @param delayAllocation if the texture allocation should be delayed (default: false)
  18114. */
  18115. constructor(name: string, size: number | {
  18116. width: number;
  18117. height: number;
  18118. } | {
  18119. ratio: number;
  18120. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  18121. /**
  18122. * Creates a depth stencil texture.
  18123. * This is only available in WebGL 2 or with the depth texture extension available.
  18124. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  18125. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  18126. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  18127. */
  18128. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  18129. private _processSizeParameter;
  18130. /**
  18131. * Define the number of samples to use in case of MSAA.
  18132. * It defaults to one meaning no MSAA has been enabled.
  18133. */
  18134. samples: number;
  18135. /**
  18136. * Resets the refresh counter of the texture and start bak from scratch.
  18137. * Could be useful to regenerate the texture if it is setup to render only once.
  18138. */
  18139. resetRefreshCounter(): void;
  18140. /**
  18141. * Define the refresh rate of the texture or the rendering frequency.
  18142. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  18143. */
  18144. refreshRate: number;
  18145. /**
  18146. * Adds a post process to the render target rendering passes.
  18147. * @param postProcess define the post process to add
  18148. */
  18149. addPostProcess(postProcess: PostProcess): void;
  18150. /**
  18151. * Clear all the post processes attached to the render target
  18152. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  18153. */
  18154. clearPostProcesses(dispose?: boolean): void;
  18155. /**
  18156. * Remove one of the post process from the list of attached post processes to the texture
  18157. * @param postProcess define the post process to remove from the list
  18158. */
  18159. removePostProcess(postProcess: PostProcess): void;
  18160. /** @hidden */
  18161. _shouldRender(): boolean;
  18162. /**
  18163. * Gets the actual render size of the texture.
  18164. * @returns the width of the render size
  18165. */
  18166. getRenderSize(): number;
  18167. /**
  18168. * Gets the actual render width of the texture.
  18169. * @returns the width of the render size
  18170. */
  18171. getRenderWidth(): number;
  18172. /**
  18173. * Gets the actual render height of the texture.
  18174. * @returns the height of the render size
  18175. */
  18176. getRenderHeight(): number;
  18177. /**
  18178. * Get if the texture can be rescaled or not.
  18179. */
  18180. readonly canRescale: boolean;
  18181. /**
  18182. * Resize the texture using a ratio.
  18183. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  18184. */
  18185. scale(ratio: number): void;
  18186. /**
  18187. * Get the texture reflection matrix used to rotate/transform the reflection.
  18188. * @returns the reflection matrix
  18189. */
  18190. getReflectionTextureMatrix(): Matrix;
  18191. /**
  18192. * Resize the texture to a new desired size.
  18193. * Be carrefull as it will recreate all the data in the new texture.
  18194. * @param size Define the new size. It can be:
  18195. * - a number for squared texture,
  18196. * - an object containing { width: number, height: number }
  18197. * - or an object containing a ratio { ratio: number }
  18198. */
  18199. resize(size: number | {
  18200. width: number;
  18201. height: number;
  18202. } | {
  18203. ratio: number;
  18204. }): void;
  18205. /**
  18206. * Renders all the objects from the render list into the texture.
  18207. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  18208. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  18209. */
  18210. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  18211. private _bestReflectionRenderTargetDimension;
  18212. /**
  18213. * @hidden
  18214. * @param faceIndex face index to bind to if this is a cubetexture
  18215. */
  18216. _bindFrameBuffer(faceIndex?: number): void;
  18217. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18218. private renderToTarget;
  18219. /**
  18220. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18221. * This allowed control for front to back rendering or reversly depending of the special needs.
  18222. *
  18223. * @param renderingGroupId The rendering group id corresponding to its index
  18224. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18225. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18226. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18227. */
  18228. 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;
  18229. /**
  18230. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18231. *
  18232. * @param renderingGroupId The rendering group id corresponding to its index
  18233. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18234. */
  18235. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  18236. /**
  18237. * Clones the texture.
  18238. * @returns the cloned texture
  18239. */
  18240. clone(): RenderTargetTexture;
  18241. /**
  18242. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18243. * @returns The JSON representation of the texture
  18244. */
  18245. serialize(): any;
  18246. /**
  18247. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  18248. */
  18249. disposeFramebufferObjects(): void;
  18250. /**
  18251. * Dispose the texture and release its associated resources.
  18252. */
  18253. dispose(): void;
  18254. /** @hidden */
  18255. _rebuild(): void;
  18256. /**
  18257. * Clear the info related to rendering groups preventing retention point in material dispose.
  18258. */
  18259. freeRenderingGroups(): void;
  18260. /**
  18261. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  18262. * @returns the view count
  18263. */
  18264. getViewCount(): number;
  18265. }
  18266. }
  18267. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  18268. import { Scene } from "babylonjs/scene";
  18269. import { Plane } from "babylonjs/Maths/math";
  18270. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18271. /**
  18272. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18273. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18274. * You can then easily use it as a reflectionTexture on a flat surface.
  18275. * In case the surface is not a plane, please consider relying on reflection probes.
  18276. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18277. */
  18278. export class MirrorTexture extends RenderTargetTexture {
  18279. private scene;
  18280. /**
  18281. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18282. * 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.
  18283. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18284. */
  18285. mirrorPlane: Plane;
  18286. /**
  18287. * Define the blur ratio used to blur the reflection if needed.
  18288. */
  18289. blurRatio: number;
  18290. /**
  18291. * Define the adaptive blur kernel used to blur the reflection if needed.
  18292. * This will autocompute the closest best match for the `blurKernel`
  18293. */
  18294. adaptiveBlurKernel: number;
  18295. /**
  18296. * Define the blur kernel used to blur the reflection if needed.
  18297. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18298. */
  18299. blurKernel: number;
  18300. /**
  18301. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18302. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18303. */
  18304. blurKernelX: number;
  18305. /**
  18306. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18307. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18308. */
  18309. blurKernelY: number;
  18310. private _autoComputeBlurKernel;
  18311. protected _onRatioRescale(): void;
  18312. private _updateGammaSpace;
  18313. private _imageProcessingConfigChangeObserver;
  18314. private _transformMatrix;
  18315. private _mirrorMatrix;
  18316. private _savedViewMatrix;
  18317. private _blurX;
  18318. private _blurY;
  18319. private _adaptiveBlurKernel;
  18320. private _blurKernelX;
  18321. private _blurKernelY;
  18322. private _blurRatio;
  18323. /**
  18324. * Instantiates a Mirror Texture.
  18325. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18326. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18327. * You can then easily use it as a reflectionTexture on a flat surface.
  18328. * In case the surface is not a plane, please consider relying on reflection probes.
  18329. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18330. * @param name
  18331. * @param size
  18332. * @param scene
  18333. * @param generateMipMaps
  18334. * @param type
  18335. * @param samplingMode
  18336. * @param generateDepthBuffer
  18337. */
  18338. constructor(name: string, size: number | {
  18339. width: number;
  18340. height: number;
  18341. } | {
  18342. ratio: number;
  18343. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18344. private _preparePostProcesses;
  18345. /**
  18346. * Clone the mirror texture.
  18347. * @returns the cloned texture
  18348. */
  18349. clone(): MirrorTexture;
  18350. /**
  18351. * Serialize the texture to a JSON representation you could use in Parse later on
  18352. * @returns the serialized JSON representation
  18353. */
  18354. serialize(): any;
  18355. /**
  18356. * Dispose the texture and release its associated resources.
  18357. */
  18358. dispose(): void;
  18359. }
  18360. }
  18361. declare module "babylonjs/Materials/Textures/texture" {
  18362. import { Observable } from "babylonjs/Misc/observable";
  18363. import { Nullable } from "babylonjs/types";
  18364. import { Scene } from "babylonjs/scene";
  18365. import { Matrix } from "babylonjs/Maths/math";
  18366. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18367. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18368. /**
  18369. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18370. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18371. */
  18372. export class Texture extends BaseTexture {
  18373. /** @hidden */
  18374. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18375. /** @hidden */
  18376. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18377. /** @hidden */
  18378. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18379. /** nearest is mag = nearest and min = nearest and mip = linear */
  18380. static readonly NEAREST_SAMPLINGMODE: number;
  18381. /** nearest is mag = nearest and min = nearest and mip = linear */
  18382. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18383. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18384. static readonly BILINEAR_SAMPLINGMODE: number;
  18385. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18386. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18387. /** Trilinear is mag = linear and min = linear and mip = linear */
  18388. static readonly TRILINEAR_SAMPLINGMODE: number;
  18389. /** Trilinear is mag = linear and min = linear and mip = linear */
  18390. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18391. /** mag = nearest and min = nearest and mip = nearest */
  18392. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18393. /** mag = nearest and min = linear and mip = nearest */
  18394. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18395. /** mag = nearest and min = linear and mip = linear */
  18396. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18397. /** mag = nearest and min = linear and mip = none */
  18398. static readonly NEAREST_LINEAR: number;
  18399. /** mag = nearest and min = nearest and mip = none */
  18400. static readonly NEAREST_NEAREST: number;
  18401. /** mag = linear and min = nearest and mip = nearest */
  18402. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18403. /** mag = linear and min = nearest and mip = linear */
  18404. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18405. /** mag = linear and min = linear and mip = none */
  18406. static readonly LINEAR_LINEAR: number;
  18407. /** mag = linear and min = nearest and mip = none */
  18408. static readonly LINEAR_NEAREST: number;
  18409. /** Explicit coordinates mode */
  18410. static readonly EXPLICIT_MODE: number;
  18411. /** Spherical coordinates mode */
  18412. static readonly SPHERICAL_MODE: number;
  18413. /** Planar coordinates mode */
  18414. static readonly PLANAR_MODE: number;
  18415. /** Cubic coordinates mode */
  18416. static readonly CUBIC_MODE: number;
  18417. /** Projection coordinates mode */
  18418. static readonly PROJECTION_MODE: number;
  18419. /** Inverse Cubic coordinates mode */
  18420. static readonly SKYBOX_MODE: number;
  18421. /** Inverse Cubic coordinates mode */
  18422. static readonly INVCUBIC_MODE: number;
  18423. /** Equirectangular coordinates mode */
  18424. static readonly EQUIRECTANGULAR_MODE: number;
  18425. /** Equirectangular Fixed coordinates mode */
  18426. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18427. /** Equirectangular Fixed Mirrored coordinates mode */
  18428. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18429. /** Texture is not repeating outside of 0..1 UVs */
  18430. static readonly CLAMP_ADDRESSMODE: number;
  18431. /** Texture is repeating outside of 0..1 UVs */
  18432. static readonly WRAP_ADDRESSMODE: number;
  18433. /** Texture is repeating and mirrored */
  18434. static readonly MIRROR_ADDRESSMODE: number;
  18435. /**
  18436. * 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
  18437. */
  18438. static UseSerializedUrlIfAny: boolean;
  18439. /**
  18440. * Define the url of the texture.
  18441. */
  18442. url: Nullable<string>;
  18443. /**
  18444. * Define an offset on the texture to offset the u coordinates of the UVs
  18445. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18446. */
  18447. uOffset: number;
  18448. /**
  18449. * Define an offset on the texture to offset the v coordinates of the UVs
  18450. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18451. */
  18452. vOffset: number;
  18453. /**
  18454. * Define an offset on the texture to scale the u coordinates of the UVs
  18455. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18456. */
  18457. uScale: number;
  18458. /**
  18459. * Define an offset on the texture to scale the v coordinates of the UVs
  18460. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18461. */
  18462. vScale: number;
  18463. /**
  18464. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18465. * @see http://doc.babylonjs.com/how_to/more_materials
  18466. */
  18467. uAng: number;
  18468. /**
  18469. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18470. * @see http://doc.babylonjs.com/how_to/more_materials
  18471. */
  18472. vAng: number;
  18473. /**
  18474. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18475. * @see http://doc.babylonjs.com/how_to/more_materials
  18476. */
  18477. wAng: number;
  18478. /**
  18479. * Defines the center of rotation (U)
  18480. */
  18481. uRotationCenter: number;
  18482. /**
  18483. * Defines the center of rotation (V)
  18484. */
  18485. vRotationCenter: number;
  18486. /**
  18487. * Defines the center of rotation (W)
  18488. */
  18489. wRotationCenter: number;
  18490. /**
  18491. * Are mip maps generated for this texture or not.
  18492. */
  18493. readonly noMipmap: boolean;
  18494. /**
  18495. * List of inspectable custom properties (used by the Inspector)
  18496. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18497. */
  18498. inspectableCustomProperties: IInspectable[];
  18499. private _noMipmap;
  18500. /** @hidden */
  18501. _invertY: boolean;
  18502. private _rowGenerationMatrix;
  18503. private _cachedTextureMatrix;
  18504. private _projectionModeMatrix;
  18505. private _t0;
  18506. private _t1;
  18507. private _t2;
  18508. private _cachedUOffset;
  18509. private _cachedVOffset;
  18510. private _cachedUScale;
  18511. private _cachedVScale;
  18512. private _cachedUAng;
  18513. private _cachedVAng;
  18514. private _cachedWAng;
  18515. private _cachedProjectionMatrixId;
  18516. private _cachedCoordinatesMode;
  18517. /** @hidden */
  18518. protected _initialSamplingMode: number;
  18519. /** @hidden */
  18520. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18521. private _deleteBuffer;
  18522. protected _format: Nullable<number>;
  18523. private _delayedOnLoad;
  18524. private _delayedOnError;
  18525. /**
  18526. * Observable triggered once the texture has been loaded.
  18527. */
  18528. onLoadObservable: Observable<Texture>;
  18529. protected _isBlocking: boolean;
  18530. /**
  18531. * Is the texture preventing material to render while loading.
  18532. * If false, a default texture will be used instead of the loading one during the preparation step.
  18533. */
  18534. isBlocking: boolean;
  18535. /**
  18536. * Get the current sampling mode associated with the texture.
  18537. */
  18538. readonly samplingMode: number;
  18539. /**
  18540. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18541. */
  18542. readonly invertY: boolean;
  18543. /**
  18544. * Instantiates a new texture.
  18545. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18546. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18547. * @param url define the url of the picture to load as a texture
  18548. * @param scene define the scene the texture will belong to
  18549. * @param noMipmap define if the texture will require mip maps or not
  18550. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18551. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18552. * @param onLoad define a callback triggered when the texture has been loaded
  18553. * @param onError define a callback triggered when an error occurred during the loading session
  18554. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18555. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18556. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18557. */
  18558. 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);
  18559. /**
  18560. * Update the url (and optional buffer) of this texture if url was null during construction.
  18561. * @param url the url of the texture
  18562. * @param buffer the buffer of the texture (defaults to null)
  18563. * @param onLoad callback called when the texture is loaded (defaults to null)
  18564. */
  18565. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18566. /**
  18567. * Finish the loading sequence of a texture flagged as delayed load.
  18568. * @hidden
  18569. */
  18570. delayLoad(): void;
  18571. private _prepareRowForTextureGeneration;
  18572. /**
  18573. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18574. * @returns the transform matrix of the texture.
  18575. */
  18576. getTextureMatrix(): Matrix;
  18577. /**
  18578. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18579. * @returns The reflection texture transform
  18580. */
  18581. getReflectionTextureMatrix(): Matrix;
  18582. /**
  18583. * Clones the texture.
  18584. * @returns the cloned texture
  18585. */
  18586. clone(): Texture;
  18587. /**
  18588. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18589. * @returns The JSON representation of the texture
  18590. */
  18591. serialize(): any;
  18592. /**
  18593. * Get the current class name of the texture useful for serialization or dynamic coding.
  18594. * @returns "Texture"
  18595. */
  18596. getClassName(): string;
  18597. /**
  18598. * Dispose the texture and release its associated resources.
  18599. */
  18600. dispose(): void;
  18601. /**
  18602. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18603. * @param parsedTexture Define the JSON representation of the texture
  18604. * @param scene Define the scene the parsed texture should be instantiated in
  18605. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18606. * @returns The parsed texture if successful
  18607. */
  18608. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18609. /**
  18610. * Creates a texture from its base 64 representation.
  18611. * @param data Define the base64 payload without the data: prefix
  18612. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18613. * @param scene Define the scene the texture should belong to
  18614. * @param noMipmap Forces the texture to not create mip map information if true
  18615. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18616. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18617. * @param onLoad define a callback triggered when the texture has been loaded
  18618. * @param onError define a callback triggered when an error occurred during the loading session
  18619. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18620. * @returns the created texture
  18621. */
  18622. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18623. /**
  18624. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18625. * @param data Define the base64 payload without the data: prefix
  18626. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18627. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18628. * @param scene Define the scene the texture should belong to
  18629. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18630. * @param noMipmap Forces the texture to not create mip map information if true
  18631. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18632. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18633. * @param onLoad define a callback triggered when the texture has been loaded
  18634. * @param onError define a callback triggered when an error occurred during the loading session
  18635. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18636. * @returns the created texture
  18637. */
  18638. 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;
  18639. }
  18640. }
  18641. declare module "babylonjs/Materials/Textures/rawTexture" {
  18642. import { Scene } from "babylonjs/scene";
  18643. import { Texture } from "babylonjs/Materials/Textures/texture";
  18644. /**
  18645. * Raw texture can help creating a texture directly from an array of data.
  18646. * This can be super useful if you either get the data from an uncompressed source or
  18647. * if you wish to create your texture pixel by pixel.
  18648. */
  18649. export class RawTexture extends Texture {
  18650. /**
  18651. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18652. */
  18653. format: number;
  18654. private _engine;
  18655. /**
  18656. * Instantiates a new RawTexture.
  18657. * Raw texture can help creating a texture directly from an array of data.
  18658. * This can be super useful if you either get the data from an uncompressed source or
  18659. * if you wish to create your texture pixel by pixel.
  18660. * @param data define the array of data to use to create the texture
  18661. * @param width define the width of the texture
  18662. * @param height define the height of the texture
  18663. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18664. * @param scene define the scene the texture belongs to
  18665. * @param generateMipMaps define whether mip maps should be generated or not
  18666. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18667. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18668. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18669. */
  18670. constructor(data: ArrayBufferView, width: number, height: number,
  18671. /**
  18672. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18673. */
  18674. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18675. /**
  18676. * Updates the texture underlying data.
  18677. * @param data Define the new data of the texture
  18678. */
  18679. update(data: ArrayBufferView): void;
  18680. /**
  18681. * Creates a luminance texture from some data.
  18682. * @param data Define the texture data
  18683. * @param width Define the width of the texture
  18684. * @param height Define the height of the texture
  18685. * @param scene Define the scene the texture belongs to
  18686. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18687. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18688. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18689. * @returns the luminance texture
  18690. */
  18691. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18692. /**
  18693. * Creates a luminance alpha texture from some data.
  18694. * @param data Define the texture data
  18695. * @param width Define the width of the texture
  18696. * @param height Define the height of the texture
  18697. * @param scene Define the scene the texture belongs to
  18698. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18699. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18700. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18701. * @returns the luminance alpha texture
  18702. */
  18703. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18704. /**
  18705. * Creates an alpha texture from some data.
  18706. * @param data Define the texture data
  18707. * @param width Define the width of the texture
  18708. * @param height Define the height of the texture
  18709. * @param scene Define the scene the texture belongs to
  18710. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18711. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18712. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18713. * @returns the alpha texture
  18714. */
  18715. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18716. /**
  18717. * Creates a RGB texture from some data.
  18718. * @param data Define the texture data
  18719. * @param width Define the width of the texture
  18720. * @param height Define the height of the texture
  18721. * @param scene Define the scene the texture belongs to
  18722. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18723. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18724. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18725. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18726. * @returns the RGB alpha texture
  18727. */
  18728. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18729. /**
  18730. * Creates a RGBA texture from some data.
  18731. * @param data Define the texture data
  18732. * @param width Define the width of the texture
  18733. * @param height Define the height of the texture
  18734. * @param scene Define the scene the texture belongs to
  18735. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18736. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18737. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18738. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18739. * @returns the RGBA texture
  18740. */
  18741. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18742. /**
  18743. * Creates a R texture from some data.
  18744. * @param data Define the texture data
  18745. * @param width Define the width of the texture
  18746. * @param height Define the height of the texture
  18747. * @param scene Define the scene the texture belongs to
  18748. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18749. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18750. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18751. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18752. * @returns the R texture
  18753. */
  18754. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18755. }
  18756. }
  18757. declare module "babylonjs/Animations/runtimeAnimation" {
  18758. import { Animation } from "babylonjs/Animations/animation";
  18759. import { Animatable } from "babylonjs/Animations/animatable";
  18760. import { Scene } from "babylonjs/scene";
  18761. /**
  18762. * Defines a runtime animation
  18763. */
  18764. export class RuntimeAnimation {
  18765. private _events;
  18766. /**
  18767. * The current frame of the runtime animation
  18768. */
  18769. private _currentFrame;
  18770. /**
  18771. * The animation used by the runtime animation
  18772. */
  18773. private _animation;
  18774. /**
  18775. * The target of the runtime animation
  18776. */
  18777. private _target;
  18778. /**
  18779. * The initiating animatable
  18780. */
  18781. private _host;
  18782. /**
  18783. * The original value of the runtime animation
  18784. */
  18785. private _originalValue;
  18786. /**
  18787. * The original blend value of the runtime animation
  18788. */
  18789. private _originalBlendValue;
  18790. /**
  18791. * The offsets cache of the runtime animation
  18792. */
  18793. private _offsetsCache;
  18794. /**
  18795. * The high limits cache of the runtime animation
  18796. */
  18797. private _highLimitsCache;
  18798. /**
  18799. * Specifies if the runtime animation has been stopped
  18800. */
  18801. private _stopped;
  18802. /**
  18803. * The blending factor of the runtime animation
  18804. */
  18805. private _blendingFactor;
  18806. /**
  18807. * The BabylonJS scene
  18808. */
  18809. private _scene;
  18810. /**
  18811. * The current value of the runtime animation
  18812. */
  18813. private _currentValue;
  18814. /** @hidden */
  18815. _workValue: any;
  18816. /**
  18817. * The active target of the runtime animation
  18818. */
  18819. private _activeTargets;
  18820. private _currentActiveTarget;
  18821. private _directTarget;
  18822. /**
  18823. * The target path of the runtime animation
  18824. */
  18825. private _targetPath;
  18826. /**
  18827. * The weight of the runtime animation
  18828. */
  18829. private _weight;
  18830. /**
  18831. * The ratio offset of the runtime animation
  18832. */
  18833. private _ratioOffset;
  18834. /**
  18835. * The previous delay of the runtime animation
  18836. */
  18837. private _previousDelay;
  18838. /**
  18839. * The previous ratio of the runtime animation
  18840. */
  18841. private _previousRatio;
  18842. private _enableBlending;
  18843. private _correctLoopMode;
  18844. private _keys;
  18845. private _minFrame;
  18846. private _maxFrame;
  18847. private _minValue;
  18848. private _maxValue;
  18849. /**
  18850. * Gets the current frame of the runtime animation
  18851. */
  18852. readonly currentFrame: number;
  18853. /**
  18854. * Gets the weight of the runtime animation
  18855. */
  18856. readonly weight: number;
  18857. /**
  18858. * Gets the current value of the runtime animation
  18859. */
  18860. readonly currentValue: any;
  18861. /**
  18862. * Gets the target path of the runtime animation
  18863. */
  18864. readonly targetPath: string;
  18865. /**
  18866. * Gets the actual target of the runtime animation
  18867. */
  18868. readonly target: any;
  18869. /**
  18870. * Create a new RuntimeAnimation object
  18871. * @param target defines the target of the animation
  18872. * @param animation defines the source animation object
  18873. * @param scene defines the hosting scene
  18874. * @param host defines the initiating Animatable
  18875. */
  18876. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18877. private _normalizationProcessor;
  18878. private _defaultNormalizationProcessor;
  18879. private _preparePath;
  18880. /**
  18881. * Gets the animation from the runtime animation
  18882. */
  18883. readonly animation: Animation;
  18884. /**
  18885. * Resets the runtime animation to the beginning
  18886. * @param restoreOriginal defines whether to restore the target property to the original value
  18887. */
  18888. reset(restoreOriginal?: boolean): void;
  18889. /**
  18890. * Specifies if the runtime animation is stopped
  18891. * @returns Boolean specifying if the runtime animation is stopped
  18892. */
  18893. isStopped(): boolean;
  18894. /**
  18895. * Disposes of the runtime animation
  18896. */
  18897. dispose(): void;
  18898. /**
  18899. * Interpolates the animation from the current frame
  18900. * @param currentFrame The frame to interpolate the animation to
  18901. * @param repeatCount The number of times that the animation should loop
  18902. * @param loopMode The type of looping mode to use
  18903. * @param offsetValue Animation offset value
  18904. * @param highLimitValue The high limit value
  18905. * @returns The interpolated value
  18906. */
  18907. private _interpolate;
  18908. /**
  18909. * Apply the interpolated value to the target
  18910. */
  18911. setValue: (currentValue: any, weight: number) => void;
  18912. private _setValueForArray;
  18913. private _setValueForDirect;
  18914. private _getOriginalValues;
  18915. private _activeBlendingProcessor;
  18916. private _noBlendingProcessor;
  18917. private _blendingProcessor;
  18918. private _setValue;
  18919. /**
  18920. * Gets the loop pmode of the runtime animation
  18921. * @returns Loop Mode
  18922. */
  18923. private _getCorrectLoopMode;
  18924. /**
  18925. * Move the current animation to a given frame
  18926. * @param frame defines the frame to move to
  18927. */
  18928. goToFrame(frame: number): void;
  18929. /**
  18930. * @hidden Internal use only
  18931. */
  18932. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18933. /**
  18934. * Execute the current animation
  18935. * @param delay defines the delay to add to the current frame
  18936. * @param from defines the lower bound of the animation range
  18937. * @param to defines the upper bound of the animation range
  18938. * @param loop defines if the current animation must loop
  18939. * @param speedRatio defines the current speed ratio
  18940. * @param weight defines the weight of the animation (default is -1 so no weight)
  18941. * @param onLoop optional callback called when animation loops
  18942. * @returns a boolean indicating if the animation is running
  18943. */
  18944. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  18945. }
  18946. }
  18947. declare module "babylonjs/Animations/animatable" {
  18948. import { Animation } from "babylonjs/Animations/animation";
  18949. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  18950. import { Nullable } from "babylonjs/types";
  18951. import { Observable } from "babylonjs/Misc/observable";
  18952. import { Scene } from "babylonjs/scene";
  18953. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  18954. import { Node } from "babylonjs/node";
  18955. /**
  18956. * Class used to store an actual running animation
  18957. */
  18958. export class Animatable {
  18959. /** defines the target object */
  18960. target: any;
  18961. /** defines the starting frame number (default is 0) */
  18962. fromFrame: number;
  18963. /** defines the ending frame number (default is 100) */
  18964. toFrame: number;
  18965. /** defines if the animation must loop (default is false) */
  18966. loopAnimation: boolean;
  18967. /** defines a callback to call when animation ends if it is not looping */
  18968. onAnimationEnd?: (() => void) | null | undefined;
  18969. /** defines a callback to call when animation loops */
  18970. onAnimationLoop?: (() => void) | null | undefined;
  18971. private _localDelayOffset;
  18972. private _pausedDelay;
  18973. private _runtimeAnimations;
  18974. private _paused;
  18975. private _scene;
  18976. private _speedRatio;
  18977. private _weight;
  18978. private _syncRoot;
  18979. /**
  18980. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18981. * This will only apply for non looping animation (default is true)
  18982. */
  18983. disposeOnEnd: boolean;
  18984. /**
  18985. * Gets a boolean indicating if the animation has started
  18986. */
  18987. animationStarted: boolean;
  18988. /**
  18989. * Observer raised when the animation ends
  18990. */
  18991. onAnimationEndObservable: Observable<Animatable>;
  18992. /**
  18993. * Observer raised when the animation loops
  18994. */
  18995. onAnimationLoopObservable: Observable<Animatable>;
  18996. /**
  18997. * Gets the root Animatable used to synchronize and normalize animations
  18998. */
  18999. readonly syncRoot: Animatable;
  19000. /**
  19001. * Gets the current frame of the first RuntimeAnimation
  19002. * Used to synchronize Animatables
  19003. */
  19004. readonly masterFrame: number;
  19005. /**
  19006. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  19007. */
  19008. weight: number;
  19009. /**
  19010. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  19011. */
  19012. speedRatio: number;
  19013. /**
  19014. * Creates a new Animatable
  19015. * @param scene defines the hosting scene
  19016. * @param target defines the target object
  19017. * @param fromFrame defines the starting frame number (default is 0)
  19018. * @param toFrame defines the ending frame number (default is 100)
  19019. * @param loopAnimation defines if the animation must loop (default is false)
  19020. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  19021. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  19022. * @param animations defines a group of animation to add to the new Animatable
  19023. * @param onAnimationLoop defines a callback to call when animation loops
  19024. */
  19025. constructor(scene: Scene,
  19026. /** defines the target object */
  19027. target: any,
  19028. /** defines the starting frame number (default is 0) */
  19029. fromFrame?: number,
  19030. /** defines the ending frame number (default is 100) */
  19031. toFrame?: number,
  19032. /** defines if the animation must loop (default is false) */
  19033. loopAnimation?: boolean, speedRatio?: number,
  19034. /** defines a callback to call when animation ends if it is not looping */
  19035. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  19036. /** defines a callback to call when animation loops */
  19037. onAnimationLoop?: (() => void) | null | undefined);
  19038. /**
  19039. * Synchronize and normalize current Animatable with a source Animatable
  19040. * This is useful when using animation weights and when animations are not of the same length
  19041. * @param root defines the root Animatable to synchronize with
  19042. * @returns the current Animatable
  19043. */
  19044. syncWith(root: Animatable): Animatable;
  19045. /**
  19046. * Gets the list of runtime animations
  19047. * @returns an array of RuntimeAnimation
  19048. */
  19049. getAnimations(): RuntimeAnimation[];
  19050. /**
  19051. * Adds more animations to the current animatable
  19052. * @param target defines the target of the animations
  19053. * @param animations defines the new animations to add
  19054. */
  19055. appendAnimations(target: any, animations: Animation[]): void;
  19056. /**
  19057. * Gets the source animation for a specific property
  19058. * @param property defines the propertyu to look for
  19059. * @returns null or the source animation for the given property
  19060. */
  19061. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  19062. /**
  19063. * Gets the runtime animation for a specific property
  19064. * @param property defines the propertyu to look for
  19065. * @returns null or the runtime animation for the given property
  19066. */
  19067. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  19068. /**
  19069. * Resets the animatable to its original state
  19070. */
  19071. reset(): void;
  19072. /**
  19073. * Allows the animatable to blend with current running animations
  19074. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19075. * @param blendingSpeed defines the blending speed to use
  19076. */
  19077. enableBlending(blendingSpeed: number): void;
  19078. /**
  19079. * Disable animation blending
  19080. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19081. */
  19082. disableBlending(): void;
  19083. /**
  19084. * Jump directly to a given frame
  19085. * @param frame defines the frame to jump to
  19086. */
  19087. goToFrame(frame: number): void;
  19088. /**
  19089. * Pause the animation
  19090. */
  19091. pause(): void;
  19092. /**
  19093. * Restart the animation
  19094. */
  19095. restart(): void;
  19096. private _raiseOnAnimationEnd;
  19097. /**
  19098. * Stop and delete the current animation
  19099. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  19100. * @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)
  19101. */
  19102. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  19103. /**
  19104. * Wait asynchronously for the animation to end
  19105. * @returns a promise which will be fullfilled when the animation ends
  19106. */
  19107. waitAsync(): Promise<Animatable>;
  19108. /** @hidden */
  19109. _animate(delay: number): boolean;
  19110. }
  19111. module "babylonjs/scene" {
  19112. interface Scene {
  19113. /** @hidden */
  19114. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  19115. /** @hidden */
  19116. _processLateAnimationBindingsForMatrices(holder: {
  19117. totalWeight: number;
  19118. animations: RuntimeAnimation[];
  19119. originalValue: Matrix;
  19120. }): any;
  19121. /** @hidden */
  19122. _processLateAnimationBindingsForQuaternions(holder: {
  19123. totalWeight: number;
  19124. animations: RuntimeAnimation[];
  19125. originalValue: Quaternion;
  19126. }, refQuaternion: Quaternion): Quaternion;
  19127. /** @hidden */
  19128. _processLateAnimationBindings(): void;
  19129. /**
  19130. * Will start the animation sequence of a given target
  19131. * @param target defines the target
  19132. * @param from defines from which frame should animation start
  19133. * @param to defines until which frame should animation run.
  19134. * @param weight defines the weight to apply to the animation (1.0 by default)
  19135. * @param loop defines if the animation loops
  19136. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19137. * @param onAnimationEnd defines the function to be executed when the animation ends
  19138. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19139. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19140. * @param onAnimationLoop defines the callback to call when an animation loops
  19141. * @returns the animatable object created for this animation
  19142. */
  19143. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19144. /**
  19145. * Will start the animation sequence of a given target
  19146. * @param target defines the target
  19147. * @param from defines from which frame should animation start
  19148. * @param to defines until which frame should animation run.
  19149. * @param loop defines if the animation loops
  19150. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19151. * @param onAnimationEnd defines the function to be executed when the animation ends
  19152. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19153. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19154. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  19155. * @param onAnimationLoop defines the callback to call when an animation loops
  19156. * @returns the animatable object created for this animation
  19157. */
  19158. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19159. /**
  19160. * Will start the animation sequence of a given target and its hierarchy
  19161. * @param target defines the target
  19162. * @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.
  19163. * @param from defines from which frame should animation start
  19164. * @param to defines until which frame should animation run.
  19165. * @param loop defines if the animation loops
  19166. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19167. * @param onAnimationEnd defines the function to be executed when the animation ends
  19168. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19169. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19170. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19171. * @param onAnimationLoop defines the callback to call when an animation loops
  19172. * @returns the list of created animatables
  19173. */
  19174. 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[];
  19175. /**
  19176. * Begin a new animation on a given node
  19177. * @param target defines the target where the animation will take place
  19178. * @param animations defines the list of animations to start
  19179. * @param from defines the initial value
  19180. * @param to defines the final value
  19181. * @param loop defines if you want animation to loop (off by default)
  19182. * @param speedRatio defines the speed ratio to apply to all animations
  19183. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19184. * @param onAnimationLoop defines the callback to call when an animation loops
  19185. * @returns the list of created animatables
  19186. */
  19187. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  19188. /**
  19189. * Begin a new animation on a given node and its hierarchy
  19190. * @param target defines the root node where the animation will take place
  19191. * @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.
  19192. * @param animations defines the list of animations to start
  19193. * @param from defines the initial value
  19194. * @param to defines the final value
  19195. * @param loop defines if you want animation to loop (off by default)
  19196. * @param speedRatio defines the speed ratio to apply to all animations
  19197. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19198. * @param onAnimationLoop defines the callback to call when an animation loops
  19199. * @returns the list of animatables created for all nodes
  19200. */
  19201. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  19202. /**
  19203. * Gets the animatable associated with a specific target
  19204. * @param target defines the target of the animatable
  19205. * @returns the required animatable if found
  19206. */
  19207. getAnimatableByTarget(target: any): Nullable<Animatable>;
  19208. /**
  19209. * Gets all animatables associated with a given target
  19210. * @param target defines the target to look animatables for
  19211. * @returns an array of Animatables
  19212. */
  19213. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  19214. /**
  19215. * Will stop the animation of the given target
  19216. * @param target - the target
  19217. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  19218. * @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)
  19219. */
  19220. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  19221. /**
  19222. * Stops and removes all animations that have been applied to the scene
  19223. */
  19224. stopAllAnimations(): void;
  19225. }
  19226. }
  19227. module "babylonjs/Bones/bone" {
  19228. interface Bone {
  19229. /**
  19230. * Copy an animation range from another bone
  19231. * @param source defines the source bone
  19232. * @param rangeName defines the range name to copy
  19233. * @param frameOffset defines the frame offset
  19234. * @param rescaleAsRequired defines if rescaling must be applied if required
  19235. * @param skelDimensionsRatio defines the scaling ratio
  19236. * @returns true if operation was successful
  19237. */
  19238. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  19239. }
  19240. }
  19241. }
  19242. declare module "babylonjs/Bones/skeleton" {
  19243. import { Bone } from "babylonjs/Bones/bone";
  19244. import { IAnimatable } from "babylonjs/Misc/tools";
  19245. import { Observable } from "babylonjs/Misc/observable";
  19246. import { Vector3, Matrix } from "babylonjs/Maths/math";
  19247. import { Scene } from "babylonjs/scene";
  19248. import { Nullable } from "babylonjs/types";
  19249. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19250. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  19251. import { Animatable } from "babylonjs/Animations/animatable";
  19252. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19253. import { Animation } from "babylonjs/Animations/animation";
  19254. import { AnimationRange } from "babylonjs/Animations/animationRange";
  19255. import { IInspectable } from "babylonjs/Misc/iInspectable";
  19256. /**
  19257. * Class used to handle skinning animations
  19258. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19259. */
  19260. export class Skeleton implements IAnimatable {
  19261. /** defines the skeleton name */
  19262. name: string;
  19263. /** defines the skeleton Id */
  19264. id: string;
  19265. /**
  19266. * Defines the list of child bones
  19267. */
  19268. bones: Bone[];
  19269. /**
  19270. * Defines an estimate of the dimension of the skeleton at rest
  19271. */
  19272. dimensionsAtRest: Vector3;
  19273. /**
  19274. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  19275. */
  19276. needInitialSkinMatrix: boolean;
  19277. /**
  19278. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  19279. */
  19280. overrideMesh: Nullable<AbstractMesh>;
  19281. /**
  19282. * Gets the list of animations attached to this skeleton
  19283. */
  19284. animations: Array<Animation>;
  19285. private _scene;
  19286. private _isDirty;
  19287. private _transformMatrices;
  19288. private _transformMatrixTexture;
  19289. private _meshesWithPoseMatrix;
  19290. private _animatables;
  19291. private _identity;
  19292. private _synchronizedWithMesh;
  19293. private _ranges;
  19294. private _lastAbsoluteTransformsUpdateId;
  19295. private _canUseTextureForBones;
  19296. private _uniqueId;
  19297. /** @hidden */
  19298. _numBonesWithLinkedTransformNode: number;
  19299. /**
  19300. * Specifies if the skeleton should be serialized
  19301. */
  19302. doNotSerialize: boolean;
  19303. private _useTextureToStoreBoneMatrices;
  19304. /**
  19305. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  19306. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  19307. */
  19308. useTextureToStoreBoneMatrices: boolean;
  19309. private _animationPropertiesOverride;
  19310. /**
  19311. * Gets or sets the animation properties override
  19312. */
  19313. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19314. /**
  19315. * List of inspectable custom properties (used by the Inspector)
  19316. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19317. */
  19318. inspectableCustomProperties: IInspectable[];
  19319. /**
  19320. * An observable triggered before computing the skeleton's matrices
  19321. */
  19322. onBeforeComputeObservable: Observable<Skeleton>;
  19323. /**
  19324. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  19325. */
  19326. readonly isUsingTextureForMatrices: boolean;
  19327. /**
  19328. * Gets the unique ID of this skeleton
  19329. */
  19330. readonly uniqueId: number;
  19331. /**
  19332. * Creates a new skeleton
  19333. * @param name defines the skeleton name
  19334. * @param id defines the skeleton Id
  19335. * @param scene defines the hosting scene
  19336. */
  19337. constructor(
  19338. /** defines the skeleton name */
  19339. name: string,
  19340. /** defines the skeleton Id */
  19341. id: string, scene: Scene);
  19342. /**
  19343. * Gets the current object class name.
  19344. * @return the class name
  19345. */
  19346. getClassName(): string;
  19347. /**
  19348. * Returns an array containing the root bones
  19349. * @returns an array containing the root bones
  19350. */
  19351. getChildren(): Array<Bone>;
  19352. /**
  19353. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  19354. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  19355. * @returns a Float32Array containing matrices data
  19356. */
  19357. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  19358. /**
  19359. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  19360. * @returns a raw texture containing the data
  19361. */
  19362. getTransformMatrixTexture(): Nullable<RawTexture>;
  19363. /**
  19364. * Gets the current hosting scene
  19365. * @returns a scene object
  19366. */
  19367. getScene(): Scene;
  19368. /**
  19369. * Gets a string representing the current skeleton data
  19370. * @param fullDetails defines a boolean indicating if we want a verbose version
  19371. * @returns a string representing the current skeleton data
  19372. */
  19373. toString(fullDetails?: boolean): string;
  19374. /**
  19375. * Get bone's index searching by name
  19376. * @param name defines bone's name to search for
  19377. * @return the indice of the bone. Returns -1 if not found
  19378. */
  19379. getBoneIndexByName(name: string): number;
  19380. /**
  19381. * Creater a new animation range
  19382. * @param name defines the name of the range
  19383. * @param from defines the start key
  19384. * @param to defines the end key
  19385. */
  19386. createAnimationRange(name: string, from: number, to: number): void;
  19387. /**
  19388. * Delete a specific animation range
  19389. * @param name defines the name of the range
  19390. * @param deleteFrames defines if frames must be removed as well
  19391. */
  19392. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19393. /**
  19394. * Gets a specific animation range
  19395. * @param name defines the name of the range to look for
  19396. * @returns the requested animation range or null if not found
  19397. */
  19398. getAnimationRange(name: string): Nullable<AnimationRange>;
  19399. /**
  19400. * Gets the list of all animation ranges defined on this skeleton
  19401. * @returns an array
  19402. */
  19403. getAnimationRanges(): Nullable<AnimationRange>[];
  19404. /**
  19405. * Copy animation range from a source skeleton.
  19406. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19407. * @param source defines the source skeleton
  19408. * @param name defines the name of the range to copy
  19409. * @param rescaleAsRequired defines if rescaling must be applied if required
  19410. * @returns true if operation was successful
  19411. */
  19412. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19413. /**
  19414. * Forces the skeleton to go to rest pose
  19415. */
  19416. returnToRest(): void;
  19417. private _getHighestAnimationFrame;
  19418. /**
  19419. * Begin a specific animation range
  19420. * @param name defines the name of the range to start
  19421. * @param loop defines if looping must be turned on (false by default)
  19422. * @param speedRatio defines the speed ratio to apply (1 by default)
  19423. * @param onAnimationEnd defines a callback which will be called when animation will end
  19424. * @returns a new animatable
  19425. */
  19426. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19427. /** @hidden */
  19428. _markAsDirty(): void;
  19429. /** @hidden */
  19430. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19431. /** @hidden */
  19432. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19433. private _computeTransformMatrices;
  19434. /**
  19435. * Build all resources required to render a skeleton
  19436. */
  19437. prepare(): void;
  19438. /**
  19439. * Gets the list of animatables currently running for this skeleton
  19440. * @returns an array of animatables
  19441. */
  19442. getAnimatables(): IAnimatable[];
  19443. /**
  19444. * Clone the current skeleton
  19445. * @param name defines the name of the new skeleton
  19446. * @param id defines the id of the enw skeleton
  19447. * @returns the new skeleton
  19448. */
  19449. clone(name: string, id: string): Skeleton;
  19450. /**
  19451. * Enable animation blending for this skeleton
  19452. * @param blendingSpeed defines the blending speed to apply
  19453. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19454. */
  19455. enableBlending(blendingSpeed?: number): void;
  19456. /**
  19457. * Releases all resources associated with the current skeleton
  19458. */
  19459. dispose(): void;
  19460. /**
  19461. * Serialize the skeleton in a JSON object
  19462. * @returns a JSON object
  19463. */
  19464. serialize(): any;
  19465. /**
  19466. * Creates a new skeleton from serialized data
  19467. * @param parsedSkeleton defines the serialized data
  19468. * @param scene defines the hosting scene
  19469. * @returns a new skeleton
  19470. */
  19471. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19472. /**
  19473. * Compute all node absolute transforms
  19474. * @param forceUpdate defines if computation must be done even if cache is up to date
  19475. */
  19476. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19477. /**
  19478. * Gets the root pose matrix
  19479. * @returns a matrix
  19480. */
  19481. getPoseMatrix(): Nullable<Matrix>;
  19482. /**
  19483. * Sorts bones per internal index
  19484. */
  19485. sortBones(): void;
  19486. private _sortBones;
  19487. }
  19488. }
  19489. declare module "babylonjs/Morph/morphTarget" {
  19490. import { IAnimatable } from "babylonjs/Misc/tools";
  19491. import { Observable } from "babylonjs/Misc/observable";
  19492. import { Nullable, FloatArray } from "babylonjs/types";
  19493. import { Scene } from "babylonjs/scene";
  19494. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19495. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19496. /**
  19497. * Defines a target to use with MorphTargetManager
  19498. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19499. */
  19500. export class MorphTarget implements IAnimatable {
  19501. /** defines the name of the target */
  19502. name: string;
  19503. /**
  19504. * Gets or sets the list of animations
  19505. */
  19506. animations: import("babylonjs/Animations/animation").Animation[];
  19507. private _scene;
  19508. private _positions;
  19509. private _normals;
  19510. private _tangents;
  19511. private _influence;
  19512. /**
  19513. * Observable raised when the influence changes
  19514. */
  19515. onInfluenceChanged: Observable<boolean>;
  19516. /** @hidden */
  19517. _onDataLayoutChanged: Observable<void>;
  19518. /**
  19519. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19520. */
  19521. influence: number;
  19522. /**
  19523. * Gets or sets the id of the morph Target
  19524. */
  19525. id: string;
  19526. private _animationPropertiesOverride;
  19527. /**
  19528. * Gets or sets the animation properties override
  19529. */
  19530. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19531. /**
  19532. * Creates a new MorphTarget
  19533. * @param name defines the name of the target
  19534. * @param influence defines the influence to use
  19535. * @param scene defines the scene the morphtarget belongs to
  19536. */
  19537. constructor(
  19538. /** defines the name of the target */
  19539. name: string, influence?: number, scene?: Nullable<Scene>);
  19540. /**
  19541. * Gets a boolean defining if the target contains position data
  19542. */
  19543. readonly hasPositions: boolean;
  19544. /**
  19545. * Gets a boolean defining if the target contains normal data
  19546. */
  19547. readonly hasNormals: boolean;
  19548. /**
  19549. * Gets a boolean defining if the target contains tangent data
  19550. */
  19551. readonly hasTangents: boolean;
  19552. /**
  19553. * Affects position data to this target
  19554. * @param data defines the position data to use
  19555. */
  19556. setPositions(data: Nullable<FloatArray>): void;
  19557. /**
  19558. * Gets the position data stored in this target
  19559. * @returns a FloatArray containing the position data (or null if not present)
  19560. */
  19561. getPositions(): Nullable<FloatArray>;
  19562. /**
  19563. * Affects normal data to this target
  19564. * @param data defines the normal data to use
  19565. */
  19566. setNormals(data: Nullable<FloatArray>): void;
  19567. /**
  19568. * Gets the normal data stored in this target
  19569. * @returns a FloatArray containing the normal data (or null if not present)
  19570. */
  19571. getNormals(): Nullable<FloatArray>;
  19572. /**
  19573. * Affects tangent data to this target
  19574. * @param data defines the tangent data to use
  19575. */
  19576. setTangents(data: Nullable<FloatArray>): void;
  19577. /**
  19578. * Gets the tangent data stored in this target
  19579. * @returns a FloatArray containing the tangent data (or null if not present)
  19580. */
  19581. getTangents(): Nullable<FloatArray>;
  19582. /**
  19583. * Serializes the current target into a Serialization object
  19584. * @returns the serialized object
  19585. */
  19586. serialize(): any;
  19587. /**
  19588. * Returns the string "MorphTarget"
  19589. * @returns "MorphTarget"
  19590. */
  19591. getClassName(): string;
  19592. /**
  19593. * Creates a new target from serialized data
  19594. * @param serializationObject defines the serialized data to use
  19595. * @returns a new MorphTarget
  19596. */
  19597. static Parse(serializationObject: any): MorphTarget;
  19598. /**
  19599. * Creates a MorphTarget from mesh data
  19600. * @param mesh defines the source mesh
  19601. * @param name defines the name to use for the new target
  19602. * @param influence defines the influence to attach to the target
  19603. * @returns a new MorphTarget
  19604. */
  19605. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19606. }
  19607. }
  19608. declare module "babylonjs/Morph/morphTargetManager" {
  19609. import { Nullable } from "babylonjs/types";
  19610. import { Scene } from "babylonjs/scene";
  19611. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  19612. /**
  19613. * This class is used to deform meshes using morphing between different targets
  19614. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19615. */
  19616. export class MorphTargetManager {
  19617. private _targets;
  19618. private _targetInfluenceChangedObservers;
  19619. private _targetDataLayoutChangedObservers;
  19620. private _activeTargets;
  19621. private _scene;
  19622. private _influences;
  19623. private _supportsNormals;
  19624. private _supportsTangents;
  19625. private _vertexCount;
  19626. private _uniqueId;
  19627. private _tempInfluences;
  19628. /**
  19629. * Creates a new MorphTargetManager
  19630. * @param scene defines the current scene
  19631. */
  19632. constructor(scene?: Nullable<Scene>);
  19633. /**
  19634. * Gets the unique ID of this manager
  19635. */
  19636. readonly uniqueId: number;
  19637. /**
  19638. * Gets the number of vertices handled by this manager
  19639. */
  19640. readonly vertexCount: number;
  19641. /**
  19642. * Gets a boolean indicating if this manager supports morphing of normals
  19643. */
  19644. readonly supportsNormals: boolean;
  19645. /**
  19646. * Gets a boolean indicating if this manager supports morphing of tangents
  19647. */
  19648. readonly supportsTangents: boolean;
  19649. /**
  19650. * Gets the number of targets stored in this manager
  19651. */
  19652. readonly numTargets: number;
  19653. /**
  19654. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19655. */
  19656. readonly numInfluencers: number;
  19657. /**
  19658. * Gets the list of influences (one per target)
  19659. */
  19660. readonly influences: Float32Array;
  19661. /**
  19662. * Gets the active target at specified index. An active target is a target with an influence > 0
  19663. * @param index defines the index to check
  19664. * @returns the requested target
  19665. */
  19666. getActiveTarget(index: number): MorphTarget;
  19667. /**
  19668. * Gets the target at specified index
  19669. * @param index defines the index to check
  19670. * @returns the requested target
  19671. */
  19672. getTarget(index: number): MorphTarget;
  19673. /**
  19674. * Add a new target to this manager
  19675. * @param target defines the target to add
  19676. */
  19677. addTarget(target: MorphTarget): void;
  19678. /**
  19679. * Removes a target from the manager
  19680. * @param target defines the target to remove
  19681. */
  19682. removeTarget(target: MorphTarget): void;
  19683. /**
  19684. * Serializes the current manager into a Serialization object
  19685. * @returns the serialized object
  19686. */
  19687. serialize(): any;
  19688. private _syncActiveTargets;
  19689. /**
  19690. * Syncrhonize the targets with all the meshes using this morph target manager
  19691. */
  19692. synchronize(): void;
  19693. /**
  19694. * Creates a new MorphTargetManager from serialized data
  19695. * @param serializationObject defines the serialized data
  19696. * @param scene defines the hosting scene
  19697. * @returns the new MorphTargetManager
  19698. */
  19699. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19700. }
  19701. }
  19702. declare module "babylonjs/Meshes/groundMesh" {
  19703. import { Scene } from "babylonjs/scene";
  19704. import { Vector3 } from "babylonjs/Maths/math";
  19705. import { Mesh } from "babylonjs/Meshes/mesh";
  19706. /**
  19707. * Mesh representing the gorund
  19708. */
  19709. export class GroundMesh extends Mesh {
  19710. /** If octree should be generated */
  19711. generateOctree: boolean;
  19712. private _heightQuads;
  19713. /** @hidden */
  19714. _subdivisionsX: number;
  19715. /** @hidden */
  19716. _subdivisionsY: number;
  19717. /** @hidden */
  19718. _width: number;
  19719. /** @hidden */
  19720. _height: number;
  19721. /** @hidden */
  19722. _minX: number;
  19723. /** @hidden */
  19724. _maxX: number;
  19725. /** @hidden */
  19726. _minZ: number;
  19727. /** @hidden */
  19728. _maxZ: number;
  19729. constructor(name: string, scene: Scene);
  19730. /**
  19731. * "GroundMesh"
  19732. * @returns "GroundMesh"
  19733. */
  19734. getClassName(): string;
  19735. /**
  19736. * The minimum of x and y subdivisions
  19737. */
  19738. readonly subdivisions: number;
  19739. /**
  19740. * X subdivisions
  19741. */
  19742. readonly subdivisionsX: number;
  19743. /**
  19744. * Y subdivisions
  19745. */
  19746. readonly subdivisionsY: number;
  19747. /**
  19748. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19749. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19750. * @param chunksCount the number of subdivisions for x and y
  19751. * @param octreeBlocksSize (Default: 32)
  19752. */
  19753. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19754. /**
  19755. * Returns a height (y) value in the Worl system :
  19756. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19757. * @param x x coordinate
  19758. * @param z z coordinate
  19759. * @returns the ground y position if (x, z) are outside the ground surface.
  19760. */
  19761. getHeightAtCoordinates(x: number, z: number): number;
  19762. /**
  19763. * Returns a normalized vector (Vector3) orthogonal to the ground
  19764. * at the ground coordinates (x, z) expressed in the World system.
  19765. * @param x x coordinate
  19766. * @param z z coordinate
  19767. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19768. */
  19769. getNormalAtCoordinates(x: number, z: number): Vector3;
  19770. /**
  19771. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19772. * at the ground coordinates (x, z) expressed in the World system.
  19773. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19774. * @param x x coordinate
  19775. * @param z z coordinate
  19776. * @param ref vector to store the result
  19777. * @returns the GroundMesh.
  19778. */
  19779. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19780. /**
  19781. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19782. * if the ground has been updated.
  19783. * This can be used in the render loop.
  19784. * @returns the GroundMesh.
  19785. */
  19786. updateCoordinateHeights(): GroundMesh;
  19787. private _getFacetAt;
  19788. private _initHeightQuads;
  19789. private _computeHeightQuads;
  19790. /**
  19791. * Serializes this ground mesh
  19792. * @param serializationObject object to write serialization to
  19793. */
  19794. serialize(serializationObject: any): void;
  19795. /**
  19796. * Parses a serialized ground mesh
  19797. * @param parsedMesh the serialized mesh
  19798. * @param scene the scene to create the ground mesh in
  19799. * @returns the created ground mesh
  19800. */
  19801. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19802. }
  19803. }
  19804. declare module "babylonjs/Physics/physicsJoint" {
  19805. import { Vector3 } from "babylonjs/Maths/math";
  19806. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  19807. /**
  19808. * Interface for Physics-Joint data
  19809. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19810. */
  19811. export interface PhysicsJointData {
  19812. /**
  19813. * The main pivot of the joint
  19814. */
  19815. mainPivot?: Vector3;
  19816. /**
  19817. * The connected pivot of the joint
  19818. */
  19819. connectedPivot?: Vector3;
  19820. /**
  19821. * The main axis of the joint
  19822. */
  19823. mainAxis?: Vector3;
  19824. /**
  19825. * The connected axis of the joint
  19826. */
  19827. connectedAxis?: Vector3;
  19828. /**
  19829. * The collision of the joint
  19830. */
  19831. collision?: boolean;
  19832. /**
  19833. * Native Oimo/Cannon/Energy data
  19834. */
  19835. nativeParams?: any;
  19836. }
  19837. /**
  19838. * This is a holder class for the physics joint created by the physics plugin
  19839. * It holds a set of functions to control the underlying joint
  19840. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19841. */
  19842. export class PhysicsJoint {
  19843. /**
  19844. * The type of the physics joint
  19845. */
  19846. type: number;
  19847. /**
  19848. * The data for the physics joint
  19849. */
  19850. jointData: PhysicsJointData;
  19851. private _physicsJoint;
  19852. protected _physicsPlugin: IPhysicsEnginePlugin;
  19853. /**
  19854. * Initializes the physics joint
  19855. * @param type The type of the physics joint
  19856. * @param jointData The data for the physics joint
  19857. */
  19858. constructor(
  19859. /**
  19860. * The type of the physics joint
  19861. */
  19862. type: number,
  19863. /**
  19864. * The data for the physics joint
  19865. */
  19866. jointData: PhysicsJointData);
  19867. /**
  19868. * Gets the physics joint
  19869. */
  19870. /**
  19871. * Sets the physics joint
  19872. */
  19873. physicsJoint: any;
  19874. /**
  19875. * Sets the physics plugin
  19876. */
  19877. physicsPlugin: IPhysicsEnginePlugin;
  19878. /**
  19879. * Execute a function that is physics-plugin specific.
  19880. * @param {Function} func the function that will be executed.
  19881. * It accepts two parameters: the physics world and the physics joint
  19882. */
  19883. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19884. /**
  19885. * Distance-Joint type
  19886. */
  19887. static DistanceJoint: number;
  19888. /**
  19889. * Hinge-Joint type
  19890. */
  19891. static HingeJoint: number;
  19892. /**
  19893. * Ball-and-Socket joint type
  19894. */
  19895. static BallAndSocketJoint: number;
  19896. /**
  19897. * Wheel-Joint type
  19898. */
  19899. static WheelJoint: number;
  19900. /**
  19901. * Slider-Joint type
  19902. */
  19903. static SliderJoint: number;
  19904. /**
  19905. * Prismatic-Joint type
  19906. */
  19907. static PrismaticJoint: number;
  19908. /**
  19909. * Universal-Joint type
  19910. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19911. */
  19912. static UniversalJoint: number;
  19913. /**
  19914. * Hinge-Joint 2 type
  19915. */
  19916. static Hinge2Joint: number;
  19917. /**
  19918. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19919. */
  19920. static PointToPointJoint: number;
  19921. /**
  19922. * Spring-Joint type
  19923. */
  19924. static SpringJoint: number;
  19925. /**
  19926. * Lock-Joint type
  19927. */
  19928. static LockJoint: number;
  19929. }
  19930. /**
  19931. * A class representing a physics distance joint
  19932. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19933. */
  19934. export class DistanceJoint extends PhysicsJoint {
  19935. /**
  19936. *
  19937. * @param jointData The data for the Distance-Joint
  19938. */
  19939. constructor(jointData: DistanceJointData);
  19940. /**
  19941. * Update the predefined distance.
  19942. * @param maxDistance The maximum preferred distance
  19943. * @param minDistance The minimum preferred distance
  19944. */
  19945. updateDistance(maxDistance: number, minDistance?: number): void;
  19946. }
  19947. /**
  19948. * Represents a Motor-Enabled Joint
  19949. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19950. */
  19951. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19952. /**
  19953. * Initializes the Motor-Enabled Joint
  19954. * @param type The type of the joint
  19955. * @param jointData The physica joint data for the joint
  19956. */
  19957. constructor(type: number, jointData: PhysicsJointData);
  19958. /**
  19959. * Set the motor values.
  19960. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19961. * @param force the force to apply
  19962. * @param maxForce max force for this motor.
  19963. */
  19964. setMotor(force?: number, maxForce?: number): void;
  19965. /**
  19966. * Set the motor's limits.
  19967. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19968. * @param upperLimit The upper limit of the motor
  19969. * @param lowerLimit The lower limit of the motor
  19970. */
  19971. setLimit(upperLimit: number, lowerLimit?: number): void;
  19972. }
  19973. /**
  19974. * This class represents a single physics Hinge-Joint
  19975. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19976. */
  19977. export class HingeJoint extends MotorEnabledJoint {
  19978. /**
  19979. * Initializes the Hinge-Joint
  19980. * @param jointData The joint data for the Hinge-Joint
  19981. */
  19982. constructor(jointData: PhysicsJointData);
  19983. /**
  19984. * Set the motor values.
  19985. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19986. * @param {number} force the force to apply
  19987. * @param {number} maxForce max force for this motor.
  19988. */
  19989. setMotor(force?: number, maxForce?: number): void;
  19990. /**
  19991. * Set the motor's limits.
  19992. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19993. * @param upperLimit The upper limit of the motor
  19994. * @param lowerLimit The lower limit of the motor
  19995. */
  19996. setLimit(upperLimit: number, lowerLimit?: number): void;
  19997. }
  19998. /**
  19999. * This class represents a dual hinge physics joint (same as wheel joint)
  20000. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20001. */
  20002. export class Hinge2Joint extends MotorEnabledJoint {
  20003. /**
  20004. * Initializes the Hinge2-Joint
  20005. * @param jointData The joint data for the Hinge2-Joint
  20006. */
  20007. constructor(jointData: PhysicsJointData);
  20008. /**
  20009. * Set the motor values.
  20010. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20011. * @param {number} targetSpeed the speed the motor is to reach
  20012. * @param {number} maxForce max force for this motor.
  20013. * @param {motorIndex} the motor's index, 0 or 1.
  20014. */
  20015. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  20016. /**
  20017. * Set the motor limits.
  20018. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20019. * @param {number} upperLimit the upper limit
  20020. * @param {number} lowerLimit lower limit
  20021. * @param {motorIndex} the motor's index, 0 or 1.
  20022. */
  20023. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20024. }
  20025. /**
  20026. * Interface for a motor enabled joint
  20027. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20028. */
  20029. export interface IMotorEnabledJoint {
  20030. /**
  20031. * Physics joint
  20032. */
  20033. physicsJoint: any;
  20034. /**
  20035. * Sets the motor of the motor-enabled joint
  20036. * @param force The force of the motor
  20037. * @param maxForce The maximum force of the motor
  20038. * @param motorIndex The index of the motor
  20039. */
  20040. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  20041. /**
  20042. * Sets the limit of the motor
  20043. * @param upperLimit The upper limit of the motor
  20044. * @param lowerLimit The lower limit of the motor
  20045. * @param motorIndex The index of the motor
  20046. */
  20047. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20048. }
  20049. /**
  20050. * Joint data for a Distance-Joint
  20051. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20052. */
  20053. export interface DistanceJointData extends PhysicsJointData {
  20054. /**
  20055. * Max distance the 2 joint objects can be apart
  20056. */
  20057. maxDistance: number;
  20058. }
  20059. /**
  20060. * Joint data from a spring joint
  20061. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20062. */
  20063. export interface SpringJointData extends PhysicsJointData {
  20064. /**
  20065. * Length of the spring
  20066. */
  20067. length: number;
  20068. /**
  20069. * Stiffness of the spring
  20070. */
  20071. stiffness: number;
  20072. /**
  20073. * Damping of the spring
  20074. */
  20075. damping: number;
  20076. /** this callback will be called when applying the force to the impostors. */
  20077. forceApplicationCallback: () => void;
  20078. }
  20079. }
  20080. declare module "babylonjs/Physics/physicsRaycastResult" {
  20081. import { Vector3 } from "babylonjs/Maths/math";
  20082. /**
  20083. * Holds the data for the raycast result
  20084. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20085. */
  20086. export class PhysicsRaycastResult {
  20087. private _hasHit;
  20088. private _hitDistance;
  20089. private _hitNormalWorld;
  20090. private _hitPointWorld;
  20091. private _rayFromWorld;
  20092. private _rayToWorld;
  20093. /**
  20094. * Gets if there was a hit
  20095. */
  20096. readonly hasHit: boolean;
  20097. /**
  20098. * Gets the distance from the hit
  20099. */
  20100. readonly hitDistance: number;
  20101. /**
  20102. * Gets the hit normal/direction in the world
  20103. */
  20104. readonly hitNormalWorld: Vector3;
  20105. /**
  20106. * Gets the hit point in the world
  20107. */
  20108. readonly hitPointWorld: Vector3;
  20109. /**
  20110. * Gets the ray "start point" of the ray in the world
  20111. */
  20112. readonly rayFromWorld: Vector3;
  20113. /**
  20114. * Gets the ray "end point" of the ray in the world
  20115. */
  20116. readonly rayToWorld: Vector3;
  20117. /**
  20118. * Sets the hit data (normal & point in world space)
  20119. * @param hitNormalWorld defines the normal in world space
  20120. * @param hitPointWorld defines the point in world space
  20121. */
  20122. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  20123. /**
  20124. * Sets the distance from the start point to the hit point
  20125. * @param distance
  20126. */
  20127. setHitDistance(distance: number): void;
  20128. /**
  20129. * Calculates the distance manually
  20130. */
  20131. calculateHitDistance(): void;
  20132. /**
  20133. * Resets all the values to default
  20134. * @param from The from point on world space
  20135. * @param to The to point on world space
  20136. */
  20137. reset(from?: Vector3, to?: Vector3): void;
  20138. }
  20139. /**
  20140. * Interface for the size containing width and height
  20141. */
  20142. interface IXYZ {
  20143. /**
  20144. * X
  20145. */
  20146. x: number;
  20147. /**
  20148. * Y
  20149. */
  20150. y: number;
  20151. /**
  20152. * Z
  20153. */
  20154. z: number;
  20155. }
  20156. }
  20157. declare module "babylonjs/Physics/IPhysicsEngine" {
  20158. import { Nullable } from "babylonjs/types";
  20159. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  20160. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20161. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20162. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  20163. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  20164. /**
  20165. * Interface used to describe a physics joint
  20166. */
  20167. export interface PhysicsImpostorJoint {
  20168. /** Defines the main impostor to which the joint is linked */
  20169. mainImpostor: PhysicsImpostor;
  20170. /** Defines the impostor that is connected to the main impostor using this joint */
  20171. connectedImpostor: PhysicsImpostor;
  20172. /** Defines the joint itself */
  20173. joint: PhysicsJoint;
  20174. }
  20175. /** @hidden */
  20176. export interface IPhysicsEnginePlugin {
  20177. world: any;
  20178. name: string;
  20179. setGravity(gravity: Vector3): void;
  20180. setTimeStep(timeStep: number): void;
  20181. getTimeStep(): number;
  20182. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  20183. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20184. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20185. generatePhysicsBody(impostor: PhysicsImpostor): void;
  20186. removePhysicsBody(impostor: PhysicsImpostor): void;
  20187. generateJoint(joint: PhysicsImpostorJoint): void;
  20188. removeJoint(joint: PhysicsImpostorJoint): void;
  20189. isSupported(): boolean;
  20190. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  20191. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  20192. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20193. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20194. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20195. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20196. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  20197. getBodyMass(impostor: PhysicsImpostor): number;
  20198. getBodyFriction(impostor: PhysicsImpostor): number;
  20199. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  20200. getBodyRestitution(impostor: PhysicsImpostor): number;
  20201. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  20202. getBodyPressure?(impostor: PhysicsImpostor): number;
  20203. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  20204. getBodyStiffness?(impostor: PhysicsImpostor): number;
  20205. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  20206. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  20207. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  20208. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  20209. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  20210. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20211. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20212. sleepBody(impostor: PhysicsImpostor): void;
  20213. wakeUpBody(impostor: PhysicsImpostor): void;
  20214. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20215. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  20216. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  20217. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20218. getRadius(impostor: PhysicsImpostor): number;
  20219. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  20220. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  20221. dispose(): void;
  20222. }
  20223. /**
  20224. * Interface used to define a physics engine
  20225. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  20226. */
  20227. export interface IPhysicsEngine {
  20228. /**
  20229. * Gets the gravity vector used by the simulation
  20230. */
  20231. gravity: Vector3;
  20232. /**
  20233. * Sets the gravity vector used by the simulation
  20234. * @param gravity defines the gravity vector to use
  20235. */
  20236. setGravity(gravity: Vector3): void;
  20237. /**
  20238. * Set the time step of the physics engine.
  20239. * Default is 1/60.
  20240. * To slow it down, enter 1/600 for example.
  20241. * To speed it up, 1/30
  20242. * @param newTimeStep the new timestep to apply to this world.
  20243. */
  20244. setTimeStep(newTimeStep: number): void;
  20245. /**
  20246. * Get the time step of the physics engine.
  20247. * @returns the current time step
  20248. */
  20249. getTimeStep(): number;
  20250. /**
  20251. * Release all resources
  20252. */
  20253. dispose(): void;
  20254. /**
  20255. * Gets the name of the current physics plugin
  20256. * @returns the name of the plugin
  20257. */
  20258. getPhysicsPluginName(): string;
  20259. /**
  20260. * Adding a new impostor for the impostor tracking.
  20261. * This will be done by the impostor itself.
  20262. * @param impostor the impostor to add
  20263. */
  20264. addImpostor(impostor: PhysicsImpostor): void;
  20265. /**
  20266. * Remove an impostor from the engine.
  20267. * This impostor and its mesh will not longer be updated by the physics engine.
  20268. * @param impostor the impostor to remove
  20269. */
  20270. removeImpostor(impostor: PhysicsImpostor): void;
  20271. /**
  20272. * Add a joint to the physics engine
  20273. * @param mainImpostor defines the main impostor to which the joint is added.
  20274. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  20275. * @param joint defines the joint that will connect both impostors.
  20276. */
  20277. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20278. /**
  20279. * Removes a joint from the simulation
  20280. * @param mainImpostor defines the impostor used with the joint
  20281. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  20282. * @param joint defines the joint to remove
  20283. */
  20284. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20285. /**
  20286. * Gets the current plugin used to run the simulation
  20287. * @returns current plugin
  20288. */
  20289. getPhysicsPlugin(): IPhysicsEnginePlugin;
  20290. /**
  20291. * Gets the list of physic impostors
  20292. * @returns an array of PhysicsImpostor
  20293. */
  20294. getImpostors(): Array<PhysicsImpostor>;
  20295. /**
  20296. * Gets the impostor for a physics enabled object
  20297. * @param object defines the object impersonated by the impostor
  20298. * @returns the PhysicsImpostor or null if not found
  20299. */
  20300. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20301. /**
  20302. * Gets the impostor for a physics body object
  20303. * @param body defines physics body used by the impostor
  20304. * @returns the PhysicsImpostor or null if not found
  20305. */
  20306. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  20307. /**
  20308. * Does a raycast in the physics world
  20309. * @param from when should the ray start?
  20310. * @param to when should the ray end?
  20311. * @returns PhysicsRaycastResult
  20312. */
  20313. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20314. /**
  20315. * Called by the scene. No need to call it.
  20316. * @param delta defines the timespam between frames
  20317. */
  20318. _step(delta: number): void;
  20319. }
  20320. }
  20321. declare module "babylonjs/Physics/physicsImpostor" {
  20322. import { Nullable, IndicesArray } from "babylonjs/types";
  20323. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  20324. import { TransformNode } from "babylonjs/Meshes/transformNode";
  20325. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20326. import { Scene } from "babylonjs/scene";
  20327. import { Bone } from "babylonjs/Bones/bone";
  20328. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  20329. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  20330. /**
  20331. * The interface for the physics imposter parameters
  20332. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20333. */
  20334. export interface PhysicsImpostorParameters {
  20335. /**
  20336. * The mass of the physics imposter
  20337. */
  20338. mass: number;
  20339. /**
  20340. * The friction of the physics imposter
  20341. */
  20342. friction?: number;
  20343. /**
  20344. * The coefficient of restitution of the physics imposter
  20345. */
  20346. restitution?: number;
  20347. /**
  20348. * The native options of the physics imposter
  20349. */
  20350. nativeOptions?: any;
  20351. /**
  20352. * Specifies if the parent should be ignored
  20353. */
  20354. ignoreParent?: boolean;
  20355. /**
  20356. * Specifies if bi-directional transformations should be disabled
  20357. */
  20358. disableBidirectionalTransformation?: boolean;
  20359. /**
  20360. * The pressure inside the physics imposter, soft object only
  20361. */
  20362. pressure?: number;
  20363. /**
  20364. * The stiffness the physics imposter, soft object only
  20365. */
  20366. stiffness?: number;
  20367. /**
  20368. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  20369. */
  20370. velocityIterations?: number;
  20371. /**
  20372. * The number of iterations used in maintaining consistent vertex positions, soft object only
  20373. */
  20374. positionIterations?: number;
  20375. /**
  20376. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  20377. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  20378. * Add to fix multiple points
  20379. */
  20380. fixedPoints?: number;
  20381. /**
  20382. * The collision margin around a soft object
  20383. */
  20384. margin?: number;
  20385. /**
  20386. * The collision margin around a soft object
  20387. */
  20388. damping?: number;
  20389. /**
  20390. * The path for a rope based on an extrusion
  20391. */
  20392. path?: any;
  20393. /**
  20394. * The shape of an extrusion used for a rope based on an extrusion
  20395. */
  20396. shape?: any;
  20397. }
  20398. /**
  20399. * Interface for a physics-enabled object
  20400. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20401. */
  20402. export interface IPhysicsEnabledObject {
  20403. /**
  20404. * The position of the physics-enabled object
  20405. */
  20406. position: Vector3;
  20407. /**
  20408. * The rotation of the physics-enabled object
  20409. */
  20410. rotationQuaternion: Nullable<Quaternion>;
  20411. /**
  20412. * The scale of the physics-enabled object
  20413. */
  20414. scaling: Vector3;
  20415. /**
  20416. * The rotation of the physics-enabled object
  20417. */
  20418. rotation?: Vector3;
  20419. /**
  20420. * The parent of the physics-enabled object
  20421. */
  20422. parent?: any;
  20423. /**
  20424. * The bounding info of the physics-enabled object
  20425. * @returns The bounding info of the physics-enabled object
  20426. */
  20427. getBoundingInfo(): BoundingInfo;
  20428. /**
  20429. * Computes the world matrix
  20430. * @param force Specifies if the world matrix should be computed by force
  20431. * @returns A world matrix
  20432. */
  20433. computeWorldMatrix(force: boolean): Matrix;
  20434. /**
  20435. * Gets the world matrix
  20436. * @returns A world matrix
  20437. */
  20438. getWorldMatrix?(): Matrix;
  20439. /**
  20440. * Gets the child meshes
  20441. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  20442. * @returns An array of abstract meshes
  20443. */
  20444. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20445. /**
  20446. * Gets the vertex data
  20447. * @param kind The type of vertex data
  20448. * @returns A nullable array of numbers, or a float32 array
  20449. */
  20450. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20451. /**
  20452. * Gets the indices from the mesh
  20453. * @returns A nullable array of index arrays
  20454. */
  20455. getIndices?(): Nullable<IndicesArray>;
  20456. /**
  20457. * Gets the scene from the mesh
  20458. * @returns the indices array or null
  20459. */
  20460. getScene?(): Scene;
  20461. /**
  20462. * Gets the absolute position from the mesh
  20463. * @returns the absolute position
  20464. */
  20465. getAbsolutePosition(): Vector3;
  20466. /**
  20467. * Gets the absolute pivot point from the mesh
  20468. * @returns the absolute pivot point
  20469. */
  20470. getAbsolutePivotPoint(): Vector3;
  20471. /**
  20472. * Rotates the mesh
  20473. * @param axis The axis of rotation
  20474. * @param amount The amount of rotation
  20475. * @param space The space of the rotation
  20476. * @returns The rotation transform node
  20477. */
  20478. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20479. /**
  20480. * Translates the mesh
  20481. * @param axis The axis of translation
  20482. * @param distance The distance of translation
  20483. * @param space The space of the translation
  20484. * @returns The transform node
  20485. */
  20486. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20487. /**
  20488. * Sets the absolute position of the mesh
  20489. * @param absolutePosition The absolute position of the mesh
  20490. * @returns The transform node
  20491. */
  20492. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20493. /**
  20494. * Gets the class name of the mesh
  20495. * @returns The class name
  20496. */
  20497. getClassName(): string;
  20498. }
  20499. /**
  20500. * Represents a physics imposter
  20501. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20502. */
  20503. export class PhysicsImpostor {
  20504. /**
  20505. * The physics-enabled object used as the physics imposter
  20506. */
  20507. object: IPhysicsEnabledObject;
  20508. /**
  20509. * The type of the physics imposter
  20510. */
  20511. type: number;
  20512. private _options;
  20513. private _scene?;
  20514. /**
  20515. * The default object size of the imposter
  20516. */
  20517. static DEFAULT_OBJECT_SIZE: Vector3;
  20518. /**
  20519. * The identity quaternion of the imposter
  20520. */
  20521. static IDENTITY_QUATERNION: Quaternion;
  20522. /** @hidden */
  20523. _pluginData: any;
  20524. private _physicsEngine;
  20525. private _physicsBody;
  20526. private _bodyUpdateRequired;
  20527. private _onBeforePhysicsStepCallbacks;
  20528. private _onAfterPhysicsStepCallbacks;
  20529. /** @hidden */
  20530. _onPhysicsCollideCallbacks: Array<{
  20531. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20532. otherImpostors: Array<PhysicsImpostor>;
  20533. }>;
  20534. private _deltaPosition;
  20535. private _deltaRotation;
  20536. private _deltaRotationConjugated;
  20537. /** hidden */
  20538. _isFromLine: boolean;
  20539. private _parent;
  20540. private _isDisposed;
  20541. private static _tmpVecs;
  20542. private static _tmpQuat;
  20543. /**
  20544. * Specifies if the physics imposter is disposed
  20545. */
  20546. readonly isDisposed: boolean;
  20547. /**
  20548. * Gets the mass of the physics imposter
  20549. */
  20550. mass: number;
  20551. /**
  20552. * Gets the coefficient of friction
  20553. */
  20554. /**
  20555. * Sets the coefficient of friction
  20556. */
  20557. friction: number;
  20558. /**
  20559. * Gets the coefficient of restitution
  20560. */
  20561. /**
  20562. * Sets the coefficient of restitution
  20563. */
  20564. restitution: number;
  20565. /**
  20566. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  20567. */
  20568. /**
  20569. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  20570. */
  20571. pressure: number;
  20572. /**
  20573. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20574. */
  20575. /**
  20576. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20577. */
  20578. stiffness: number;
  20579. /**
  20580. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20581. */
  20582. /**
  20583. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20584. */
  20585. velocityIterations: number;
  20586. /**
  20587. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20588. */
  20589. /**
  20590. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20591. */
  20592. positionIterations: number;
  20593. /**
  20594. * The unique id of the physics imposter
  20595. * set by the physics engine when adding this impostor to the array
  20596. */
  20597. uniqueId: number;
  20598. /**
  20599. * @hidden
  20600. */
  20601. soft: boolean;
  20602. /**
  20603. * @hidden
  20604. */
  20605. segments: number;
  20606. private _joints;
  20607. /**
  20608. * Initializes the physics imposter
  20609. * @param object The physics-enabled object used as the physics imposter
  20610. * @param type The type of the physics imposter
  20611. * @param _options The options for the physics imposter
  20612. * @param _scene The Babylon scene
  20613. */
  20614. constructor(
  20615. /**
  20616. * The physics-enabled object used as the physics imposter
  20617. */
  20618. object: IPhysicsEnabledObject,
  20619. /**
  20620. * The type of the physics imposter
  20621. */
  20622. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20623. /**
  20624. * This function will completly initialize this impostor.
  20625. * It will create a new body - but only if this mesh has no parent.
  20626. * If it has, this impostor will not be used other than to define the impostor
  20627. * of the child mesh.
  20628. * @hidden
  20629. */
  20630. _init(): void;
  20631. private _getPhysicsParent;
  20632. /**
  20633. * Should a new body be generated.
  20634. * @returns boolean specifying if body initialization is required
  20635. */
  20636. isBodyInitRequired(): boolean;
  20637. /**
  20638. * Sets the updated scaling
  20639. * @param updated Specifies if the scaling is updated
  20640. */
  20641. setScalingUpdated(): void;
  20642. /**
  20643. * Force a regeneration of this or the parent's impostor's body.
  20644. * Use under cautious - This will remove all joints already implemented.
  20645. */
  20646. forceUpdate(): void;
  20647. /**
  20648. * Gets the body that holds this impostor. Either its own, or its parent.
  20649. */
  20650. /**
  20651. * Set the physics body. Used mainly by the physics engine/plugin
  20652. */
  20653. physicsBody: any;
  20654. /**
  20655. * Get the parent of the physics imposter
  20656. * @returns Physics imposter or null
  20657. */
  20658. /**
  20659. * Sets the parent of the physics imposter
  20660. */
  20661. parent: Nullable<PhysicsImpostor>;
  20662. /**
  20663. * Resets the update flags
  20664. */
  20665. resetUpdateFlags(): void;
  20666. /**
  20667. * Gets the object extend size
  20668. * @returns the object extend size
  20669. */
  20670. getObjectExtendSize(): Vector3;
  20671. /**
  20672. * Gets the object center
  20673. * @returns The object center
  20674. */
  20675. getObjectCenter(): Vector3;
  20676. /**
  20677. * Get a specific parametes from the options parameter
  20678. * @param paramName The object parameter name
  20679. * @returns The object parameter
  20680. */
  20681. getParam(paramName: string): any;
  20682. /**
  20683. * Sets a specific parameter in the options given to the physics plugin
  20684. * @param paramName The parameter name
  20685. * @param value The value of the parameter
  20686. */
  20687. setParam(paramName: string, value: number): void;
  20688. /**
  20689. * Specifically change the body's mass option. Won't recreate the physics body object
  20690. * @param mass The mass of the physics imposter
  20691. */
  20692. setMass(mass: number): void;
  20693. /**
  20694. * Gets the linear velocity
  20695. * @returns linear velocity or null
  20696. */
  20697. getLinearVelocity(): Nullable<Vector3>;
  20698. /**
  20699. * Sets the linear velocity
  20700. * @param velocity linear velocity or null
  20701. */
  20702. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20703. /**
  20704. * Gets the angular velocity
  20705. * @returns angular velocity or null
  20706. */
  20707. getAngularVelocity(): Nullable<Vector3>;
  20708. /**
  20709. * Sets the angular velocity
  20710. * @param velocity The velocity or null
  20711. */
  20712. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20713. /**
  20714. * Execute a function with the physics plugin native code
  20715. * Provide a function the will have two variables - the world object and the physics body object
  20716. * @param func The function to execute with the physics plugin native code
  20717. */
  20718. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20719. /**
  20720. * Register a function that will be executed before the physics world is stepping forward
  20721. * @param func The function to execute before the physics world is stepped forward
  20722. */
  20723. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20724. /**
  20725. * Unregister a function that will be executed before the physics world is stepping forward
  20726. * @param func The function to execute before the physics world is stepped forward
  20727. */
  20728. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20729. /**
  20730. * Register a function that will be executed after the physics step
  20731. * @param func The function to execute after physics step
  20732. */
  20733. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20734. /**
  20735. * Unregisters a function that will be executed after the physics step
  20736. * @param func The function to execute after physics step
  20737. */
  20738. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20739. /**
  20740. * register a function that will be executed when this impostor collides against a different body
  20741. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20742. * @param func Callback that is executed on collision
  20743. */
  20744. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20745. /**
  20746. * Unregisters the physics imposter on contact
  20747. * @param collideAgainst The physics object to collide against
  20748. * @param func Callback to execute on collision
  20749. */
  20750. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20751. private _tmpQuat;
  20752. private _tmpQuat2;
  20753. /**
  20754. * Get the parent rotation
  20755. * @returns The parent rotation
  20756. */
  20757. getParentsRotation(): Quaternion;
  20758. /**
  20759. * this function is executed by the physics engine.
  20760. */
  20761. beforeStep: () => void;
  20762. /**
  20763. * this function is executed by the physics engine
  20764. */
  20765. afterStep: () => void;
  20766. /**
  20767. * Legacy collision detection event support
  20768. */
  20769. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20770. /**
  20771. * event and body object due to cannon's event-based architecture.
  20772. */
  20773. onCollide: (e: {
  20774. body: any;
  20775. }) => void;
  20776. /**
  20777. * Apply a force
  20778. * @param force The force to apply
  20779. * @param contactPoint The contact point for the force
  20780. * @returns The physics imposter
  20781. */
  20782. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20783. /**
  20784. * Apply an impulse
  20785. * @param force The impulse force
  20786. * @param contactPoint The contact point for the impulse force
  20787. * @returns The physics imposter
  20788. */
  20789. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20790. /**
  20791. * A help function to create a joint
  20792. * @param otherImpostor A physics imposter used to create a joint
  20793. * @param jointType The type of joint
  20794. * @param jointData The data for the joint
  20795. * @returns The physics imposter
  20796. */
  20797. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20798. /**
  20799. * Add a joint to this impostor with a different impostor
  20800. * @param otherImpostor A physics imposter used to add a joint
  20801. * @param joint The joint to add
  20802. * @returns The physics imposter
  20803. */
  20804. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20805. /**
  20806. * Add an anchor to a cloth impostor
  20807. * @param otherImpostor rigid impostor to anchor to
  20808. * @param width ratio across width from 0 to 1
  20809. * @param height ratio up height from 0 to 1
  20810. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  20811. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  20812. * @returns impostor the soft imposter
  20813. */
  20814. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20815. /**
  20816. * Add a hook to a rope impostor
  20817. * @param otherImpostor rigid impostor to anchor to
  20818. * @param length ratio across rope from 0 to 1
  20819. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  20820. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  20821. * @returns impostor the rope imposter
  20822. */
  20823. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20824. /**
  20825. * Will keep this body still, in a sleep mode.
  20826. * @returns the physics imposter
  20827. */
  20828. sleep(): PhysicsImpostor;
  20829. /**
  20830. * Wake the body up.
  20831. * @returns The physics imposter
  20832. */
  20833. wakeUp(): PhysicsImpostor;
  20834. /**
  20835. * Clones the physics imposter
  20836. * @param newObject The physics imposter clones to this physics-enabled object
  20837. * @returns A nullable physics imposter
  20838. */
  20839. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20840. /**
  20841. * Disposes the physics imposter
  20842. */
  20843. dispose(): void;
  20844. /**
  20845. * Sets the delta position
  20846. * @param position The delta position amount
  20847. */
  20848. setDeltaPosition(position: Vector3): void;
  20849. /**
  20850. * Sets the delta rotation
  20851. * @param rotation The delta rotation amount
  20852. */
  20853. setDeltaRotation(rotation: Quaternion): void;
  20854. /**
  20855. * Gets the box size of the physics imposter and stores the result in the input parameter
  20856. * @param result Stores the box size
  20857. * @returns The physics imposter
  20858. */
  20859. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20860. /**
  20861. * Gets the radius of the physics imposter
  20862. * @returns Radius of the physics imposter
  20863. */
  20864. getRadius(): number;
  20865. /**
  20866. * Sync a bone with this impostor
  20867. * @param bone The bone to sync to the impostor.
  20868. * @param boneMesh The mesh that the bone is influencing.
  20869. * @param jointPivot The pivot of the joint / bone in local space.
  20870. * @param distToJoint Optional distance from the impostor to the joint.
  20871. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20872. */
  20873. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20874. /**
  20875. * Sync impostor to a bone
  20876. * @param bone The bone that the impostor will be synced to.
  20877. * @param boneMesh The mesh that the bone is influencing.
  20878. * @param jointPivot The pivot of the joint / bone in local space.
  20879. * @param distToJoint Optional distance from the impostor to the joint.
  20880. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20881. * @param boneAxis Optional vector3 axis the bone is aligned with
  20882. */
  20883. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20884. /**
  20885. * No-Imposter type
  20886. */
  20887. static NoImpostor: number;
  20888. /**
  20889. * Sphere-Imposter type
  20890. */
  20891. static SphereImpostor: number;
  20892. /**
  20893. * Box-Imposter type
  20894. */
  20895. static BoxImpostor: number;
  20896. /**
  20897. * Plane-Imposter type
  20898. */
  20899. static PlaneImpostor: number;
  20900. /**
  20901. * Mesh-imposter type
  20902. */
  20903. static MeshImpostor: number;
  20904. /**
  20905. * Cylinder-Imposter type
  20906. */
  20907. static CylinderImpostor: number;
  20908. /**
  20909. * Particle-Imposter type
  20910. */
  20911. static ParticleImpostor: number;
  20912. /**
  20913. * Heightmap-Imposter type
  20914. */
  20915. static HeightmapImpostor: number;
  20916. /**
  20917. * ConvexHull-Impostor type (Ammo.js plugin only)
  20918. */
  20919. static ConvexHullImpostor: number;
  20920. /**
  20921. * Rope-Imposter type
  20922. */
  20923. static RopeImpostor: number;
  20924. /**
  20925. * Cloth-Imposter type
  20926. */
  20927. static ClothImpostor: number;
  20928. /**
  20929. * Softbody-Imposter type
  20930. */
  20931. static SoftbodyImpostor: number;
  20932. }
  20933. }
  20934. declare module "babylonjs/Meshes/mesh" {
  20935. import { Observable } from "babylonjs/Misc/observable";
  20936. import { IAnimatable } from "babylonjs/Misc/tools";
  20937. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  20938. import { Camera } from "babylonjs/Cameras/camera";
  20939. import { Scene } from "babylonjs/scene";
  20940. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  20941. import { Engine } from "babylonjs/Engines/engine";
  20942. import { Node } from "babylonjs/node";
  20943. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20944. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  20945. import { Buffer } from "babylonjs/Meshes/buffer";
  20946. import { Geometry } from "babylonjs/Meshes/geometry";
  20947. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20948. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20949. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  20950. import { Effect } from "babylonjs/Materials/effect";
  20951. import { Material } from "babylonjs/Materials/material";
  20952. import { Skeleton } from "babylonjs/Bones/skeleton";
  20953. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  20954. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  20955. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20956. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  20957. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20958. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  20959. /**
  20960. * Class used to represent a specific level of detail of a mesh
  20961. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20962. */
  20963. export class MeshLODLevel {
  20964. /** Defines the distance where this level should star being displayed */
  20965. distance: number;
  20966. /** Defines the mesh to use to render this level */
  20967. mesh: Nullable<Mesh>;
  20968. /**
  20969. * Creates a new LOD level
  20970. * @param distance defines the distance where this level should star being displayed
  20971. * @param mesh defines the mesh to use to render this level
  20972. */
  20973. constructor(
  20974. /** Defines the distance where this level should star being displayed */
  20975. distance: number,
  20976. /** Defines the mesh to use to render this level */
  20977. mesh: Nullable<Mesh>);
  20978. }
  20979. /**
  20980. * @hidden
  20981. **/
  20982. export class _CreationDataStorage {
  20983. closePath?: boolean;
  20984. closeArray?: boolean;
  20985. idx: number[];
  20986. dashSize: number;
  20987. gapSize: number;
  20988. path3D: Path3D;
  20989. pathArray: Vector3[][];
  20990. arc: number;
  20991. radius: number;
  20992. cap: number;
  20993. tessellation: number;
  20994. }
  20995. /**
  20996. * @hidden
  20997. **/
  20998. class _InstanceDataStorage {
  20999. visibleInstances: any;
  21000. batchCache: _InstancesBatch;
  21001. instancesBufferSize: number;
  21002. instancesBuffer: Nullable<Buffer>;
  21003. instancesData: Float32Array;
  21004. overridenInstanceCount: number;
  21005. isFrozen: boolean;
  21006. _previousBatch: _InstancesBatch;
  21007. hardwareInstancedRendering: boolean;
  21008. }
  21009. /**
  21010. * @hidden
  21011. **/
  21012. export class _InstancesBatch {
  21013. mustReturn: boolean;
  21014. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  21015. renderSelf: boolean[];
  21016. hardwareInstancedRendering: boolean[];
  21017. }
  21018. /**
  21019. * Class used to represent renderable models
  21020. */
  21021. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  21022. /**
  21023. * Mesh side orientation : usually the external or front surface
  21024. */
  21025. static readonly FRONTSIDE: number;
  21026. /**
  21027. * Mesh side orientation : usually the internal or back surface
  21028. */
  21029. static readonly BACKSIDE: number;
  21030. /**
  21031. * Mesh side orientation : both internal and external or front and back surfaces
  21032. */
  21033. static readonly DOUBLESIDE: number;
  21034. /**
  21035. * Mesh side orientation : by default, `FRONTSIDE`
  21036. */
  21037. static readonly DEFAULTSIDE: number;
  21038. /**
  21039. * Mesh cap setting : no cap
  21040. */
  21041. static readonly NO_CAP: number;
  21042. /**
  21043. * Mesh cap setting : one cap at the beginning of the mesh
  21044. */
  21045. static readonly CAP_START: number;
  21046. /**
  21047. * Mesh cap setting : one cap at the end of the mesh
  21048. */
  21049. static readonly CAP_END: number;
  21050. /**
  21051. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  21052. */
  21053. static readonly CAP_ALL: number;
  21054. /**
  21055. * Gets the default side orientation.
  21056. * @param orientation the orientation to value to attempt to get
  21057. * @returns the default orientation
  21058. * @hidden
  21059. */
  21060. static _GetDefaultSideOrientation(orientation?: number): number;
  21061. private _onBeforeRenderObservable;
  21062. private _onBeforeBindObservable;
  21063. private _onAfterRenderObservable;
  21064. private _onBeforeDrawObservable;
  21065. /**
  21066. * An event triggered before rendering the mesh
  21067. */
  21068. readonly onBeforeRenderObservable: Observable<Mesh>;
  21069. /**
  21070. * An event triggered before binding the mesh
  21071. */
  21072. readonly onBeforeBindObservable: Observable<Mesh>;
  21073. /**
  21074. * An event triggered after rendering the mesh
  21075. */
  21076. readonly onAfterRenderObservable: Observable<Mesh>;
  21077. /**
  21078. * An event triggered before drawing the mesh
  21079. */
  21080. readonly onBeforeDrawObservable: Observable<Mesh>;
  21081. private _onBeforeDrawObserver;
  21082. /**
  21083. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  21084. */
  21085. onBeforeDraw: () => void;
  21086. /**
  21087. * Gets the delay loading state of the mesh (when delay loading is turned on)
  21088. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  21089. */
  21090. delayLoadState: number;
  21091. /**
  21092. * Gets the list of instances created from this mesh
  21093. * it is not supposed to be modified manually.
  21094. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  21095. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21096. */
  21097. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  21098. /**
  21099. * Gets the file containing delay loading data for this mesh
  21100. */
  21101. delayLoadingFile: string;
  21102. /** @hidden */
  21103. _binaryInfo: any;
  21104. private _LODLevels;
  21105. /**
  21106. * User defined function used to change how LOD level selection is done
  21107. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  21108. */
  21109. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  21110. private _morphTargetManager;
  21111. /**
  21112. * Gets or sets the morph target manager
  21113. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21114. */
  21115. morphTargetManager: Nullable<MorphTargetManager>;
  21116. /** @hidden */
  21117. _creationDataStorage: Nullable<_CreationDataStorage>;
  21118. /** @hidden */
  21119. _geometry: Nullable<Geometry>;
  21120. /** @hidden */
  21121. _delayInfo: Array<string>;
  21122. /** @hidden */
  21123. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  21124. /** @hidden */
  21125. _instanceDataStorage: _InstanceDataStorage;
  21126. private _effectiveMaterial;
  21127. /** @hidden */
  21128. _shouldGenerateFlatShading: boolean;
  21129. private _preActivateId;
  21130. /** @hidden */
  21131. _originalBuilderSideOrientation: number;
  21132. /**
  21133. * Use this property to change the original side orientation defined at construction time
  21134. */
  21135. overrideMaterialSideOrientation: Nullable<number>;
  21136. private _areNormalsFrozen;
  21137. private _sourcePositions;
  21138. private _sourceNormals;
  21139. private _source;
  21140. private meshMap;
  21141. /**
  21142. * Gets the source mesh (the one used to clone this one from)
  21143. */
  21144. readonly source: Nullable<Mesh>;
  21145. /**
  21146. * Gets or sets a boolean indicating that this mesh does not use index buffer
  21147. */
  21148. isUnIndexed: boolean;
  21149. /**
  21150. * @constructor
  21151. * @param name The value used by scene.getMeshByName() to do a lookup.
  21152. * @param scene The scene to add this mesh to.
  21153. * @param parent The parent of this mesh, if it has one
  21154. * @param source An optional Mesh from which geometry is shared, cloned.
  21155. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  21156. * When false, achieved by calling a clone(), also passing False.
  21157. * This will make creation of children, recursive.
  21158. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  21159. */
  21160. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  21161. /**
  21162. * Gets the class name
  21163. * @returns the string "Mesh".
  21164. */
  21165. getClassName(): string;
  21166. /** @hidden */
  21167. readonly _isMesh: boolean;
  21168. /**
  21169. * Returns a description of this mesh
  21170. * @param fullDetails define if full details about this mesh must be used
  21171. * @returns a descriptive string representing this mesh
  21172. */
  21173. toString(fullDetails?: boolean): string;
  21174. /** @hidden */
  21175. _unBindEffect(): void;
  21176. /**
  21177. * Gets a boolean indicating if this mesh has LOD
  21178. */
  21179. readonly hasLODLevels: boolean;
  21180. /**
  21181. * Gets the list of MeshLODLevel associated with the current mesh
  21182. * @returns an array of MeshLODLevel
  21183. */
  21184. getLODLevels(): MeshLODLevel[];
  21185. private _sortLODLevels;
  21186. /**
  21187. * Add a mesh as LOD level triggered at the given distance.
  21188. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21189. * @param distance The distance from the center of the object to show this level
  21190. * @param mesh The mesh to be added as LOD level (can be null)
  21191. * @return This mesh (for chaining)
  21192. */
  21193. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  21194. /**
  21195. * Returns the LOD level mesh at the passed distance or null if not found.
  21196. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21197. * @param distance The distance from the center of the object to show this level
  21198. * @returns a Mesh or `null`
  21199. */
  21200. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  21201. /**
  21202. * Remove a mesh from the LOD array
  21203. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21204. * @param mesh defines the mesh to be removed
  21205. * @return This mesh (for chaining)
  21206. */
  21207. removeLODLevel(mesh: Mesh): Mesh;
  21208. /**
  21209. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  21210. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21211. * @param camera defines the camera to use to compute distance
  21212. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  21213. * @return This mesh (for chaining)
  21214. */
  21215. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  21216. /**
  21217. * Gets the mesh internal Geometry object
  21218. */
  21219. readonly geometry: Nullable<Geometry>;
  21220. /**
  21221. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  21222. * @returns the total number of vertices
  21223. */
  21224. getTotalVertices(): number;
  21225. /**
  21226. * Returns the content of an associated vertex buffer
  21227. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21228. * - VertexBuffer.PositionKind
  21229. * - VertexBuffer.UVKind
  21230. * - VertexBuffer.UV2Kind
  21231. * - VertexBuffer.UV3Kind
  21232. * - VertexBuffer.UV4Kind
  21233. * - VertexBuffer.UV5Kind
  21234. * - VertexBuffer.UV6Kind
  21235. * - VertexBuffer.ColorKind
  21236. * - VertexBuffer.MatricesIndicesKind
  21237. * - VertexBuffer.MatricesIndicesExtraKind
  21238. * - VertexBuffer.MatricesWeightsKind
  21239. * - VertexBuffer.MatricesWeightsExtraKind
  21240. * @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
  21241. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  21242. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  21243. */
  21244. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21245. /**
  21246. * Returns the mesh VertexBuffer object from the requested `kind`
  21247. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21248. * - VertexBuffer.PositionKind
  21249. * - VertexBuffer.UVKind
  21250. * - VertexBuffer.UV2Kind
  21251. * - VertexBuffer.UV3Kind
  21252. * - VertexBuffer.UV4Kind
  21253. * - VertexBuffer.UV5Kind
  21254. * - VertexBuffer.UV6Kind
  21255. * - VertexBuffer.ColorKind
  21256. * - VertexBuffer.MatricesIndicesKind
  21257. * - VertexBuffer.MatricesIndicesExtraKind
  21258. * - VertexBuffer.MatricesWeightsKind
  21259. * - VertexBuffer.MatricesWeightsExtraKind
  21260. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  21261. */
  21262. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21263. /**
  21264. * Tests if a specific vertex buffer is associated with this mesh
  21265. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21266. * - VertexBuffer.PositionKind
  21267. * - VertexBuffer.UVKind
  21268. * - VertexBuffer.UV2Kind
  21269. * - VertexBuffer.UV3Kind
  21270. * - VertexBuffer.UV4Kind
  21271. * - VertexBuffer.UV5Kind
  21272. * - VertexBuffer.UV6Kind
  21273. * - VertexBuffer.ColorKind
  21274. * - VertexBuffer.MatricesIndicesKind
  21275. * - VertexBuffer.MatricesIndicesExtraKind
  21276. * - VertexBuffer.MatricesWeightsKind
  21277. * - VertexBuffer.MatricesWeightsExtraKind
  21278. * @returns a boolean
  21279. */
  21280. isVerticesDataPresent(kind: string): boolean;
  21281. /**
  21282. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21283. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21284. * - VertexBuffer.PositionKind
  21285. * - VertexBuffer.UVKind
  21286. * - VertexBuffer.UV2Kind
  21287. * - VertexBuffer.UV3Kind
  21288. * - VertexBuffer.UV4Kind
  21289. * - VertexBuffer.UV5Kind
  21290. * - VertexBuffer.UV6Kind
  21291. * - VertexBuffer.ColorKind
  21292. * - VertexBuffer.MatricesIndicesKind
  21293. * - VertexBuffer.MatricesIndicesExtraKind
  21294. * - VertexBuffer.MatricesWeightsKind
  21295. * - VertexBuffer.MatricesWeightsExtraKind
  21296. * @returns a boolean
  21297. */
  21298. isVertexBufferUpdatable(kind: string): boolean;
  21299. /**
  21300. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  21301. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21302. * - VertexBuffer.PositionKind
  21303. * - VertexBuffer.UVKind
  21304. * - VertexBuffer.UV2Kind
  21305. * - VertexBuffer.UV3Kind
  21306. * - VertexBuffer.UV4Kind
  21307. * - VertexBuffer.UV5Kind
  21308. * - VertexBuffer.UV6Kind
  21309. * - VertexBuffer.ColorKind
  21310. * - VertexBuffer.MatricesIndicesKind
  21311. * - VertexBuffer.MatricesIndicesExtraKind
  21312. * - VertexBuffer.MatricesWeightsKind
  21313. * - VertexBuffer.MatricesWeightsExtraKind
  21314. * @returns an array of strings
  21315. */
  21316. getVerticesDataKinds(): string[];
  21317. /**
  21318. * Returns a positive integer : the total number of indices in this mesh geometry.
  21319. * @returns the numner of indices or zero if the mesh has no geometry.
  21320. */
  21321. getTotalIndices(): number;
  21322. /**
  21323. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21324. * @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.
  21325. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21326. * @returns the indices array or an empty array if the mesh has no geometry
  21327. */
  21328. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21329. readonly isBlocked: boolean;
  21330. /**
  21331. * Determine if the current mesh is ready to be rendered
  21332. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21333. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21334. * @returns true if all associated assets are ready (material, textures, shaders)
  21335. */
  21336. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21337. /**
  21338. * 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.
  21339. */
  21340. readonly areNormalsFrozen: boolean;
  21341. /**
  21342. * 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.
  21343. * @returns the current mesh
  21344. */
  21345. freezeNormals(): Mesh;
  21346. /**
  21347. * 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
  21348. * @returns the current mesh
  21349. */
  21350. unfreezeNormals(): Mesh;
  21351. /**
  21352. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21353. */
  21354. overridenInstanceCount: number;
  21355. /** @hidden */
  21356. _preActivate(): Mesh;
  21357. /** @hidden */
  21358. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21359. /** @hidden */
  21360. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21361. /**
  21362. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21363. * This means the mesh underlying bounding box and sphere are recomputed.
  21364. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  21365. * @returns the current mesh
  21366. */
  21367. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  21368. /** @hidden */
  21369. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21370. /**
  21371. * This function will subdivide the mesh into multiple submeshes
  21372. * @param count defines the expected number of submeshes
  21373. */
  21374. subdivide(count: number): void;
  21375. /**
  21376. * Copy a FloatArray into a specific associated vertex buffer
  21377. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21378. * - VertexBuffer.PositionKind
  21379. * - VertexBuffer.UVKind
  21380. * - VertexBuffer.UV2Kind
  21381. * - VertexBuffer.UV3Kind
  21382. * - VertexBuffer.UV4Kind
  21383. * - VertexBuffer.UV5Kind
  21384. * - VertexBuffer.UV6Kind
  21385. * - VertexBuffer.ColorKind
  21386. * - VertexBuffer.MatricesIndicesKind
  21387. * - VertexBuffer.MatricesIndicesExtraKind
  21388. * - VertexBuffer.MatricesWeightsKind
  21389. * - VertexBuffer.MatricesWeightsExtraKind
  21390. * @param data defines the data source
  21391. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21392. * @param stride defines the data stride size (can be null)
  21393. * @returns the current mesh
  21394. */
  21395. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21396. /**
  21397. * Flags an associated vertex buffer as updatable
  21398. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  21399. * - VertexBuffer.PositionKind
  21400. * - VertexBuffer.UVKind
  21401. * - VertexBuffer.UV2Kind
  21402. * - VertexBuffer.UV3Kind
  21403. * - VertexBuffer.UV4Kind
  21404. * - VertexBuffer.UV5Kind
  21405. * - VertexBuffer.UV6Kind
  21406. * - VertexBuffer.ColorKind
  21407. * - VertexBuffer.MatricesIndicesKind
  21408. * - VertexBuffer.MatricesIndicesExtraKind
  21409. * - VertexBuffer.MatricesWeightsKind
  21410. * - VertexBuffer.MatricesWeightsExtraKind
  21411. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21412. */
  21413. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21414. /**
  21415. * Sets the mesh global Vertex Buffer
  21416. * @param buffer defines the buffer to use
  21417. * @returns the current mesh
  21418. */
  21419. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21420. /**
  21421. * Update a specific associated vertex buffer
  21422. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21423. * - VertexBuffer.PositionKind
  21424. * - VertexBuffer.UVKind
  21425. * - VertexBuffer.UV2Kind
  21426. * - VertexBuffer.UV3Kind
  21427. * - VertexBuffer.UV4Kind
  21428. * - VertexBuffer.UV5Kind
  21429. * - VertexBuffer.UV6Kind
  21430. * - VertexBuffer.ColorKind
  21431. * - VertexBuffer.MatricesIndicesKind
  21432. * - VertexBuffer.MatricesIndicesExtraKind
  21433. * - VertexBuffer.MatricesWeightsKind
  21434. * - VertexBuffer.MatricesWeightsExtraKind
  21435. * @param data defines the data source
  21436. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21437. * @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)
  21438. * @returns the current mesh
  21439. */
  21440. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21441. /**
  21442. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21443. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21444. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  21445. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  21446. * @returns the current mesh
  21447. */
  21448. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21449. /**
  21450. * Creates a un-shared specific occurence of the geometry for the mesh.
  21451. * @returns the current mesh
  21452. */
  21453. makeGeometryUnique(): Mesh;
  21454. /**
  21455. * Set the index buffer of this mesh
  21456. * @param indices defines the source data
  21457. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  21458. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  21459. * @returns the current mesh
  21460. */
  21461. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21462. /**
  21463. * Update the current index buffer
  21464. * @param indices defines the source data
  21465. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  21466. * @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)
  21467. * @returns the current mesh
  21468. */
  21469. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  21470. /**
  21471. * Invert the geometry to move from a right handed system to a left handed one.
  21472. * @returns the current mesh
  21473. */
  21474. toLeftHanded(): Mesh;
  21475. /** @hidden */
  21476. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21477. /** @hidden */
  21478. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  21479. /**
  21480. * Registers for this mesh a javascript function called just before the rendering process
  21481. * @param func defines the function to call before rendering this mesh
  21482. * @returns the current mesh
  21483. */
  21484. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21485. /**
  21486. * Disposes a previously registered javascript function called before the rendering
  21487. * @param func defines the function to remove
  21488. * @returns the current mesh
  21489. */
  21490. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21491. /**
  21492. * Registers for this mesh a javascript function called just after the rendering is complete
  21493. * @param func defines the function to call after rendering this mesh
  21494. * @returns the current mesh
  21495. */
  21496. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21497. /**
  21498. * Disposes a previously registered javascript function called after the rendering.
  21499. * @param func defines the function to remove
  21500. * @returns the current mesh
  21501. */
  21502. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21503. /** @hidden */
  21504. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21505. /** @hidden */
  21506. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21507. /** @hidden */
  21508. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21509. /** @hidden */
  21510. _freeze(): void;
  21511. /** @hidden */
  21512. _unFreeze(): void;
  21513. /**
  21514. * 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
  21515. * @param subMesh defines the subMesh to render
  21516. * @param enableAlphaMode defines if alpha mode can be changed
  21517. * @returns the current mesh
  21518. */
  21519. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21520. private _onBeforeDraw;
  21521. /**
  21522. * Renormalize the mesh and patch it up if there are no weights
  21523. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  21524. * However in the case of zero weights then we set just a single influence to 1.
  21525. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  21526. */
  21527. cleanMatrixWeights(): void;
  21528. private normalizeSkinFourWeights;
  21529. private normalizeSkinWeightsAndExtra;
  21530. /**
  21531. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  21532. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  21533. * the user know there was an issue with importing the mesh
  21534. * @returns a validation object with skinned, valid and report string
  21535. */
  21536. validateSkinning(): {
  21537. skinned: boolean;
  21538. valid: boolean;
  21539. report: string;
  21540. };
  21541. /** @hidden */
  21542. _checkDelayState(): Mesh;
  21543. private _queueLoad;
  21544. /**
  21545. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21546. * A mesh is in the frustum if its bounding box intersects the frustum
  21547. * @param frustumPlanes defines the frustum to test
  21548. * @returns true if the mesh is in the frustum planes
  21549. */
  21550. isInFrustum(frustumPlanes: Plane[]): boolean;
  21551. /**
  21552. * Sets the mesh material by the material or multiMaterial `id` property
  21553. * @param id is a string identifying the material or the multiMaterial
  21554. * @returns the current mesh
  21555. */
  21556. setMaterialByID(id: string): Mesh;
  21557. /**
  21558. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21559. * @returns an array of IAnimatable
  21560. */
  21561. getAnimatables(): IAnimatable[];
  21562. /**
  21563. * Modifies the mesh geometry according to the passed transformation matrix.
  21564. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21565. * The mesh normals are modified using the same transformation.
  21566. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21567. * @param transform defines the transform matrix to use
  21568. * @see http://doc.babylonjs.com/resources/baking_transformations
  21569. * @returns the current mesh
  21570. */
  21571. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21572. /**
  21573. * Modifies the mesh geometry according to its own current World Matrix.
  21574. * The mesh World Matrix is then reset.
  21575. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21576. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21577. * @see http://doc.babylonjs.com/resources/baking_transformations
  21578. * @returns the current mesh
  21579. */
  21580. bakeCurrentTransformIntoVertices(): Mesh;
  21581. /** @hidden */
  21582. readonly _positions: Nullable<Vector3[]>;
  21583. /** @hidden */
  21584. _resetPointsArrayCache(): Mesh;
  21585. /** @hidden */
  21586. _generatePointsArray(): boolean;
  21587. /**
  21588. * Returns a new Mesh object generated from the current mesh properties.
  21589. * This method must not get confused with createInstance()
  21590. * @param name is a string, the name given to the new mesh
  21591. * @param newParent can be any Node object (default `null`)
  21592. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  21593. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  21594. * @returns a new mesh
  21595. */
  21596. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21597. /**
  21598. * Releases resources associated with this mesh.
  21599. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21600. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21601. */
  21602. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21603. /**
  21604. * Modifies the mesh geometry according to a displacement map.
  21605. * 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.
  21606. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21607. * @param url is a string, the URL from the image file is to be downloaded.
  21608. * @param minHeight is the lower limit of the displacement.
  21609. * @param maxHeight is the upper limit of the displacement.
  21610. * @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.
  21611. * @param uvOffset is an optional vector2 used to offset UV.
  21612. * @param uvScale is an optional vector2 used to scale UV.
  21613. * @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.
  21614. * @returns the Mesh.
  21615. */
  21616. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21617. /**
  21618. * Modifies the mesh geometry according to a displacementMap buffer.
  21619. * 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.
  21620. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21621. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21622. * @param heightMapWidth is the width of the buffer image.
  21623. * @param heightMapHeight is the height of the buffer image.
  21624. * @param minHeight is the lower limit of the displacement.
  21625. * @param maxHeight is the upper limit of the displacement.
  21626. * @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.
  21627. * @param uvOffset is an optional vector2 used to offset UV.
  21628. * @param uvScale is an optional vector2 used to scale UV.
  21629. * @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.
  21630. * @returns the Mesh.
  21631. */
  21632. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21633. /**
  21634. * Modify the mesh to get a flat shading rendering.
  21635. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21636. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21637. * @returns current mesh
  21638. */
  21639. convertToFlatShadedMesh(): Mesh;
  21640. /**
  21641. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21642. * In other words, more vertices, no more indices and a single bigger VBO.
  21643. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21644. * @returns current mesh
  21645. */
  21646. convertToUnIndexedMesh(): Mesh;
  21647. /**
  21648. * Inverses facet orientations.
  21649. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21650. * @param flipNormals will also inverts the normals
  21651. * @returns current mesh
  21652. */
  21653. flipFaces(flipNormals?: boolean): Mesh;
  21654. /**
  21655. * Increase the number of facets and hence vertices in a mesh
  21656. * Vertex normals are interpolated from existing vertex normals
  21657. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21658. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  21659. */
  21660. increaseVertices(numberPerEdge: number): void;
  21661. /**
  21662. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  21663. * This will undo any application of covertToFlatShadedMesh
  21664. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21665. */
  21666. forceSharedVertices(): void;
  21667. /** @hidden */
  21668. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21669. /** @hidden */
  21670. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21671. /**
  21672. * Creates a new InstancedMesh object from the mesh model.
  21673. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21674. * @param name defines the name of the new instance
  21675. * @returns a new InstancedMesh
  21676. */
  21677. createInstance(name: string): InstancedMesh;
  21678. /**
  21679. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21680. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21681. * @returns the current mesh
  21682. */
  21683. synchronizeInstances(): Mesh;
  21684. /**
  21685. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21686. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21687. * This should be used together with the simplification to avoid disappearing triangles.
  21688. * @param successCallback an optional success callback to be called after the optimization finished.
  21689. * @returns the current mesh
  21690. */
  21691. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21692. /**
  21693. * Serialize current mesh
  21694. * @param serializationObject defines the object which will receive the serialization data
  21695. */
  21696. serialize(serializationObject: any): void;
  21697. /** @hidden */
  21698. _syncGeometryWithMorphTargetManager(): void;
  21699. /** @hidden */
  21700. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21701. /**
  21702. * Returns a new Mesh object parsed from the source provided.
  21703. * @param parsedMesh is the source
  21704. * @param scene defines the hosting scene
  21705. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21706. * @returns a new Mesh
  21707. */
  21708. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21709. /**
  21710. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21711. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21712. * @param name defines the name of the mesh to create
  21713. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21714. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21715. * @param closePath creates a seam between the first and the last points of each path of the path array
  21716. * @param offset is taken in account only if the `pathArray` is containing a single path
  21717. * @param scene defines the hosting scene
  21718. * @param updatable defines if the mesh must be flagged as updatable
  21719. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21720. * @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)
  21721. * @returns a new Mesh
  21722. */
  21723. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21724. /**
  21725. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21726. * @param name defines the name of the mesh to create
  21727. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21728. * @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
  21729. * @param scene defines the hosting scene
  21730. * @param updatable defines if the mesh must be flagged as updatable
  21731. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21732. * @returns a new Mesh
  21733. */
  21734. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21735. /**
  21736. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21737. * @param name defines the name of the mesh to create
  21738. * @param size sets the size (float) of each box side (default 1)
  21739. * @param scene defines the hosting scene
  21740. * @param updatable defines if the mesh must be flagged as updatable
  21741. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21742. * @returns a new Mesh
  21743. */
  21744. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21745. /**
  21746. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21747. * @param name defines the name of the mesh to create
  21748. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21749. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21750. * @param scene defines the hosting scene
  21751. * @param updatable defines if the mesh must be flagged as updatable
  21752. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21753. * @returns a new Mesh
  21754. */
  21755. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21756. /**
  21757. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  21758. * @param name defines the name of the mesh to create
  21759. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21760. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21761. * @param scene defines the hosting scene
  21762. * @returns a new Mesh
  21763. */
  21764. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  21765. /**
  21766. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21767. * @param name defines the name of the mesh to create
  21768. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21769. * @param diameterTop set the top cap diameter (floats, default 1)
  21770. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21771. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21772. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21773. * @param scene defines the hosting scene
  21774. * @param updatable defines if the mesh must be flagged as updatable
  21775. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21776. * @returns a new Mesh
  21777. */
  21778. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21779. /**
  21780. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21781. * @param name defines the name of the mesh to create
  21782. * @param diameter sets the diameter size (float) of the torus (default 1)
  21783. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21784. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21785. * @param scene defines the hosting scene
  21786. * @param updatable defines if the mesh must be flagged as updatable
  21787. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21788. * @returns a new Mesh
  21789. */
  21790. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21791. /**
  21792. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21793. * @param name defines the name of the mesh to create
  21794. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21795. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21796. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21797. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21798. * @param p the number of windings on X axis (positive integers, default 2)
  21799. * @param q the number of windings on Y axis (positive integers, default 3)
  21800. * @param scene defines the hosting scene
  21801. * @param updatable defines if the mesh must be flagged as updatable
  21802. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21803. * @returns a new Mesh
  21804. */
  21805. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21806. /**
  21807. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21808. * @param name defines the name of the mesh to create
  21809. * @param points is an array successive Vector3
  21810. * @param scene defines the hosting scene
  21811. * @param updatable defines if the mesh must be flagged as updatable
  21812. * @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).
  21813. * @returns a new Mesh
  21814. */
  21815. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21816. /**
  21817. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21818. * @param name defines the name of the mesh to create
  21819. * @param points is an array successive Vector3
  21820. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21821. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21822. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21823. * @param scene defines the hosting scene
  21824. * @param updatable defines if the mesh must be flagged as updatable
  21825. * @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)
  21826. * @returns a new Mesh
  21827. */
  21828. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21829. /**
  21830. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21831. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21832. * 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.
  21833. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21834. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21835. * Remember you can only change the shape positions, not their number when updating a polygon.
  21836. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21837. * @param name defines the name of the mesh to create
  21838. * @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
  21839. * @param scene defines the hosting scene
  21840. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21841. * @param updatable defines if the mesh must be flagged as updatable
  21842. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21843. * @param earcutInjection can be used to inject your own earcut reference
  21844. * @returns a new Mesh
  21845. */
  21846. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21847. /**
  21848. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21849. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21850. * @param name defines the name of the mesh to create
  21851. * @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
  21852. * @param depth defines the height of extrusion
  21853. * @param scene defines the hosting scene
  21854. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21855. * @param updatable defines if the mesh must be flagged as updatable
  21856. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21857. * @param earcutInjection can be used to inject your own earcut reference
  21858. * @returns a new Mesh
  21859. */
  21860. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21861. /**
  21862. * Creates an extruded shape mesh.
  21863. * 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
  21864. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21865. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21866. * @param name defines the name of the mesh to create
  21867. * @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
  21868. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21869. * @param scale is the value to scale the shape
  21870. * @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
  21871. * @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
  21872. * @param scene defines the hosting scene
  21873. * @param updatable defines if the mesh must be flagged as updatable
  21874. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21875. * @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)
  21876. * @returns a new Mesh
  21877. */
  21878. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21879. /**
  21880. * Creates an custom extruded shape mesh.
  21881. * The custom extrusion is a parametric shape.
  21882. * It has no predefined shape. Its final shape will depend on the input parameters.
  21883. * Please consider using the same method from the MeshBuilder class instead
  21884. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21885. * @param name defines the name of the mesh to create
  21886. * @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
  21887. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21888. * @param scaleFunction is a custom Javascript function called on each path point
  21889. * @param rotationFunction is a custom Javascript function called on each path point
  21890. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21891. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21892. * @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
  21893. * @param scene defines the hosting scene
  21894. * @param updatable defines if the mesh must be flagged as updatable
  21895. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21896. * @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)
  21897. * @returns a new Mesh
  21898. */
  21899. 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;
  21900. /**
  21901. * Creates lathe mesh.
  21902. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21903. * Please consider using the same method from the MeshBuilder class instead
  21904. * @param name defines the name of the mesh to create
  21905. * @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
  21906. * @param radius is the radius value of the lathe
  21907. * @param tessellation is the side number of the lathe.
  21908. * @param scene defines the hosting scene
  21909. * @param updatable defines if the mesh must be flagged as updatable
  21910. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21911. * @returns a new Mesh
  21912. */
  21913. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21914. /**
  21915. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21916. * @param name defines the name of the mesh to create
  21917. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21918. * @param scene defines the hosting scene
  21919. * @param updatable defines if the mesh must be flagged as updatable
  21920. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21921. * @returns a new Mesh
  21922. */
  21923. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21924. /**
  21925. * Creates a ground mesh.
  21926. * Please consider using the same method from the MeshBuilder class instead
  21927. * @param name defines the name of the mesh to create
  21928. * @param width set the width of the ground
  21929. * @param height set the height of the ground
  21930. * @param subdivisions sets the number of subdivisions per side
  21931. * @param scene defines the hosting scene
  21932. * @param updatable defines if the mesh must be flagged as updatable
  21933. * @returns a new Mesh
  21934. */
  21935. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21936. /**
  21937. * Creates a tiled ground mesh.
  21938. * Please consider using the same method from the MeshBuilder class instead
  21939. * @param name defines the name of the mesh to create
  21940. * @param xmin set the ground minimum X coordinate
  21941. * @param zmin set the ground minimum Y coordinate
  21942. * @param xmax set the ground maximum X coordinate
  21943. * @param zmax set the ground maximum Z coordinate
  21944. * @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
  21945. * @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
  21946. * @param scene defines the hosting scene
  21947. * @param updatable defines if the mesh must be flagged as updatable
  21948. * @returns a new Mesh
  21949. */
  21950. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21951. w: number;
  21952. h: number;
  21953. }, precision: {
  21954. w: number;
  21955. h: number;
  21956. }, scene: Scene, updatable?: boolean): Mesh;
  21957. /**
  21958. * Creates a ground mesh from a height map.
  21959. * Please consider using the same method from the MeshBuilder class instead
  21960. * @see http://doc.babylonjs.com/babylon101/height_map
  21961. * @param name defines the name of the mesh to create
  21962. * @param url sets the URL of the height map image resource
  21963. * @param width set the ground width size
  21964. * @param height set the ground height size
  21965. * @param subdivisions sets the number of subdivision per side
  21966. * @param minHeight is the minimum altitude on the ground
  21967. * @param maxHeight is the maximum altitude on the ground
  21968. * @param scene defines the hosting scene
  21969. * @param updatable defines if the mesh must be flagged as updatable
  21970. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21971. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21972. * @returns a new Mesh
  21973. */
  21974. 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;
  21975. /**
  21976. * Creates a tube mesh.
  21977. * The tube is a parametric shape.
  21978. * It has no predefined shape. Its final shape will depend on the input parameters.
  21979. * Please consider using the same method from the MeshBuilder class instead
  21980. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21981. * @param name defines the name of the mesh to create
  21982. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21983. * @param radius sets the tube radius size
  21984. * @param tessellation is the number of sides on the tubular surface
  21985. * @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
  21986. * @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
  21987. * @param scene defines the hosting scene
  21988. * @param updatable defines if the mesh must be flagged as updatable
  21989. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21990. * @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)
  21991. * @returns a new Mesh
  21992. */
  21993. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21994. (i: number, distance: number): number;
  21995. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21996. /**
  21997. * Creates a polyhedron mesh.
  21998. * Please consider using the same method from the MeshBuilder class instead.
  21999. * * 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
  22000. * * The parameter `size` (positive float, default 1) sets the polygon size
  22001. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  22002. * * 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`
  22003. * * 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
  22004. * * 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)`)
  22005. * * 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
  22006. * * 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
  22007. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22008. * * If you create a double-sided mesh, you can choose what parts of 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
  22009. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22010. * @param name defines the name of the mesh to create
  22011. * @param options defines the options used to create the mesh
  22012. * @param scene defines the hosting scene
  22013. * @returns a new Mesh
  22014. */
  22015. static CreatePolyhedron(name: string, options: {
  22016. type?: number;
  22017. size?: number;
  22018. sizeX?: number;
  22019. sizeY?: number;
  22020. sizeZ?: number;
  22021. custom?: any;
  22022. faceUV?: Vector4[];
  22023. faceColors?: Color4[];
  22024. updatable?: boolean;
  22025. sideOrientation?: number;
  22026. }, scene: Scene): Mesh;
  22027. /**
  22028. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  22029. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  22030. * * 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`)
  22031. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  22032. * * 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
  22033. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22034. * * If you create a double-sided mesh, you can choose what parts of 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
  22035. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22036. * @param name defines the name of the mesh
  22037. * @param options defines the options used to create the mesh
  22038. * @param scene defines the hosting scene
  22039. * @returns a new Mesh
  22040. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  22041. */
  22042. static CreateIcoSphere(name: string, options: {
  22043. radius?: number;
  22044. flat?: boolean;
  22045. subdivisions?: number;
  22046. sideOrientation?: number;
  22047. updatable?: boolean;
  22048. }, scene: Scene): Mesh;
  22049. /**
  22050. * Creates a decal mesh.
  22051. * Please consider using the same method from the MeshBuilder class instead.
  22052. * A decal is a mesh usually applied as a model onto the surface of another mesh
  22053. * @param name defines the name of the mesh
  22054. * @param sourceMesh defines the mesh receiving the decal
  22055. * @param position sets the position of the decal in world coordinates
  22056. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  22057. * @param size sets the decal scaling
  22058. * @param angle sets the angle to rotate the decal
  22059. * @returns a new Mesh
  22060. */
  22061. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  22062. /**
  22063. * Prepare internal position array for software CPU skinning
  22064. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  22065. */
  22066. setPositionsForCPUSkinning(): Float32Array;
  22067. /**
  22068. * Prepare internal normal array for software CPU skinning
  22069. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22070. */
  22071. setNormalsForCPUSkinning(): Float32Array;
  22072. /**
  22073. * Updates the vertex buffer by applying transformation from the bones
  22074. * @param skeleton defines the skeleton to apply to current mesh
  22075. * @returns the current mesh
  22076. */
  22077. applySkeleton(skeleton: Skeleton): Mesh;
  22078. /**
  22079. * 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
  22080. * @param meshes defines the list of meshes to scan
  22081. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  22082. */
  22083. static MinMax(meshes: AbstractMesh[]): {
  22084. min: Vector3;
  22085. max: Vector3;
  22086. };
  22087. /**
  22088. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  22089. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  22090. * @returns a vector3
  22091. */
  22092. static Center(meshesOrMinMaxVector: {
  22093. min: Vector3;
  22094. max: Vector3;
  22095. } | AbstractMesh[]): Vector3;
  22096. /**
  22097. * Merge the array of meshes into a single mesh for performance reasons.
  22098. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  22099. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  22100. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  22101. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  22102. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  22103. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  22104. * @returns a new mesh
  22105. */
  22106. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  22107. /** @hidden */
  22108. addInstance(instance: InstancedMesh): void;
  22109. /** @hidden */
  22110. removeInstance(instance: InstancedMesh): void;
  22111. }
  22112. }
  22113. declare module "babylonjs/Materials/material" {
  22114. import { IAnimatable } from "babylonjs/Misc/tools";
  22115. import { SmartArray } from "babylonjs/Misc/smartArray";
  22116. import { Observable } from "babylonjs/Misc/observable";
  22117. import { Nullable } from "babylonjs/types";
  22118. import { Scene } from "babylonjs/scene";
  22119. import { Matrix } from "babylonjs/Maths/math";
  22120. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  22121. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22122. import { Mesh } from "babylonjs/Meshes/mesh";
  22123. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  22124. import { Effect } from "babylonjs/Materials/effect";
  22125. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22126. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  22127. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22128. import { IInspectable } from "babylonjs/Misc/iInspectable";
  22129. import { Animation } from "babylonjs/Animations/animation";
  22130. /**
  22131. * Base class for the main features of a material in Babylon.js
  22132. */
  22133. export class Material implements IAnimatable {
  22134. /**
  22135. * Returns the triangle fill mode
  22136. */
  22137. static readonly TriangleFillMode: number;
  22138. /**
  22139. * Returns the wireframe mode
  22140. */
  22141. static readonly WireFrameFillMode: number;
  22142. /**
  22143. * Returns the point fill mode
  22144. */
  22145. static readonly PointFillMode: number;
  22146. /**
  22147. * Returns the point list draw mode
  22148. */
  22149. static readonly PointListDrawMode: number;
  22150. /**
  22151. * Returns the line list draw mode
  22152. */
  22153. static readonly LineListDrawMode: number;
  22154. /**
  22155. * Returns the line loop draw mode
  22156. */
  22157. static readonly LineLoopDrawMode: number;
  22158. /**
  22159. * Returns the line strip draw mode
  22160. */
  22161. static readonly LineStripDrawMode: number;
  22162. /**
  22163. * Returns the triangle strip draw mode
  22164. */
  22165. static readonly TriangleStripDrawMode: number;
  22166. /**
  22167. * Returns the triangle fan draw mode
  22168. */
  22169. static readonly TriangleFanDrawMode: number;
  22170. /**
  22171. * Stores the clock-wise side orientation
  22172. */
  22173. static readonly ClockWiseSideOrientation: number;
  22174. /**
  22175. * Stores the counter clock-wise side orientation
  22176. */
  22177. static readonly CounterClockWiseSideOrientation: number;
  22178. /**
  22179. * The dirty texture flag value
  22180. */
  22181. static readonly TextureDirtyFlag: number;
  22182. /**
  22183. * The dirty light flag value
  22184. */
  22185. static readonly LightDirtyFlag: number;
  22186. /**
  22187. * The dirty fresnel flag value
  22188. */
  22189. static readonly FresnelDirtyFlag: number;
  22190. /**
  22191. * The dirty attribute flag value
  22192. */
  22193. static readonly AttributesDirtyFlag: number;
  22194. /**
  22195. * The dirty misc flag value
  22196. */
  22197. static readonly MiscDirtyFlag: number;
  22198. /**
  22199. * The all dirty flag value
  22200. */
  22201. static readonly AllDirtyFlag: number;
  22202. /**
  22203. * The ID of the material
  22204. */
  22205. id: string;
  22206. /**
  22207. * Gets or sets the unique id of the material
  22208. */
  22209. uniqueId: number;
  22210. /**
  22211. * The name of the material
  22212. */
  22213. name: string;
  22214. /**
  22215. * Gets or sets user defined metadata
  22216. */
  22217. metadata: any;
  22218. /**
  22219. * For internal use only. Please do not use.
  22220. */
  22221. reservedDataStore: any;
  22222. /**
  22223. * Specifies if the ready state should be checked on each call
  22224. */
  22225. checkReadyOnEveryCall: boolean;
  22226. /**
  22227. * Specifies if the ready state should be checked once
  22228. */
  22229. checkReadyOnlyOnce: boolean;
  22230. /**
  22231. * The state of the material
  22232. */
  22233. state: string;
  22234. /**
  22235. * The alpha value of the material
  22236. */
  22237. protected _alpha: number;
  22238. /**
  22239. * List of inspectable custom properties (used by the Inspector)
  22240. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22241. */
  22242. inspectableCustomProperties: IInspectable[];
  22243. /**
  22244. * Sets the alpha value of the material
  22245. */
  22246. /**
  22247. * Gets the alpha value of the material
  22248. */
  22249. alpha: number;
  22250. /**
  22251. * Specifies if back face culling is enabled
  22252. */
  22253. protected _backFaceCulling: boolean;
  22254. /**
  22255. * Sets the back-face culling state
  22256. */
  22257. /**
  22258. * Gets the back-face culling state
  22259. */
  22260. backFaceCulling: boolean;
  22261. /**
  22262. * Stores the value for side orientation
  22263. */
  22264. sideOrientation: number;
  22265. /**
  22266. * Callback triggered when the material is compiled
  22267. */
  22268. onCompiled: (effect: Effect) => void;
  22269. /**
  22270. * Callback triggered when an error occurs
  22271. */
  22272. onError: (effect: Effect, errors: string) => void;
  22273. /**
  22274. * Callback triggered to get the render target textures
  22275. */
  22276. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  22277. /**
  22278. * Gets a boolean indicating that current material needs to register RTT
  22279. */
  22280. readonly hasRenderTargetTextures: boolean;
  22281. /**
  22282. * Specifies if the material should be serialized
  22283. */
  22284. doNotSerialize: boolean;
  22285. /**
  22286. * @hidden
  22287. */
  22288. _storeEffectOnSubMeshes: boolean;
  22289. /**
  22290. * Stores the animations for the material
  22291. */
  22292. animations: Array<Animation>;
  22293. /**
  22294. * An event triggered when the material is disposed
  22295. */
  22296. onDisposeObservable: Observable<Material>;
  22297. /**
  22298. * An observer which watches for dispose events
  22299. */
  22300. private _onDisposeObserver;
  22301. private _onUnBindObservable;
  22302. /**
  22303. * Called during a dispose event
  22304. */
  22305. onDispose: () => void;
  22306. private _onBindObservable;
  22307. /**
  22308. * An event triggered when the material is bound
  22309. */
  22310. readonly onBindObservable: Observable<AbstractMesh>;
  22311. /**
  22312. * An observer which watches for bind events
  22313. */
  22314. private _onBindObserver;
  22315. /**
  22316. * Called during a bind event
  22317. */
  22318. onBind: (Mesh: AbstractMesh) => void;
  22319. /**
  22320. * An event triggered when the material is unbound
  22321. */
  22322. readonly onUnBindObservable: Observable<Material>;
  22323. /**
  22324. * Stores the value of the alpha mode
  22325. */
  22326. private _alphaMode;
  22327. /**
  22328. * Sets the value of the alpha mode.
  22329. *
  22330. * | Value | Type | Description |
  22331. * | --- | --- | --- |
  22332. * | 0 | ALPHA_DISABLE | |
  22333. * | 1 | ALPHA_ADD | |
  22334. * | 2 | ALPHA_COMBINE | |
  22335. * | 3 | ALPHA_SUBTRACT | |
  22336. * | 4 | ALPHA_MULTIPLY | |
  22337. * | 5 | ALPHA_MAXIMIZED | |
  22338. * | 6 | ALPHA_ONEONE | |
  22339. * | 7 | ALPHA_PREMULTIPLIED | |
  22340. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22341. * | 9 | ALPHA_INTERPOLATE | |
  22342. * | 10 | ALPHA_SCREENMODE | |
  22343. *
  22344. */
  22345. /**
  22346. * Gets the value of the alpha mode
  22347. */
  22348. alphaMode: number;
  22349. /**
  22350. * Stores the state of the need depth pre-pass value
  22351. */
  22352. private _needDepthPrePass;
  22353. /**
  22354. * Sets the need depth pre-pass value
  22355. */
  22356. /**
  22357. * Gets the depth pre-pass value
  22358. */
  22359. needDepthPrePass: boolean;
  22360. /**
  22361. * Specifies if depth writing should be disabled
  22362. */
  22363. disableDepthWrite: boolean;
  22364. /**
  22365. * Specifies if depth writing should be forced
  22366. */
  22367. forceDepthWrite: boolean;
  22368. /**
  22369. * Specifies if there should be a separate pass for culling
  22370. */
  22371. separateCullingPass: boolean;
  22372. /**
  22373. * Stores the state specifing if fog should be enabled
  22374. */
  22375. private _fogEnabled;
  22376. /**
  22377. * Sets the state for enabling fog
  22378. */
  22379. /**
  22380. * Gets the value of the fog enabled state
  22381. */
  22382. fogEnabled: boolean;
  22383. /**
  22384. * Stores the size of points
  22385. */
  22386. pointSize: number;
  22387. /**
  22388. * Stores the z offset value
  22389. */
  22390. zOffset: number;
  22391. /**
  22392. * Gets a value specifying if wireframe mode is enabled
  22393. */
  22394. /**
  22395. * Sets the state of wireframe mode
  22396. */
  22397. wireframe: boolean;
  22398. /**
  22399. * Gets the value specifying if point clouds are enabled
  22400. */
  22401. /**
  22402. * Sets the state of point cloud mode
  22403. */
  22404. pointsCloud: boolean;
  22405. /**
  22406. * Gets the material fill mode
  22407. */
  22408. /**
  22409. * Sets the material fill mode
  22410. */
  22411. fillMode: number;
  22412. /**
  22413. * @hidden
  22414. * Stores the effects for the material
  22415. */
  22416. _effect: Nullable<Effect>;
  22417. /**
  22418. * @hidden
  22419. * Specifies if the material was previously ready
  22420. */
  22421. _wasPreviouslyReady: boolean;
  22422. /**
  22423. * Specifies if uniform buffers should be used
  22424. */
  22425. private _useUBO;
  22426. /**
  22427. * Stores a reference to the scene
  22428. */
  22429. private _scene;
  22430. /**
  22431. * Stores the fill mode state
  22432. */
  22433. private _fillMode;
  22434. /**
  22435. * Specifies if the depth write state should be cached
  22436. */
  22437. private _cachedDepthWriteState;
  22438. /**
  22439. * Stores the uniform buffer
  22440. */
  22441. protected _uniformBuffer: UniformBuffer;
  22442. /** @hidden */
  22443. _indexInSceneMaterialArray: number;
  22444. /** @hidden */
  22445. meshMap: Nullable<{
  22446. [id: string]: AbstractMesh | undefined;
  22447. }>;
  22448. /**
  22449. * Creates a material instance
  22450. * @param name defines the name of the material
  22451. * @param scene defines the scene to reference
  22452. * @param doNotAdd specifies if the material should be added to the scene
  22453. */
  22454. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22455. /**
  22456. * Returns a string representation of the current material
  22457. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22458. * @returns a string with material information
  22459. */
  22460. toString(fullDetails?: boolean): string;
  22461. /**
  22462. * Gets the class name of the material
  22463. * @returns a string with the class name of the material
  22464. */
  22465. getClassName(): string;
  22466. /**
  22467. * Specifies if updates for the material been locked
  22468. */
  22469. readonly isFrozen: boolean;
  22470. /**
  22471. * Locks updates for the material
  22472. */
  22473. freeze(): void;
  22474. /**
  22475. * Unlocks updates for the material
  22476. */
  22477. unfreeze(): void;
  22478. /**
  22479. * Specifies if the material is ready to be used
  22480. * @param mesh defines the mesh to check
  22481. * @param useInstances specifies if instances should be used
  22482. * @returns a boolean indicating if the material is ready to be used
  22483. */
  22484. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22485. /**
  22486. * Specifies that the submesh is ready to be used
  22487. * @param mesh defines the mesh to check
  22488. * @param subMesh defines which submesh to check
  22489. * @param useInstances specifies that instances should be used
  22490. * @returns a boolean indicating that the submesh is ready or not
  22491. */
  22492. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22493. /**
  22494. * Returns the material effect
  22495. * @returns the effect associated with the material
  22496. */
  22497. getEffect(): Nullable<Effect>;
  22498. /**
  22499. * Returns the current scene
  22500. * @returns a Scene
  22501. */
  22502. getScene(): Scene;
  22503. /**
  22504. * Specifies if the material will require alpha blending
  22505. * @returns a boolean specifying if alpha blending is needed
  22506. */
  22507. needAlphaBlending(): boolean;
  22508. /**
  22509. * Specifies if the mesh will require alpha blending
  22510. * @param mesh defines the mesh to check
  22511. * @returns a boolean specifying if alpha blending is needed for the mesh
  22512. */
  22513. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22514. /**
  22515. * Specifies if this material should be rendered in alpha test mode
  22516. * @returns a boolean specifying if an alpha test is needed.
  22517. */
  22518. needAlphaTesting(): boolean;
  22519. /**
  22520. * Gets the texture used for the alpha test
  22521. * @returns the texture to use for alpha testing
  22522. */
  22523. getAlphaTestTexture(): Nullable<BaseTexture>;
  22524. /**
  22525. * Marks the material to indicate that it needs to be re-calculated
  22526. */
  22527. markDirty(): void;
  22528. /** @hidden */
  22529. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22530. /**
  22531. * Binds the material to the mesh
  22532. * @param world defines the world transformation matrix
  22533. * @param mesh defines the mesh to bind the material to
  22534. */
  22535. bind(world: Matrix, mesh?: Mesh): void;
  22536. /**
  22537. * Binds the submesh to the material
  22538. * @param world defines the world transformation matrix
  22539. * @param mesh defines the mesh containing the submesh
  22540. * @param subMesh defines the submesh to bind the material to
  22541. */
  22542. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22543. /**
  22544. * Binds the world matrix to the material
  22545. * @param world defines the world transformation matrix
  22546. */
  22547. bindOnlyWorldMatrix(world: Matrix): void;
  22548. /**
  22549. * Binds the scene's uniform buffer to the effect.
  22550. * @param effect defines the effect to bind to the scene uniform buffer
  22551. * @param sceneUbo defines the uniform buffer storing scene data
  22552. */
  22553. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22554. /**
  22555. * Binds the view matrix to the effect
  22556. * @param effect defines the effect to bind the view matrix to
  22557. */
  22558. bindView(effect: Effect): void;
  22559. /**
  22560. * Binds the view projection matrix to the effect
  22561. * @param effect defines the effect to bind the view projection matrix to
  22562. */
  22563. bindViewProjection(effect: Effect): void;
  22564. /**
  22565. * Specifies if material alpha testing should be turned on for the mesh
  22566. * @param mesh defines the mesh to check
  22567. */
  22568. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22569. /**
  22570. * Processes to execute after binding the material to a mesh
  22571. * @param mesh defines the rendered mesh
  22572. */
  22573. protected _afterBind(mesh?: Mesh): void;
  22574. /**
  22575. * Unbinds the material from the mesh
  22576. */
  22577. unbind(): void;
  22578. /**
  22579. * Gets the active textures from the material
  22580. * @returns an array of textures
  22581. */
  22582. getActiveTextures(): BaseTexture[];
  22583. /**
  22584. * Specifies if the material uses a texture
  22585. * @param texture defines the texture to check against the material
  22586. * @returns a boolean specifying if the material uses the texture
  22587. */
  22588. hasTexture(texture: BaseTexture): boolean;
  22589. /**
  22590. * Makes a duplicate of the material, and gives it a new name
  22591. * @param name defines the new name for the duplicated material
  22592. * @returns the cloned material
  22593. */
  22594. clone(name: string): Nullable<Material>;
  22595. /**
  22596. * Gets the meshes bound to the material
  22597. * @returns an array of meshes bound to the material
  22598. */
  22599. getBindedMeshes(): AbstractMesh[];
  22600. /**
  22601. * Force shader compilation
  22602. * @param mesh defines the mesh associated with this material
  22603. * @param onCompiled defines a function to execute once the material is compiled
  22604. * @param options defines the options to configure the compilation
  22605. */
  22606. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22607. clipPlane: boolean;
  22608. }>): void;
  22609. /**
  22610. * Force shader compilation
  22611. * @param mesh defines the mesh that will use this material
  22612. * @param options defines additional options for compiling the shaders
  22613. * @returns a promise that resolves when the compilation completes
  22614. */
  22615. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22616. clipPlane: boolean;
  22617. }>): Promise<void>;
  22618. private static readonly _ImageProcessingDirtyCallBack;
  22619. private static readonly _TextureDirtyCallBack;
  22620. private static readonly _FresnelDirtyCallBack;
  22621. private static readonly _MiscDirtyCallBack;
  22622. private static readonly _LightsDirtyCallBack;
  22623. private static readonly _AttributeDirtyCallBack;
  22624. private static _FresnelAndMiscDirtyCallBack;
  22625. private static _TextureAndMiscDirtyCallBack;
  22626. private static readonly _DirtyCallbackArray;
  22627. private static readonly _RunDirtyCallBacks;
  22628. /**
  22629. * Marks a define in the material to indicate that it needs to be re-computed
  22630. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22631. */
  22632. markAsDirty(flag: number): void;
  22633. /**
  22634. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22635. * @param func defines a function which checks material defines against the submeshes
  22636. */
  22637. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22638. /**
  22639. * Indicates that image processing needs to be re-calculated for all submeshes
  22640. */
  22641. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22642. /**
  22643. * Indicates that textures need to be re-calculated for all submeshes
  22644. */
  22645. protected _markAllSubMeshesAsTexturesDirty(): void;
  22646. /**
  22647. * Indicates that fresnel needs to be re-calculated for all submeshes
  22648. */
  22649. protected _markAllSubMeshesAsFresnelDirty(): void;
  22650. /**
  22651. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22652. */
  22653. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22654. /**
  22655. * Indicates that lights need to be re-calculated for all submeshes
  22656. */
  22657. protected _markAllSubMeshesAsLightsDirty(): void;
  22658. /**
  22659. * Indicates that attributes need to be re-calculated for all submeshes
  22660. */
  22661. protected _markAllSubMeshesAsAttributesDirty(): void;
  22662. /**
  22663. * Indicates that misc needs to be re-calculated for all submeshes
  22664. */
  22665. protected _markAllSubMeshesAsMiscDirty(): void;
  22666. /**
  22667. * Indicates that textures and misc need to be re-calculated for all submeshes
  22668. */
  22669. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22670. /**
  22671. * Disposes the material
  22672. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22673. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22674. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22675. */
  22676. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22677. /** @hidden */
  22678. private releaseVertexArrayObject;
  22679. /**
  22680. * Serializes this material
  22681. * @returns the serialized material object
  22682. */
  22683. serialize(): any;
  22684. /**
  22685. * Creates a material from parsed material data
  22686. * @param parsedMaterial defines parsed material data
  22687. * @param scene defines the hosting scene
  22688. * @param rootUrl defines the root URL to use to load textures
  22689. * @returns a new material
  22690. */
  22691. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22692. }
  22693. }
  22694. declare module "babylonjs/Meshes/subMesh" {
  22695. import { Nullable, IndicesArray, DeepImmutable } from "babylonjs/types";
  22696. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  22697. import { Engine } from "babylonjs/Engines/engine";
  22698. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22699. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22700. import { Effect } from "babylonjs/Materials/effect";
  22701. import { Collider } from "babylonjs/Collisions/collider";
  22702. import { Material } from "babylonjs/Materials/material";
  22703. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22704. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22705. import { Mesh } from "babylonjs/Meshes/mesh";
  22706. import { Ray } from "babylonjs/Culling/ray";
  22707. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22708. /**
  22709. * Base class for submeshes
  22710. */
  22711. export class BaseSubMesh {
  22712. /** @hidden */
  22713. _materialDefines: Nullable<MaterialDefines>;
  22714. /** @hidden */
  22715. _materialEffect: Nullable<Effect>;
  22716. /**
  22717. * Gets associated effect
  22718. */
  22719. readonly effect: Nullable<Effect>;
  22720. /**
  22721. * Sets associated effect (effect used to render this submesh)
  22722. * @param effect defines the effect to associate with
  22723. * @param defines defines the set of defines used to compile this effect
  22724. */
  22725. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22726. }
  22727. /**
  22728. * Defines a subdivision inside a mesh
  22729. */
  22730. export class SubMesh extends BaseSubMesh implements ICullable {
  22731. /** the material index to use */
  22732. materialIndex: number;
  22733. /** vertex index start */
  22734. verticesStart: number;
  22735. /** vertices count */
  22736. verticesCount: number;
  22737. /** index start */
  22738. indexStart: number;
  22739. /** indices count */
  22740. indexCount: number;
  22741. /** @hidden */
  22742. _linesIndexCount: number;
  22743. private _mesh;
  22744. private _renderingMesh;
  22745. private _boundingInfo;
  22746. private _linesIndexBuffer;
  22747. /** @hidden */
  22748. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22749. /** @hidden */
  22750. _trianglePlanes: Plane[];
  22751. /** @hidden */
  22752. _lastColliderTransformMatrix: Matrix;
  22753. /** @hidden */
  22754. _renderId: number;
  22755. /** @hidden */
  22756. _alphaIndex: number;
  22757. /** @hidden */
  22758. _distanceToCamera: number;
  22759. /** @hidden */
  22760. _id: number;
  22761. private _currentMaterial;
  22762. /**
  22763. * Add a new submesh to a mesh
  22764. * @param materialIndex defines the material index to use
  22765. * @param verticesStart defines vertex index start
  22766. * @param verticesCount defines vertices count
  22767. * @param indexStart defines index start
  22768. * @param indexCount defines indices count
  22769. * @param mesh defines the parent mesh
  22770. * @param renderingMesh defines an optional rendering mesh
  22771. * @param createBoundingBox defines if bounding box should be created for this submesh
  22772. * @returns the new submesh
  22773. */
  22774. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22775. /**
  22776. * Creates a new submesh
  22777. * @param materialIndex defines the material index to use
  22778. * @param verticesStart defines vertex index start
  22779. * @param verticesCount defines vertices count
  22780. * @param indexStart defines index start
  22781. * @param indexCount defines indices count
  22782. * @param mesh defines the parent mesh
  22783. * @param renderingMesh defines an optional rendering mesh
  22784. * @param createBoundingBox defines if bounding box should be created for this submesh
  22785. */
  22786. constructor(
  22787. /** the material index to use */
  22788. materialIndex: number,
  22789. /** vertex index start */
  22790. verticesStart: number,
  22791. /** vertices count */
  22792. verticesCount: number,
  22793. /** index start */
  22794. indexStart: number,
  22795. /** indices count */
  22796. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22797. /**
  22798. * Returns true if this submesh covers the entire parent mesh
  22799. * @ignorenaming
  22800. */
  22801. readonly IsGlobal: boolean;
  22802. /**
  22803. * Returns the submesh BoudingInfo object
  22804. * @returns current bounding info (or mesh's one if the submesh is global)
  22805. */
  22806. getBoundingInfo(): BoundingInfo;
  22807. /**
  22808. * Sets the submesh BoundingInfo
  22809. * @param boundingInfo defines the new bounding info to use
  22810. * @returns the SubMesh
  22811. */
  22812. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22813. /**
  22814. * Returns the mesh of the current submesh
  22815. * @return the parent mesh
  22816. */
  22817. getMesh(): AbstractMesh;
  22818. /**
  22819. * Returns the rendering mesh of the submesh
  22820. * @returns the rendering mesh (could be different from parent mesh)
  22821. */
  22822. getRenderingMesh(): Mesh;
  22823. /**
  22824. * Returns the submesh material
  22825. * @returns null or the current material
  22826. */
  22827. getMaterial(): Nullable<Material>;
  22828. /**
  22829. * Sets a new updated BoundingInfo object to the submesh
  22830. * @returns the SubMesh
  22831. */
  22832. refreshBoundingInfo(): SubMesh;
  22833. /** @hidden */
  22834. _checkCollision(collider: Collider): boolean;
  22835. /**
  22836. * Updates the submesh BoundingInfo
  22837. * @param world defines the world matrix to use to update the bounding info
  22838. * @returns the submesh
  22839. */
  22840. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22841. /**
  22842. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22843. * @param frustumPlanes defines the frustum planes
  22844. * @returns true if the submesh is intersecting with the frustum
  22845. */
  22846. isInFrustum(frustumPlanes: Plane[]): boolean;
  22847. /**
  22848. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22849. * @param frustumPlanes defines the frustum planes
  22850. * @returns true if the submesh is inside the frustum
  22851. */
  22852. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22853. /**
  22854. * Renders the submesh
  22855. * @param enableAlphaMode defines if alpha needs to be used
  22856. * @returns the submesh
  22857. */
  22858. render(enableAlphaMode: boolean): SubMesh;
  22859. /**
  22860. * @hidden
  22861. */
  22862. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22863. /**
  22864. * Checks if the submesh intersects with a ray
  22865. * @param ray defines the ray to test
  22866. * @returns true is the passed ray intersects the submesh bounding box
  22867. */
  22868. canIntersects(ray: Ray): boolean;
  22869. /**
  22870. * Intersects current submesh with a ray
  22871. * @param ray defines the ray to test
  22872. * @param positions defines mesh's positions array
  22873. * @param indices defines mesh's indices array
  22874. * @param fastCheck defines if only bounding info should be used
  22875. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22876. * @returns intersection info or null if no intersection
  22877. */
  22878. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22879. /** @hidden */
  22880. private _intersectLines;
  22881. /** @hidden */
  22882. private _intersectTriangles;
  22883. /** @hidden */
  22884. _rebuild(): void;
  22885. /**
  22886. * Creates a new submesh from the passed mesh
  22887. * @param newMesh defines the new hosting mesh
  22888. * @param newRenderingMesh defines an optional rendering mesh
  22889. * @returns the new submesh
  22890. */
  22891. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22892. /**
  22893. * Release associated resources
  22894. */
  22895. dispose(): void;
  22896. /**
  22897. * Gets the class name
  22898. * @returns the string "SubMesh".
  22899. */
  22900. getClassName(): string;
  22901. /**
  22902. * Creates a new submesh from indices data
  22903. * @param materialIndex the index of the main mesh material
  22904. * @param startIndex the index where to start the copy in the mesh indices array
  22905. * @param indexCount the number of indices to copy then from the startIndex
  22906. * @param mesh the main mesh to create the submesh from
  22907. * @param renderingMesh the optional rendering mesh
  22908. * @returns a new submesh
  22909. */
  22910. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22911. }
  22912. }
  22913. declare module "babylonjs/Meshes/geometry" {
  22914. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22915. import { Scene } from "babylonjs/scene";
  22916. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  22917. import { Engine } from "babylonjs/Engines/engine";
  22918. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22919. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22920. import { Effect } from "babylonjs/Materials/effect";
  22921. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22922. import { Mesh } from "babylonjs/Meshes/mesh";
  22923. /**
  22924. * Class used to store geometry data (vertex buffers + index buffer)
  22925. */
  22926. export class Geometry implements IGetSetVerticesData {
  22927. /**
  22928. * Gets or sets the ID of the geometry
  22929. */
  22930. id: string;
  22931. /**
  22932. * Gets or sets the unique ID of the geometry
  22933. */
  22934. uniqueId: number;
  22935. /**
  22936. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22937. */
  22938. delayLoadState: number;
  22939. /**
  22940. * Gets the file containing the data to load when running in delay load state
  22941. */
  22942. delayLoadingFile: Nullable<string>;
  22943. /**
  22944. * Callback called when the geometry is updated
  22945. */
  22946. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22947. private _scene;
  22948. private _engine;
  22949. private _meshes;
  22950. private _totalVertices;
  22951. /** @hidden */
  22952. _indices: IndicesArray;
  22953. /** @hidden */
  22954. _vertexBuffers: {
  22955. [key: string]: VertexBuffer;
  22956. };
  22957. private _isDisposed;
  22958. private _extend;
  22959. private _boundingBias;
  22960. /** @hidden */
  22961. _delayInfo: Array<string>;
  22962. private _indexBuffer;
  22963. private _indexBufferIsUpdatable;
  22964. /** @hidden */
  22965. _boundingInfo: Nullable<BoundingInfo>;
  22966. /** @hidden */
  22967. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22968. /** @hidden */
  22969. _softwareSkinningFrameId: number;
  22970. private _vertexArrayObjects;
  22971. private _updatable;
  22972. /** @hidden */
  22973. _positions: Nullable<Vector3[]>;
  22974. /**
  22975. * 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
  22976. */
  22977. /**
  22978. * 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
  22979. */
  22980. boundingBias: Vector2;
  22981. /**
  22982. * Static function used to attach a new empty geometry to a mesh
  22983. * @param mesh defines the mesh to attach the geometry to
  22984. * @returns the new Geometry
  22985. */
  22986. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22987. /**
  22988. * Creates a new geometry
  22989. * @param id defines the unique ID
  22990. * @param scene defines the hosting scene
  22991. * @param vertexData defines the VertexData used to get geometry data
  22992. * @param updatable defines if geometry must be updatable (false by default)
  22993. * @param mesh defines the mesh that will be associated with the geometry
  22994. */
  22995. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22996. /**
  22997. * Gets the current extend of the geometry
  22998. */
  22999. readonly extend: {
  23000. minimum: Vector3;
  23001. maximum: Vector3;
  23002. };
  23003. /**
  23004. * Gets the hosting scene
  23005. * @returns the hosting Scene
  23006. */
  23007. getScene(): Scene;
  23008. /**
  23009. * Gets the hosting engine
  23010. * @returns the hosting Engine
  23011. */
  23012. getEngine(): Engine;
  23013. /**
  23014. * Defines if the geometry is ready to use
  23015. * @returns true if the geometry is ready to be used
  23016. */
  23017. isReady(): boolean;
  23018. /**
  23019. * Gets a value indicating that the geometry should not be serialized
  23020. */
  23021. readonly doNotSerialize: boolean;
  23022. /** @hidden */
  23023. _rebuild(): void;
  23024. /**
  23025. * Affects all geometry data in one call
  23026. * @param vertexData defines the geometry data
  23027. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  23028. */
  23029. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  23030. /**
  23031. * Set specific vertex data
  23032. * @param kind defines the data kind (Position, normal, etc...)
  23033. * @param data defines the vertex data to use
  23034. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23035. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23036. */
  23037. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  23038. /**
  23039. * Removes a specific vertex data
  23040. * @param kind defines the data kind (Position, normal, etc...)
  23041. */
  23042. removeVerticesData(kind: string): void;
  23043. /**
  23044. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  23045. * @param buffer defines the vertex buffer to use
  23046. * @param totalVertices defines the total number of vertices for position kind (could be null)
  23047. */
  23048. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  23049. /**
  23050. * Update a specific vertex buffer
  23051. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  23052. * It will do nothing if the buffer is not updatable
  23053. * @param kind defines the data kind (Position, normal, etc...)
  23054. * @param data defines the data to use
  23055. * @param offset defines the offset in the target buffer where to store the data
  23056. * @param useBytes set to true if the offset is in bytes
  23057. */
  23058. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  23059. /**
  23060. * Update a specific vertex buffer
  23061. * This function will create a new buffer if the current one is not updatable
  23062. * @param kind defines the data kind (Position, normal, etc...)
  23063. * @param data defines the data to use
  23064. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23065. */
  23066. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23067. private _updateBoundingInfo;
  23068. /** @hidden */
  23069. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  23070. /**
  23071. * Gets total number of vertices
  23072. * @returns the total number of vertices
  23073. */
  23074. getTotalVertices(): number;
  23075. /**
  23076. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23077. * @param kind defines the data kind (Position, normal, etc...)
  23078. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23079. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23080. * @returns a float array containing vertex data
  23081. */
  23082. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23083. /**
  23084. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23085. * @param kind defines the data kind (Position, normal, etc...)
  23086. * @returns true if the vertex buffer with the specified kind is updatable
  23087. */
  23088. isVertexBufferUpdatable(kind: string): boolean;
  23089. /**
  23090. * Gets a specific vertex buffer
  23091. * @param kind defines the data kind (Position, normal, etc...)
  23092. * @returns a VertexBuffer
  23093. */
  23094. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23095. /**
  23096. * Returns all vertex buffers
  23097. * @return an object holding all vertex buffers indexed by kind
  23098. */
  23099. getVertexBuffers(): Nullable<{
  23100. [key: string]: VertexBuffer;
  23101. }>;
  23102. /**
  23103. * Gets a boolean indicating if specific vertex buffer is present
  23104. * @param kind defines the data kind (Position, normal, etc...)
  23105. * @returns true if data is present
  23106. */
  23107. isVerticesDataPresent(kind: string): boolean;
  23108. /**
  23109. * Gets a list of all attached data kinds (Position, normal, etc...)
  23110. * @returns a list of string containing all kinds
  23111. */
  23112. getVerticesDataKinds(): string[];
  23113. /**
  23114. * Update index buffer
  23115. * @param indices defines the indices to store in the index buffer
  23116. * @param offset defines the offset in the target buffer where to store the data
  23117. * @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)
  23118. */
  23119. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23120. /**
  23121. * Creates a new index buffer
  23122. * @param indices defines the indices to store in the index buffer
  23123. * @param totalVertices defines the total number of vertices (could be null)
  23124. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23125. */
  23126. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23127. /**
  23128. * Return the total number of indices
  23129. * @returns the total number of indices
  23130. */
  23131. getTotalIndices(): number;
  23132. /**
  23133. * Gets the index buffer array
  23134. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23135. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23136. * @returns the index buffer array
  23137. */
  23138. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23139. /**
  23140. * Gets the index buffer
  23141. * @return the index buffer
  23142. */
  23143. getIndexBuffer(): Nullable<WebGLBuffer>;
  23144. /** @hidden */
  23145. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23146. /**
  23147. * Release the associated resources for a specific mesh
  23148. * @param mesh defines the source mesh
  23149. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23150. */
  23151. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23152. /**
  23153. * Apply current geometry to a given mesh
  23154. * @param mesh defines the mesh to apply geometry to
  23155. */
  23156. applyToMesh(mesh: Mesh): void;
  23157. private _updateExtend;
  23158. private _applyToMesh;
  23159. private notifyUpdate;
  23160. /**
  23161. * Load the geometry if it was flagged as delay loaded
  23162. * @param scene defines the hosting scene
  23163. * @param onLoaded defines a callback called when the geometry is loaded
  23164. */
  23165. load(scene: Scene, onLoaded?: () => void): void;
  23166. private _queueLoad;
  23167. /**
  23168. * Invert the geometry to move from a right handed system to a left handed one.
  23169. */
  23170. toLeftHanded(): void;
  23171. /** @hidden */
  23172. _resetPointsArrayCache(): void;
  23173. /** @hidden */
  23174. _generatePointsArray(): boolean;
  23175. /**
  23176. * Gets a value indicating if the geometry is disposed
  23177. * @returns true if the geometry was disposed
  23178. */
  23179. isDisposed(): boolean;
  23180. private _disposeVertexArrayObjects;
  23181. /**
  23182. * Free all associated resources
  23183. */
  23184. dispose(): void;
  23185. /**
  23186. * Clone the current geometry into a new geometry
  23187. * @param id defines the unique ID of the new geometry
  23188. * @returns a new geometry object
  23189. */
  23190. copy(id: string): Geometry;
  23191. /**
  23192. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23193. * @return a JSON representation of the current geometry data (without the vertices data)
  23194. */
  23195. serialize(): any;
  23196. private toNumberArray;
  23197. /**
  23198. * Serialize all vertices data into a JSON oject
  23199. * @returns a JSON representation of the current geometry data
  23200. */
  23201. serializeVerticeData(): any;
  23202. /**
  23203. * Extracts a clone of a mesh geometry
  23204. * @param mesh defines the source mesh
  23205. * @param id defines the unique ID of the new geometry object
  23206. * @returns the new geometry object
  23207. */
  23208. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23209. /**
  23210. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23211. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23212. * Be aware Math.random() could cause collisions, but:
  23213. * "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"
  23214. * @returns a string containing a new GUID
  23215. */
  23216. static RandomId(): string;
  23217. /** @hidden */
  23218. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23219. private static _CleanMatricesWeights;
  23220. /**
  23221. * Create a new geometry from persisted data (Using .babylon file format)
  23222. * @param parsedVertexData defines the persisted data
  23223. * @param scene defines the hosting scene
  23224. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23225. * @returns the new geometry object
  23226. */
  23227. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23228. }
  23229. }
  23230. declare module "babylonjs/Meshes/mesh.vertexData" {
  23231. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23232. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  23233. import { Geometry } from "babylonjs/Meshes/geometry";
  23234. import { Mesh } from "babylonjs/Meshes/mesh";
  23235. /**
  23236. * Define an interface for all classes that will get and set the data on vertices
  23237. */
  23238. export interface IGetSetVerticesData {
  23239. /**
  23240. * Gets a boolean indicating if specific vertex data is present
  23241. * @param kind defines the vertex data kind to use
  23242. * @returns true is data kind is present
  23243. */
  23244. isVerticesDataPresent(kind: string): boolean;
  23245. /**
  23246. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23247. * @param kind defines the data kind (Position, normal, etc...)
  23248. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23249. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23250. * @returns a float array containing vertex data
  23251. */
  23252. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23253. /**
  23254. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23255. * @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.
  23256. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23257. * @returns the indices array or an empty array if the mesh has no geometry
  23258. */
  23259. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23260. /**
  23261. * Set specific vertex data
  23262. * @param kind defines the data kind (Position, normal, etc...)
  23263. * @param data defines the vertex data to use
  23264. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23265. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23266. */
  23267. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23268. /**
  23269. * Update a specific associated vertex buffer
  23270. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23271. * - VertexBuffer.PositionKind
  23272. * - VertexBuffer.UVKind
  23273. * - VertexBuffer.UV2Kind
  23274. * - VertexBuffer.UV3Kind
  23275. * - VertexBuffer.UV4Kind
  23276. * - VertexBuffer.UV5Kind
  23277. * - VertexBuffer.UV6Kind
  23278. * - VertexBuffer.ColorKind
  23279. * - VertexBuffer.MatricesIndicesKind
  23280. * - VertexBuffer.MatricesIndicesExtraKind
  23281. * - VertexBuffer.MatricesWeightsKind
  23282. * - VertexBuffer.MatricesWeightsExtraKind
  23283. * @param data defines the data source
  23284. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23285. * @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)
  23286. */
  23287. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23288. /**
  23289. * Creates a new index buffer
  23290. * @param indices defines the indices to store in the index buffer
  23291. * @param totalVertices defines the total number of vertices (could be null)
  23292. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23293. */
  23294. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23295. }
  23296. /**
  23297. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23298. */
  23299. export class VertexData {
  23300. /**
  23301. * Mesh side orientation : usually the external or front surface
  23302. */
  23303. static readonly FRONTSIDE: number;
  23304. /**
  23305. * Mesh side orientation : usually the internal or back surface
  23306. */
  23307. static readonly BACKSIDE: number;
  23308. /**
  23309. * Mesh side orientation : both internal and external or front and back surfaces
  23310. */
  23311. static readonly DOUBLESIDE: number;
  23312. /**
  23313. * Mesh side orientation : by default, `FRONTSIDE`
  23314. */
  23315. static readonly DEFAULTSIDE: number;
  23316. /**
  23317. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23318. */
  23319. positions: Nullable<FloatArray>;
  23320. /**
  23321. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23322. */
  23323. normals: Nullable<FloatArray>;
  23324. /**
  23325. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23326. */
  23327. tangents: Nullable<FloatArray>;
  23328. /**
  23329. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23330. */
  23331. uvs: Nullable<FloatArray>;
  23332. /**
  23333. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23334. */
  23335. uvs2: Nullable<FloatArray>;
  23336. /**
  23337. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23338. */
  23339. uvs3: Nullable<FloatArray>;
  23340. /**
  23341. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23342. */
  23343. uvs4: Nullable<FloatArray>;
  23344. /**
  23345. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23346. */
  23347. uvs5: Nullable<FloatArray>;
  23348. /**
  23349. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23350. */
  23351. uvs6: Nullable<FloatArray>;
  23352. /**
  23353. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23354. */
  23355. colors: Nullable<FloatArray>;
  23356. /**
  23357. * 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).
  23358. */
  23359. matricesIndices: Nullable<FloatArray>;
  23360. /**
  23361. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23362. */
  23363. matricesWeights: Nullable<FloatArray>;
  23364. /**
  23365. * An array extending the number of possible indices
  23366. */
  23367. matricesIndicesExtra: Nullable<FloatArray>;
  23368. /**
  23369. * An array extending the number of possible weights when the number of indices is extended
  23370. */
  23371. matricesWeightsExtra: Nullable<FloatArray>;
  23372. /**
  23373. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23374. */
  23375. indices: Nullable<IndicesArray>;
  23376. /**
  23377. * Uses the passed data array to set the set the values for the specified kind of data
  23378. * @param data a linear array of floating numbers
  23379. * @param kind the type of data that is being set, eg positions, colors etc
  23380. */
  23381. set(data: FloatArray, kind: string): void;
  23382. /**
  23383. * Associates the vertexData to the passed Mesh.
  23384. * Sets it as updatable or not (default `false`)
  23385. * @param mesh the mesh the vertexData is applied to
  23386. * @param updatable when used and having the value true allows new data to update the vertexData
  23387. * @returns the VertexData
  23388. */
  23389. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23390. /**
  23391. * Associates the vertexData to the passed Geometry.
  23392. * Sets it as updatable or not (default `false`)
  23393. * @param geometry the geometry the vertexData is applied to
  23394. * @param updatable when used and having the value true allows new data to update the vertexData
  23395. * @returns VertexData
  23396. */
  23397. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23398. /**
  23399. * Updates the associated mesh
  23400. * @param mesh the mesh to be updated
  23401. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23402. * @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
  23403. * @returns VertexData
  23404. */
  23405. updateMesh(mesh: Mesh): VertexData;
  23406. /**
  23407. * Updates the associated geometry
  23408. * @param geometry the geometry to be updated
  23409. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23410. * @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
  23411. * @returns VertexData.
  23412. */
  23413. updateGeometry(geometry: Geometry): VertexData;
  23414. private _applyTo;
  23415. private _update;
  23416. /**
  23417. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23418. * @param matrix the transforming matrix
  23419. * @returns the VertexData
  23420. */
  23421. transform(matrix: Matrix): VertexData;
  23422. /**
  23423. * Merges the passed VertexData into the current one
  23424. * @param other the VertexData to be merged into the current one
  23425. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23426. * @returns the modified VertexData
  23427. */
  23428. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23429. private _mergeElement;
  23430. private _validate;
  23431. /**
  23432. * Serializes the VertexData
  23433. * @returns a serialized object
  23434. */
  23435. serialize(): any;
  23436. /**
  23437. * Extracts the vertexData from a mesh
  23438. * @param mesh the mesh from which to extract the VertexData
  23439. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23440. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23441. * @returns the object VertexData associated to the passed mesh
  23442. */
  23443. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23444. /**
  23445. * Extracts the vertexData from the geometry
  23446. * @param geometry the geometry from which to extract the VertexData
  23447. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23448. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23449. * @returns the object VertexData associated to the passed mesh
  23450. */
  23451. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23452. private static _ExtractFrom;
  23453. /**
  23454. * Creates the VertexData for a Ribbon
  23455. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23456. * * pathArray array of paths, each of which an array of successive Vector3
  23457. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23458. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23459. * * 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
  23460. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23461. * * 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)
  23462. * * 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)
  23463. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23464. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23465. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23466. * @returns the VertexData of the ribbon
  23467. */
  23468. static CreateRibbon(options: {
  23469. pathArray: Vector3[][];
  23470. closeArray?: boolean;
  23471. closePath?: boolean;
  23472. offset?: number;
  23473. sideOrientation?: number;
  23474. frontUVs?: Vector4;
  23475. backUVs?: Vector4;
  23476. invertUV?: boolean;
  23477. uvs?: Vector2[];
  23478. colors?: Color4[];
  23479. }): VertexData;
  23480. /**
  23481. * Creates the VertexData for a box
  23482. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23483. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23484. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23485. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23486. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23487. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23488. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23489. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23490. * * 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)
  23491. * * 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)
  23492. * @returns the VertexData of the box
  23493. */
  23494. static CreateBox(options: {
  23495. size?: number;
  23496. width?: number;
  23497. height?: number;
  23498. depth?: number;
  23499. faceUV?: Vector4[];
  23500. faceColors?: Color4[];
  23501. sideOrientation?: number;
  23502. frontUVs?: Vector4;
  23503. backUVs?: Vector4;
  23504. }): VertexData;
  23505. /**
  23506. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23507. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23508. * * segments sets the number of horizontal strips optional, default 32
  23509. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23510. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23511. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23512. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23513. * * 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
  23514. * * 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
  23515. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23516. * * 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)
  23517. * * 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)
  23518. * @returns the VertexData of the ellipsoid
  23519. */
  23520. static CreateSphere(options: {
  23521. segments?: number;
  23522. diameter?: number;
  23523. diameterX?: number;
  23524. diameterY?: number;
  23525. diameterZ?: number;
  23526. arc?: number;
  23527. slice?: number;
  23528. sideOrientation?: number;
  23529. frontUVs?: Vector4;
  23530. backUVs?: Vector4;
  23531. }): VertexData;
  23532. /**
  23533. * Creates the VertexData for a cylinder, cone or prism
  23534. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23535. * * height sets the height (y direction) of the cylinder, optional, default 2
  23536. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23537. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23538. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23539. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23540. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23541. * * 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
  23542. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23543. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23544. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23545. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23546. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23547. * * 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)
  23548. * * 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)
  23549. * @returns the VertexData of the cylinder, cone or prism
  23550. */
  23551. static CreateCylinder(options: {
  23552. height?: number;
  23553. diameterTop?: number;
  23554. diameterBottom?: number;
  23555. diameter?: number;
  23556. tessellation?: number;
  23557. subdivisions?: number;
  23558. arc?: number;
  23559. faceColors?: Color4[];
  23560. faceUV?: Vector4[];
  23561. hasRings?: boolean;
  23562. enclose?: boolean;
  23563. sideOrientation?: number;
  23564. frontUVs?: Vector4;
  23565. backUVs?: Vector4;
  23566. }): VertexData;
  23567. /**
  23568. * Creates the VertexData for a torus
  23569. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23570. * * diameter the diameter of the torus, optional default 1
  23571. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23572. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23573. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23574. * * 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)
  23575. * * 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)
  23576. * @returns the VertexData of the torus
  23577. */
  23578. static CreateTorus(options: {
  23579. diameter?: number;
  23580. thickness?: number;
  23581. tessellation?: number;
  23582. sideOrientation?: number;
  23583. frontUVs?: Vector4;
  23584. backUVs?: Vector4;
  23585. }): VertexData;
  23586. /**
  23587. * Creates the VertexData of the LineSystem
  23588. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23589. * - lines an array of lines, each line being an array of successive Vector3
  23590. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23591. * @returns the VertexData of the LineSystem
  23592. */
  23593. static CreateLineSystem(options: {
  23594. lines: Vector3[][];
  23595. colors?: Nullable<Color4[][]>;
  23596. }): VertexData;
  23597. /**
  23598. * Create the VertexData for a DashedLines
  23599. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23600. * - points an array successive Vector3
  23601. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23602. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23603. * - dashNb the intended total number of dashes, optional, default 200
  23604. * @returns the VertexData for the DashedLines
  23605. */
  23606. static CreateDashedLines(options: {
  23607. points: Vector3[];
  23608. dashSize?: number;
  23609. gapSize?: number;
  23610. dashNb?: number;
  23611. }): VertexData;
  23612. /**
  23613. * Creates the VertexData for a Ground
  23614. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23615. * - width the width (x direction) of the ground, optional, default 1
  23616. * - height the height (z direction) of the ground, optional, default 1
  23617. * - subdivisions the number of subdivisions per side, optional, default 1
  23618. * @returns the VertexData of the Ground
  23619. */
  23620. static CreateGround(options: {
  23621. width?: number;
  23622. height?: number;
  23623. subdivisions?: number;
  23624. subdivisionsX?: number;
  23625. subdivisionsY?: number;
  23626. }): VertexData;
  23627. /**
  23628. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23629. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23630. * * xmin the ground minimum X coordinate, optional, default -1
  23631. * * zmin the ground minimum Z coordinate, optional, default -1
  23632. * * xmax the ground maximum X coordinate, optional, default 1
  23633. * * zmax the ground maximum Z coordinate, optional, default 1
  23634. * * 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}
  23635. * * 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}
  23636. * @returns the VertexData of the TiledGround
  23637. */
  23638. static CreateTiledGround(options: {
  23639. xmin: number;
  23640. zmin: number;
  23641. xmax: number;
  23642. zmax: number;
  23643. subdivisions?: {
  23644. w: number;
  23645. h: number;
  23646. };
  23647. precision?: {
  23648. w: number;
  23649. h: number;
  23650. };
  23651. }): VertexData;
  23652. /**
  23653. * Creates the VertexData of the Ground designed from a heightmap
  23654. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23655. * * width the width (x direction) of the ground
  23656. * * height the height (z direction) of the ground
  23657. * * subdivisions the number of subdivisions per side
  23658. * * minHeight the minimum altitude on the ground, optional, default 0
  23659. * * maxHeight the maximum altitude on the ground, optional default 1
  23660. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23661. * * buffer the array holding the image color data
  23662. * * bufferWidth the width of image
  23663. * * bufferHeight the height of image
  23664. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23665. * @returns the VertexData of the Ground designed from a heightmap
  23666. */
  23667. static CreateGroundFromHeightMap(options: {
  23668. width: number;
  23669. height: number;
  23670. subdivisions: number;
  23671. minHeight: number;
  23672. maxHeight: number;
  23673. colorFilter: Color3;
  23674. buffer: Uint8Array;
  23675. bufferWidth: number;
  23676. bufferHeight: number;
  23677. alphaFilter: number;
  23678. }): VertexData;
  23679. /**
  23680. * Creates the VertexData for a Plane
  23681. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23682. * * size sets the width and height of the plane to the value of size, optional default 1
  23683. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23684. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23685. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23686. * * 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)
  23687. * * 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)
  23688. * @returns the VertexData of the box
  23689. */
  23690. static CreatePlane(options: {
  23691. size?: number;
  23692. width?: number;
  23693. height?: number;
  23694. sideOrientation?: number;
  23695. frontUVs?: Vector4;
  23696. backUVs?: Vector4;
  23697. }): VertexData;
  23698. /**
  23699. * Creates the VertexData of the Disc or regular Polygon
  23700. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23701. * * radius the radius of the disc, optional default 0.5
  23702. * * tessellation the number of polygon sides, optional, default 64
  23703. * * 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
  23704. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23705. * * 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)
  23706. * * 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)
  23707. * @returns the VertexData of the box
  23708. */
  23709. static CreateDisc(options: {
  23710. radius?: number;
  23711. tessellation?: number;
  23712. arc?: number;
  23713. sideOrientation?: number;
  23714. frontUVs?: Vector4;
  23715. backUVs?: Vector4;
  23716. }): VertexData;
  23717. /**
  23718. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23719. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23720. * @param polygon a mesh built from polygonTriangulation.build()
  23721. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23722. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23723. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23724. * @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)
  23725. * @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)
  23726. * @returns the VertexData of the Polygon
  23727. */
  23728. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23729. /**
  23730. * Creates the VertexData of the IcoSphere
  23731. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23732. * * radius the radius of the IcoSphere, optional default 1
  23733. * * radiusX allows stretching in the x direction, optional, default radius
  23734. * * radiusY allows stretching in the y direction, optional, default radius
  23735. * * radiusZ allows stretching in the z direction, optional, default radius
  23736. * * flat when true creates a flat shaded mesh, optional, default true
  23737. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23738. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23739. * * 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)
  23740. * * 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)
  23741. * @returns the VertexData of the IcoSphere
  23742. */
  23743. static CreateIcoSphere(options: {
  23744. radius?: number;
  23745. radiusX?: number;
  23746. radiusY?: number;
  23747. radiusZ?: number;
  23748. flat?: boolean;
  23749. subdivisions?: number;
  23750. sideOrientation?: number;
  23751. frontUVs?: Vector4;
  23752. backUVs?: Vector4;
  23753. }): VertexData;
  23754. /**
  23755. * Creates the VertexData for a Polyhedron
  23756. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23757. * * type provided types are:
  23758. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23759. * * 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)
  23760. * * size the size of the IcoSphere, optional default 1
  23761. * * sizeX allows stretching in the x direction, optional, default size
  23762. * * sizeY allows stretching in the y direction, optional, default size
  23763. * * sizeZ allows stretching in the z direction, optional, default size
  23764. * * 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
  23765. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23766. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23767. * * flat when true creates a flat shaded mesh, optional, default true
  23768. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23769. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23770. * * 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)
  23771. * * 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)
  23772. * @returns the VertexData of the Polyhedron
  23773. */
  23774. static CreatePolyhedron(options: {
  23775. type?: number;
  23776. size?: number;
  23777. sizeX?: number;
  23778. sizeY?: number;
  23779. sizeZ?: number;
  23780. custom?: any;
  23781. faceUV?: Vector4[];
  23782. faceColors?: Color4[];
  23783. flat?: boolean;
  23784. sideOrientation?: number;
  23785. frontUVs?: Vector4;
  23786. backUVs?: Vector4;
  23787. }): VertexData;
  23788. /**
  23789. * Creates the VertexData for a TorusKnot
  23790. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23791. * * radius the radius of the torus knot, optional, default 2
  23792. * * tube the thickness of the tube, optional, default 0.5
  23793. * * radialSegments the number of sides on each tube segments, optional, default 32
  23794. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23795. * * p the number of windings around the z axis, optional, default 2
  23796. * * q the number of windings around the x axis, optional, default 3
  23797. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23798. * * 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)
  23799. * * 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)
  23800. * @returns the VertexData of the Torus Knot
  23801. */
  23802. static CreateTorusKnot(options: {
  23803. radius?: number;
  23804. tube?: number;
  23805. radialSegments?: number;
  23806. tubularSegments?: number;
  23807. p?: number;
  23808. q?: number;
  23809. sideOrientation?: number;
  23810. frontUVs?: Vector4;
  23811. backUVs?: Vector4;
  23812. }): VertexData;
  23813. /**
  23814. * Compute normals for given positions and indices
  23815. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23816. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23817. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23818. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23819. * * facetNormals : optional array of facet normals (vector3)
  23820. * * facetPositions : optional array of facet positions (vector3)
  23821. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23822. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23823. * * bInfo : optional bounding info, required for facetPartitioning computation
  23824. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23825. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23826. * * useRightHandedSystem: optional boolean to for right handed system computation
  23827. * * depthSort : optional boolean to enable the facet depth sort computation
  23828. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23829. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23830. */
  23831. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23832. facetNormals?: any;
  23833. facetPositions?: any;
  23834. facetPartitioning?: any;
  23835. ratio?: number;
  23836. bInfo?: any;
  23837. bbSize?: Vector3;
  23838. subDiv?: any;
  23839. useRightHandedSystem?: boolean;
  23840. depthSort?: boolean;
  23841. distanceTo?: Vector3;
  23842. depthSortedFacets?: any;
  23843. }): void;
  23844. /** @hidden */
  23845. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23846. /**
  23847. * Applies VertexData created from the imported parameters to the geometry
  23848. * @param parsedVertexData the parsed data from an imported file
  23849. * @param geometry the geometry to apply the VertexData to
  23850. */
  23851. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23852. }
  23853. }
  23854. declare module "babylonjs/Meshes/Builders/discBuilder" {
  23855. import { Nullable } from "babylonjs/types";
  23856. import { Scene } from "babylonjs/scene";
  23857. import { Vector4 } from "babylonjs/Maths/math";
  23858. import { Mesh } from "babylonjs/Meshes/mesh";
  23859. /**
  23860. * Class containing static functions to help procedurally build meshes
  23861. */
  23862. export class DiscBuilder {
  23863. /**
  23864. * Creates a plane polygonal mesh. By default, this is a disc
  23865. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23866. * * 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
  23867. * * 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
  23868. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23869. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23870. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23871. * @param name defines the name of the mesh
  23872. * @param options defines the options used to create the mesh
  23873. * @param scene defines the hosting scene
  23874. * @returns the plane polygonal mesh
  23875. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23876. */
  23877. static CreateDisc(name: string, options: {
  23878. radius?: number;
  23879. tessellation?: number;
  23880. arc?: number;
  23881. updatable?: boolean;
  23882. sideOrientation?: number;
  23883. frontUVs?: Vector4;
  23884. backUVs?: Vector4;
  23885. }, scene?: Nullable<Scene>): Mesh;
  23886. }
  23887. }
  23888. declare module "babylonjs/Particles/solidParticleSystem" {
  23889. import { Vector3 } from "babylonjs/Maths/math";
  23890. import { Mesh } from "babylonjs/Meshes/mesh";
  23891. import { Scene, IDisposable } from "babylonjs/scene";
  23892. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  23893. /**
  23894. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23895. *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.
  23896. * The SPS is also a particle system. It provides some methods to manage the particles.
  23897. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23898. *
  23899. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23900. */
  23901. export class SolidParticleSystem implements IDisposable {
  23902. /**
  23903. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23904. * Example : var p = SPS.particles[i];
  23905. */
  23906. particles: SolidParticle[];
  23907. /**
  23908. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23909. */
  23910. nbParticles: number;
  23911. /**
  23912. * If the particles must ever face the camera (default false). Useful for planar particles.
  23913. */
  23914. billboard: boolean;
  23915. /**
  23916. * Recompute normals when adding a shape
  23917. */
  23918. recomputeNormals: boolean;
  23919. /**
  23920. * This a counter ofr your own usage. It's not set by any SPS functions.
  23921. */
  23922. counter: number;
  23923. /**
  23924. * The SPS name. This name is also given to the underlying mesh.
  23925. */
  23926. name: string;
  23927. /**
  23928. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23929. */
  23930. mesh: Mesh;
  23931. /**
  23932. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23933. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23934. */
  23935. vars: any;
  23936. /**
  23937. * This array is populated when the SPS is set as 'pickable'.
  23938. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23939. * Each element of this array is an object `{idx: int, faceId: int}`.
  23940. * `idx` is the picked particle index in the `SPS.particles` array
  23941. * `faceId` is the picked face index counted within this particle.
  23942. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23943. */
  23944. pickedParticles: {
  23945. idx: number;
  23946. faceId: number;
  23947. }[];
  23948. /**
  23949. * This array is populated when `enableDepthSort` is set to true.
  23950. * Each element of this array is an instance of the class DepthSortedParticle.
  23951. */
  23952. depthSortedParticles: DepthSortedParticle[];
  23953. /**
  23954. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23955. * @hidden
  23956. */
  23957. _bSphereOnly: boolean;
  23958. /**
  23959. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23960. * @hidden
  23961. */
  23962. _bSphereRadiusFactor: number;
  23963. private _scene;
  23964. private _positions;
  23965. private _indices;
  23966. private _normals;
  23967. private _colors;
  23968. private _uvs;
  23969. private _indices32;
  23970. private _positions32;
  23971. private _normals32;
  23972. private _fixedNormal32;
  23973. private _colors32;
  23974. private _uvs32;
  23975. private _index;
  23976. private _updatable;
  23977. private _pickable;
  23978. private _isVisibilityBoxLocked;
  23979. private _alwaysVisible;
  23980. private _depthSort;
  23981. private _shapeCounter;
  23982. private _copy;
  23983. private _color;
  23984. private _computeParticleColor;
  23985. private _computeParticleTexture;
  23986. private _computeParticleRotation;
  23987. private _computeParticleVertex;
  23988. private _computeBoundingBox;
  23989. private _depthSortParticles;
  23990. private _camera;
  23991. private _mustUnrotateFixedNormals;
  23992. private _particlesIntersect;
  23993. private _needs32Bits;
  23994. /**
  23995. * Creates a SPS (Solid Particle System) object.
  23996. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23997. * @param scene (Scene) is the scene in which the SPS is added.
  23998. * @param options defines the options of the sps e.g.
  23999. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24000. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24001. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24002. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24003. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24004. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24005. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24006. */
  24007. constructor(name: string, scene: Scene, options?: {
  24008. updatable?: boolean;
  24009. isPickable?: boolean;
  24010. enableDepthSort?: boolean;
  24011. particleIntersection?: boolean;
  24012. boundingSphereOnly?: boolean;
  24013. bSphereRadiusFactor?: number;
  24014. });
  24015. /**
  24016. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24017. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24018. * @returns the created mesh
  24019. */
  24020. buildMesh(): Mesh;
  24021. /**
  24022. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24023. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24024. * Thus the particles generated from `digest()` have their property `position` set yet.
  24025. * @param mesh ( Mesh ) is the mesh to be digested
  24026. * @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
  24027. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24028. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24029. * @returns the current SPS
  24030. */
  24031. digest(mesh: Mesh, options?: {
  24032. facetNb?: number;
  24033. number?: number;
  24034. delta?: number;
  24035. }): SolidParticleSystem;
  24036. private _unrotateFixedNormals;
  24037. private _resetCopy;
  24038. private _meshBuilder;
  24039. private _posToShape;
  24040. private _uvsToShapeUV;
  24041. private _addParticle;
  24042. /**
  24043. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24044. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24045. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24046. * @param nb (positive integer) the number of particles to be created from this model
  24047. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24048. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24049. * @returns the number of shapes in the system
  24050. */
  24051. addShape(mesh: Mesh, nb: number, options?: {
  24052. positionFunction?: any;
  24053. vertexFunction?: any;
  24054. }): number;
  24055. private _rebuildParticle;
  24056. /**
  24057. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24058. * @returns the SPS.
  24059. */
  24060. rebuildMesh(): SolidParticleSystem;
  24061. /**
  24062. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24063. * This method calls `updateParticle()` for each particle of the SPS.
  24064. * For an animated SPS, it is usually called within the render loop.
  24065. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24066. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24067. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24068. * @returns the SPS.
  24069. */
  24070. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24071. /**
  24072. * Disposes the SPS.
  24073. */
  24074. dispose(): void;
  24075. /**
  24076. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24077. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24078. * @returns the SPS.
  24079. */
  24080. refreshVisibleSize(): SolidParticleSystem;
  24081. /**
  24082. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24083. * @param size the size (float) of the visibility box
  24084. * note : this doesn't lock the SPS mesh bounding box.
  24085. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24086. */
  24087. setVisibilityBox(size: number): void;
  24088. /**
  24089. * Gets whether the SPS as always visible or not
  24090. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24091. */
  24092. /**
  24093. * Sets the SPS as always visible or not
  24094. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24095. */
  24096. isAlwaysVisible: boolean;
  24097. /**
  24098. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24099. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24100. */
  24101. /**
  24102. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24103. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24104. */
  24105. isVisibilityBoxLocked: boolean;
  24106. /**
  24107. * Tells to `setParticles()` to compute the particle rotations or not.
  24108. * Default value : true. The SPS is faster when it's set to false.
  24109. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24110. */
  24111. /**
  24112. * Gets if `setParticles()` computes the particle rotations or not.
  24113. * Default value : true. The SPS is faster when it's set to false.
  24114. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24115. */
  24116. computeParticleRotation: boolean;
  24117. /**
  24118. * Tells to `setParticles()` to compute the particle colors or not.
  24119. * Default value : true. The SPS is faster when it's set to false.
  24120. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24121. */
  24122. /**
  24123. * Gets if `setParticles()` computes the particle colors or not.
  24124. * Default value : true. The SPS is faster when it's set to false.
  24125. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24126. */
  24127. computeParticleColor: boolean;
  24128. /**
  24129. * Gets if `setParticles()` computes the particle textures or not.
  24130. * Default value : true. The SPS is faster when it's set to false.
  24131. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24132. */
  24133. computeParticleTexture: boolean;
  24134. /**
  24135. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24136. * Default value : false. The SPS is faster when it's set to false.
  24137. * Note : the particle custom vertex positions aren't stored values.
  24138. */
  24139. /**
  24140. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24141. * Default value : false. The SPS is faster when it's set to false.
  24142. * Note : the particle custom vertex positions aren't stored values.
  24143. */
  24144. computeParticleVertex: boolean;
  24145. /**
  24146. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24147. */
  24148. /**
  24149. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24150. */
  24151. computeBoundingBox: boolean;
  24152. /**
  24153. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24154. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24155. * Default : `true`
  24156. */
  24157. /**
  24158. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24159. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24160. * Default : `true`
  24161. */
  24162. depthSortParticles: boolean;
  24163. /**
  24164. * This function does nothing. It may be overwritten to set all the particle first values.
  24165. * The SPS doesn't call this function, you may have to call it by your own.
  24166. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24167. */
  24168. initParticles(): void;
  24169. /**
  24170. * This function does nothing. It may be overwritten to recycle a particle.
  24171. * The SPS doesn't call this function, you may have to call it by your own.
  24172. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24173. * @param particle The particle to recycle
  24174. * @returns the recycled particle
  24175. */
  24176. recycleParticle(particle: SolidParticle): SolidParticle;
  24177. /**
  24178. * Updates a particle : this function should be overwritten by the user.
  24179. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24180. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24181. * @example : just set a particle position or velocity and recycle conditions
  24182. * @param particle The particle to update
  24183. * @returns the updated particle
  24184. */
  24185. updateParticle(particle: SolidParticle): SolidParticle;
  24186. /**
  24187. * Updates a vertex of a particle : it can be overwritten by the user.
  24188. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24189. * @param particle the current particle
  24190. * @param vertex the current index of the current particle
  24191. * @param pt the index of the current vertex in the particle shape
  24192. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24193. * @example : just set a vertex particle position
  24194. * @returns the updated vertex
  24195. */
  24196. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24197. /**
  24198. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24199. * This does nothing and may be overwritten by the user.
  24200. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24201. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24202. * @param update the boolean update value actually passed to setParticles()
  24203. */
  24204. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24205. /**
  24206. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24207. * This will be passed three parameters.
  24208. * This does nothing and may be overwritten by the user.
  24209. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24210. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24211. * @param update the boolean update value actually passed to setParticles()
  24212. */
  24213. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24214. }
  24215. }
  24216. declare module "babylonjs/Particles/solidParticle" {
  24217. import { Nullable } from "babylonjs/types";
  24218. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  24219. import { Mesh } from "babylonjs/Meshes/mesh";
  24220. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24221. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  24222. /**
  24223. * Represents one particle of a solid particle system.
  24224. */
  24225. export class SolidParticle {
  24226. /**
  24227. * particle global index
  24228. */
  24229. idx: number;
  24230. /**
  24231. * The color of the particle
  24232. */
  24233. color: Nullable<Color4>;
  24234. /**
  24235. * The world space position of the particle.
  24236. */
  24237. position: Vector3;
  24238. /**
  24239. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24240. */
  24241. rotation: Vector3;
  24242. /**
  24243. * The world space rotation quaternion of the particle.
  24244. */
  24245. rotationQuaternion: Nullable<Quaternion>;
  24246. /**
  24247. * The scaling of the particle.
  24248. */
  24249. scaling: Vector3;
  24250. /**
  24251. * The uvs of the particle.
  24252. */
  24253. uvs: Vector4;
  24254. /**
  24255. * The current speed of the particle.
  24256. */
  24257. velocity: Vector3;
  24258. /**
  24259. * The pivot point in the particle local space.
  24260. */
  24261. pivot: Vector3;
  24262. /**
  24263. * Must the particle be translated from its pivot point in its local space ?
  24264. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24265. * Default : false
  24266. */
  24267. translateFromPivot: boolean;
  24268. /**
  24269. * Is the particle active or not ?
  24270. */
  24271. alive: boolean;
  24272. /**
  24273. * Is the particle visible or not ?
  24274. */
  24275. isVisible: boolean;
  24276. /**
  24277. * Index of this particle in the global "positions" array (Internal use)
  24278. * @hidden
  24279. */
  24280. _pos: number;
  24281. /**
  24282. * @hidden Index of this particle in the global "indices" array (Internal use)
  24283. */
  24284. _ind: number;
  24285. /**
  24286. * @hidden ModelShape of this particle (Internal use)
  24287. */
  24288. _model: ModelShape;
  24289. /**
  24290. * ModelShape id of this particle
  24291. */
  24292. shapeId: number;
  24293. /**
  24294. * Index of the particle in its shape id (Internal use)
  24295. */
  24296. idxInShape: number;
  24297. /**
  24298. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24299. */
  24300. _modelBoundingInfo: BoundingInfo;
  24301. /**
  24302. * @hidden Particle BoundingInfo object (Internal use)
  24303. */
  24304. _boundingInfo: BoundingInfo;
  24305. /**
  24306. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24307. */
  24308. _sps: SolidParticleSystem;
  24309. /**
  24310. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24311. */
  24312. _stillInvisible: boolean;
  24313. /**
  24314. * @hidden Last computed particle rotation matrix
  24315. */
  24316. _rotationMatrix: number[];
  24317. /**
  24318. * Parent particle Id, if any.
  24319. * Default null.
  24320. */
  24321. parentId: Nullable<number>;
  24322. /**
  24323. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24324. * The possible values are :
  24325. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24326. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24327. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24328. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24329. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24330. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24331. * */
  24332. cullingStrategy: number;
  24333. /**
  24334. * @hidden Internal global position in the SPS.
  24335. */
  24336. _globalPosition: Vector3;
  24337. /**
  24338. * Creates a Solid Particle object.
  24339. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24340. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24341. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24342. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24343. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24344. * @param shapeId (integer) is the model shape identifier in the SPS.
  24345. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24346. * @param sps defines the sps it is associated to
  24347. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24348. */
  24349. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24350. /**
  24351. * Legacy support, changed scale to scaling
  24352. */
  24353. /**
  24354. * Legacy support, changed scale to scaling
  24355. */
  24356. scale: Vector3;
  24357. /**
  24358. * Legacy support, changed quaternion to rotationQuaternion
  24359. */
  24360. /**
  24361. * Legacy support, changed quaternion to rotationQuaternion
  24362. */
  24363. quaternion: Nullable<Quaternion>;
  24364. /**
  24365. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24366. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24367. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24368. * @returns true if it intersects
  24369. */
  24370. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24371. /**
  24372. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24373. * A particle is in the frustum if its bounding box intersects the frustum
  24374. * @param frustumPlanes defines the frustum to test
  24375. * @returns true if the particle is in the frustum planes
  24376. */
  24377. isInFrustum(frustumPlanes: Plane[]): boolean;
  24378. /**
  24379. * get the rotation matrix of the particle
  24380. * @hidden
  24381. */
  24382. getRotationMatrix(m: Matrix): void;
  24383. }
  24384. /**
  24385. * Represents the shape of the model used by one particle of a solid particle system.
  24386. * SPS internal tool, don't use it manually.
  24387. */
  24388. export class ModelShape {
  24389. /**
  24390. * The shape id
  24391. * @hidden
  24392. */
  24393. shapeID: number;
  24394. /**
  24395. * flat array of model positions (internal use)
  24396. * @hidden
  24397. */
  24398. _shape: Vector3[];
  24399. /**
  24400. * flat array of model UVs (internal use)
  24401. * @hidden
  24402. */
  24403. _shapeUV: number[];
  24404. /**
  24405. * length of the shape in the model indices array (internal use)
  24406. * @hidden
  24407. */
  24408. _indicesLength: number;
  24409. /**
  24410. * Custom position function (internal use)
  24411. * @hidden
  24412. */
  24413. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24414. /**
  24415. * Custom vertex function (internal use)
  24416. * @hidden
  24417. */
  24418. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24419. /**
  24420. * 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.
  24421. * SPS internal tool, don't use it manually.
  24422. * @hidden
  24423. */
  24424. 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>);
  24425. }
  24426. /**
  24427. * Represents a Depth Sorted Particle in the solid particle system.
  24428. */
  24429. export class DepthSortedParticle {
  24430. /**
  24431. * Index of the particle in the "indices" array
  24432. */
  24433. ind: number;
  24434. /**
  24435. * Length of the particle shape in the "indices" array
  24436. */
  24437. indicesLength: number;
  24438. /**
  24439. * Squared distance from the particle to the camera
  24440. */
  24441. sqDistance: number;
  24442. }
  24443. }
  24444. declare module "babylonjs/Meshes/abstractMesh" {
  24445. import { Observable } from "babylonjs/Misc/observable";
  24446. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  24447. import { Camera } from "babylonjs/Cameras/camera";
  24448. import { Scene, IDisposable } from "babylonjs/scene";
  24449. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  24450. import { Node } from "babylonjs/node";
  24451. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24452. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24453. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24454. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  24455. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24456. import { Material } from "babylonjs/Materials/material";
  24457. import { Light } from "babylonjs/Lights/light";
  24458. import { Skeleton } from "babylonjs/Bones/skeleton";
  24459. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  24460. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  24461. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  24462. import { Ray } from "babylonjs/Culling/ray";
  24463. import { Collider } from "babylonjs/Collisions/collider";
  24464. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  24465. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  24466. /**
  24467. * Class used to store all common mesh properties
  24468. */
  24469. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24470. /** No occlusion */
  24471. static OCCLUSION_TYPE_NONE: number;
  24472. /** Occlusion set to optimisitic */
  24473. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24474. /** Occlusion set to strict */
  24475. static OCCLUSION_TYPE_STRICT: number;
  24476. /** Use an accurante occlusion algorithm */
  24477. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24478. /** Use a conservative occlusion algorithm */
  24479. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24480. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24481. * Test order :
  24482. * Is the bounding sphere outside the frustum ?
  24483. * If not, are the bounding box vertices outside the frustum ?
  24484. * It not, then the cullable object is in the frustum.
  24485. */
  24486. static readonly CULLINGSTRATEGY_STANDARD: number;
  24487. /** Culling strategy : Bounding Sphere Only.
  24488. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24489. * It's also less accurate than the standard because some not visible objects can still be selected.
  24490. * Test : is the bounding sphere outside the frustum ?
  24491. * If not, then the cullable object is in the frustum.
  24492. */
  24493. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24494. /** Culling strategy : Optimistic Inclusion.
  24495. * This in an inclusion test first, then the standard exclusion test.
  24496. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24497. * 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.
  24498. * Anyway, it's as accurate as the standard strategy.
  24499. * Test :
  24500. * Is the cullable object bounding sphere center in the frustum ?
  24501. * If not, apply the default culling strategy.
  24502. */
  24503. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24504. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24505. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24506. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24507. * 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.
  24508. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24509. * Test :
  24510. * Is the cullable object bounding sphere center in the frustum ?
  24511. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24512. */
  24513. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24514. /**
  24515. * No billboard
  24516. */
  24517. static readonly BILLBOARDMODE_NONE: number;
  24518. /** Billboard on X axis */
  24519. static readonly BILLBOARDMODE_X: number;
  24520. /** Billboard on Y axis */
  24521. static readonly BILLBOARDMODE_Y: number;
  24522. /** Billboard on Z axis */
  24523. static readonly BILLBOARDMODE_Z: number;
  24524. /** Billboard on all axes */
  24525. static readonly BILLBOARDMODE_ALL: number;
  24526. private _facetData;
  24527. /**
  24528. * The culling strategy to use to check whether the mesh must be rendered or not.
  24529. * This value can be changed at any time and will be used on the next render mesh selection.
  24530. * The possible values are :
  24531. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24532. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24533. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24534. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24535. * Please read each static variable documentation to get details about the culling process.
  24536. * */
  24537. cullingStrategy: number;
  24538. /**
  24539. * Gets the number of facets in the mesh
  24540. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24541. */
  24542. readonly facetNb: number;
  24543. /**
  24544. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24545. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24546. */
  24547. partitioningSubdivisions: number;
  24548. /**
  24549. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24550. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24551. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24552. */
  24553. partitioningBBoxRatio: number;
  24554. /**
  24555. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24556. * Works only for updatable meshes.
  24557. * Doesn't work with multi-materials
  24558. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24559. */
  24560. mustDepthSortFacets: boolean;
  24561. /**
  24562. * The location (Vector3) where the facet depth sort must be computed from.
  24563. * By default, the active camera position.
  24564. * Used only when facet depth sort is enabled
  24565. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24566. */
  24567. facetDepthSortFrom: Vector3;
  24568. /**
  24569. * gets a boolean indicating if facetData is enabled
  24570. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24571. */
  24572. readonly isFacetDataEnabled: boolean;
  24573. /** @hidden */
  24574. _updateNonUniformScalingState(value: boolean): boolean;
  24575. /**
  24576. * An event triggered when this mesh collides with another one
  24577. */
  24578. onCollideObservable: Observable<AbstractMesh>;
  24579. private _onCollideObserver;
  24580. /** Set a function to call when this mesh collides with another one */
  24581. onCollide: () => void;
  24582. /**
  24583. * An event triggered when the collision's position changes
  24584. */
  24585. onCollisionPositionChangeObservable: Observable<Vector3>;
  24586. private _onCollisionPositionChangeObserver;
  24587. /** Set a function to call when the collision's position changes */
  24588. onCollisionPositionChange: () => void;
  24589. /**
  24590. * An event triggered when material is changed
  24591. */
  24592. onMaterialChangedObservable: Observable<AbstractMesh>;
  24593. /**
  24594. * Gets or sets the orientation for POV movement & rotation
  24595. */
  24596. definedFacingForward: boolean;
  24597. /** @hidden */
  24598. _occlusionQuery: Nullable<WebGLQuery>;
  24599. private _visibility;
  24600. /** @hidden */
  24601. _isActive: boolean;
  24602. /** @hidden */
  24603. _renderingGroup: RenderingGroup;
  24604. /**
  24605. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24606. */
  24607. /**
  24608. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24609. */
  24610. visibility: number;
  24611. /** Gets or sets the alpha index used to sort transparent meshes
  24612. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24613. */
  24614. alphaIndex: number;
  24615. /**
  24616. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24617. */
  24618. isVisible: boolean;
  24619. /**
  24620. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24621. */
  24622. isPickable: boolean;
  24623. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24624. showSubMeshesBoundingBox: boolean;
  24625. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24626. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24627. */
  24628. isBlocker: boolean;
  24629. /**
  24630. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24631. */
  24632. enablePointerMoveEvents: boolean;
  24633. /**
  24634. * Specifies the rendering group id for this mesh (0 by default)
  24635. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24636. */
  24637. renderingGroupId: number;
  24638. private _material;
  24639. /** Gets or sets current material */
  24640. material: Nullable<Material>;
  24641. private _receiveShadows;
  24642. /**
  24643. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24644. * @see http://doc.babylonjs.com/babylon101/shadows
  24645. */
  24646. receiveShadows: boolean;
  24647. /** Defines color to use when rendering outline */
  24648. outlineColor: Color3;
  24649. /** Define width to use when rendering outline */
  24650. outlineWidth: number;
  24651. /** Defines color to use when rendering overlay */
  24652. overlayColor: Color3;
  24653. /** Defines alpha to use when rendering overlay */
  24654. overlayAlpha: number;
  24655. private _hasVertexAlpha;
  24656. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24657. hasVertexAlpha: boolean;
  24658. private _useVertexColors;
  24659. /** 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) */
  24660. useVertexColors: boolean;
  24661. private _computeBonesUsingShaders;
  24662. /**
  24663. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24664. */
  24665. computeBonesUsingShaders: boolean;
  24666. private _numBoneInfluencers;
  24667. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24668. numBoneInfluencers: number;
  24669. private _applyFog;
  24670. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24671. applyFog: boolean;
  24672. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24673. useOctreeForRenderingSelection: boolean;
  24674. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24675. useOctreeForPicking: boolean;
  24676. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24677. useOctreeForCollisions: boolean;
  24678. private _layerMask;
  24679. /**
  24680. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24681. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24682. */
  24683. layerMask: number;
  24684. /**
  24685. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24686. */
  24687. alwaysSelectAsActiveMesh: boolean;
  24688. /**
  24689. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  24690. */
  24691. doNotSyncBoundingInfo: boolean;
  24692. /**
  24693. * Gets or sets the current action manager
  24694. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24695. */
  24696. actionManager: Nullable<AbstractActionManager>;
  24697. private _checkCollisions;
  24698. private _collisionMask;
  24699. private _collisionGroup;
  24700. /**
  24701. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24702. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24703. */
  24704. ellipsoid: Vector3;
  24705. /**
  24706. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24707. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24708. */
  24709. ellipsoidOffset: Vector3;
  24710. private _collider;
  24711. private _oldPositionForCollisions;
  24712. private _diffPositionForCollisions;
  24713. /**
  24714. * Gets or sets a collision mask used to mask collisions (default is -1).
  24715. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24716. */
  24717. collisionMask: number;
  24718. /**
  24719. * Gets or sets the current collision group mask (-1 by default).
  24720. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24721. */
  24722. collisionGroup: number;
  24723. /**
  24724. * Defines edge width used when edgesRenderer is enabled
  24725. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24726. */
  24727. edgesWidth: number;
  24728. /**
  24729. * Defines edge color used when edgesRenderer is enabled
  24730. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24731. */
  24732. edgesColor: Color4;
  24733. /** @hidden */
  24734. _edgesRenderer: Nullable<IEdgesRenderer>;
  24735. /** @hidden */
  24736. _masterMesh: Nullable<AbstractMesh>;
  24737. /** @hidden */
  24738. _boundingInfo: Nullable<BoundingInfo>;
  24739. /** @hidden */
  24740. _renderId: number;
  24741. /**
  24742. * Gets or sets the list of subMeshes
  24743. * @see http://doc.babylonjs.com/how_to/multi_materials
  24744. */
  24745. subMeshes: SubMesh[];
  24746. /** @hidden */
  24747. _intersectionsInProgress: AbstractMesh[];
  24748. /** @hidden */
  24749. _unIndexed: boolean;
  24750. /** @hidden */
  24751. _lightSources: Light[];
  24752. /** @hidden */
  24753. readonly _positions: Nullable<Vector3[]>;
  24754. /** @hidden */
  24755. _waitingActions: any;
  24756. /** @hidden */
  24757. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24758. private _skeleton;
  24759. /** @hidden */
  24760. _bonesTransformMatrices: Nullable<Float32Array>;
  24761. /**
  24762. * Gets or sets a skeleton to apply skining transformations
  24763. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24764. */
  24765. skeleton: Nullable<Skeleton>;
  24766. /**
  24767. * An event triggered when the mesh is rebuilt.
  24768. */
  24769. onRebuildObservable: Observable<AbstractMesh>;
  24770. /**
  24771. * Creates a new AbstractMesh
  24772. * @param name defines the name of the mesh
  24773. * @param scene defines the hosting scene
  24774. */
  24775. constructor(name: string, scene?: Nullable<Scene>);
  24776. /**
  24777. * Returns the string "AbstractMesh"
  24778. * @returns "AbstractMesh"
  24779. */
  24780. getClassName(): string;
  24781. /**
  24782. * Gets a string representation of the current mesh
  24783. * @param fullDetails defines a boolean indicating if full details must be included
  24784. * @returns a string representation of the current mesh
  24785. */
  24786. toString(fullDetails?: boolean): string;
  24787. /**
  24788. * @hidden
  24789. */
  24790. protected _getEffectiveParent(): Nullable<Node>;
  24791. /** @hidden */
  24792. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24793. /** @hidden */
  24794. _rebuild(): void;
  24795. /** @hidden */
  24796. _resyncLightSources(): void;
  24797. /** @hidden */
  24798. _resyncLighSource(light: Light): void;
  24799. /** @hidden */
  24800. _unBindEffect(): void;
  24801. /** @hidden */
  24802. _removeLightSource(light: Light): void;
  24803. private _markSubMeshesAsDirty;
  24804. /** @hidden */
  24805. _markSubMeshesAsLightDirty(): void;
  24806. /** @hidden */
  24807. _markSubMeshesAsAttributesDirty(): void;
  24808. /** @hidden */
  24809. _markSubMeshesAsMiscDirty(): void;
  24810. /**
  24811. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24812. */
  24813. scaling: Vector3;
  24814. /**
  24815. * Returns true if the mesh is blocked. Implemented by child classes
  24816. */
  24817. readonly isBlocked: boolean;
  24818. /**
  24819. * Returns the mesh itself by default. Implemented by child classes
  24820. * @param camera defines the camera to use to pick the right LOD level
  24821. * @returns the currentAbstractMesh
  24822. */
  24823. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24824. /**
  24825. * Returns 0 by default. Implemented by child classes
  24826. * @returns an integer
  24827. */
  24828. getTotalVertices(): number;
  24829. /**
  24830. * Returns a positive integer : the total number of indices in this mesh geometry.
  24831. * @returns the numner of indices or zero if the mesh has no geometry.
  24832. */
  24833. getTotalIndices(): number;
  24834. /**
  24835. * Returns null by default. Implemented by child classes
  24836. * @returns null
  24837. */
  24838. getIndices(): Nullable<IndicesArray>;
  24839. /**
  24840. * Returns the array of the requested vertex data kind. Implemented by child classes
  24841. * @param kind defines the vertex data kind to use
  24842. * @returns null
  24843. */
  24844. getVerticesData(kind: string): Nullable<FloatArray>;
  24845. /**
  24846. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24847. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24848. * Note that a new underlying VertexBuffer object is created each call.
  24849. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24850. * @param kind defines vertex data kind:
  24851. * * VertexBuffer.PositionKind
  24852. * * VertexBuffer.UVKind
  24853. * * VertexBuffer.UV2Kind
  24854. * * VertexBuffer.UV3Kind
  24855. * * VertexBuffer.UV4Kind
  24856. * * VertexBuffer.UV5Kind
  24857. * * VertexBuffer.UV6Kind
  24858. * * VertexBuffer.ColorKind
  24859. * * VertexBuffer.MatricesIndicesKind
  24860. * * VertexBuffer.MatricesIndicesExtraKind
  24861. * * VertexBuffer.MatricesWeightsKind
  24862. * * VertexBuffer.MatricesWeightsExtraKind
  24863. * @param data defines the data source
  24864. * @param updatable defines if the data must be flagged as updatable (or static)
  24865. * @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
  24866. * @returns the current mesh
  24867. */
  24868. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24869. /**
  24870. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24871. * If the mesh has no geometry, it is simply returned as it is.
  24872. * @param kind defines vertex data kind:
  24873. * * VertexBuffer.PositionKind
  24874. * * VertexBuffer.UVKind
  24875. * * VertexBuffer.UV2Kind
  24876. * * VertexBuffer.UV3Kind
  24877. * * VertexBuffer.UV4Kind
  24878. * * VertexBuffer.UV5Kind
  24879. * * VertexBuffer.UV6Kind
  24880. * * VertexBuffer.ColorKind
  24881. * * VertexBuffer.MatricesIndicesKind
  24882. * * VertexBuffer.MatricesIndicesExtraKind
  24883. * * VertexBuffer.MatricesWeightsKind
  24884. * * VertexBuffer.MatricesWeightsExtraKind
  24885. * @param data defines the data source
  24886. * @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
  24887. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24888. * @returns the current mesh
  24889. */
  24890. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24891. /**
  24892. * Sets the mesh indices,
  24893. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24894. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24895. * @param totalVertices Defines the total number of vertices
  24896. * @returns the current mesh
  24897. */
  24898. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24899. /**
  24900. * Gets a boolean indicating if specific vertex data is present
  24901. * @param kind defines the vertex data kind to use
  24902. * @returns true is data kind is present
  24903. */
  24904. isVerticesDataPresent(kind: string): boolean;
  24905. /**
  24906. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24907. * @returns a BoundingInfo
  24908. */
  24909. getBoundingInfo(): BoundingInfo;
  24910. /**
  24911. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24912. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  24913. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  24914. * @returns the current mesh
  24915. */
  24916. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  24917. /**
  24918. * Overwrite the current bounding info
  24919. * @param boundingInfo defines the new bounding info
  24920. * @returns the current mesh
  24921. */
  24922. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24923. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24924. readonly useBones: boolean;
  24925. /** @hidden */
  24926. _preActivate(): void;
  24927. /** @hidden */
  24928. _preActivateForIntermediateRendering(renderId: number): void;
  24929. /** @hidden */
  24930. _activate(renderId: number): boolean;
  24931. /** @hidden */
  24932. _freeze(): void;
  24933. /** @hidden */
  24934. _unFreeze(): void;
  24935. /**
  24936. * Gets the current world matrix
  24937. * @returns a Matrix
  24938. */
  24939. getWorldMatrix(): Matrix;
  24940. /** @hidden */
  24941. _getWorldMatrixDeterminant(): number;
  24942. /**
  24943. * Perform relative position change from the point of view of behind the front of the mesh.
  24944. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24945. * Supports definition of mesh facing forward or backward
  24946. * @param amountRight defines the distance on the right axis
  24947. * @param amountUp defines the distance on the up axis
  24948. * @param amountForward defines the distance on the forward axis
  24949. * @returns the current mesh
  24950. */
  24951. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24952. /**
  24953. * Calculate relative position change from the point of view of behind the front of the mesh.
  24954. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24955. * Supports definition of mesh facing forward or backward
  24956. * @param amountRight defines the distance on the right axis
  24957. * @param amountUp defines the distance on the up axis
  24958. * @param amountForward defines the distance on the forward axis
  24959. * @returns the new displacement vector
  24960. */
  24961. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24962. /**
  24963. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24964. * Supports definition of mesh facing forward or backward
  24965. * @param flipBack defines the flip
  24966. * @param twirlClockwise defines the twirl
  24967. * @param tiltRight defines the tilt
  24968. * @returns the current mesh
  24969. */
  24970. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24971. /**
  24972. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24973. * Supports definition of mesh facing forward or backward.
  24974. * @param flipBack defines the flip
  24975. * @param twirlClockwise defines the twirl
  24976. * @param tiltRight defines the tilt
  24977. * @returns the new rotation vector
  24978. */
  24979. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24980. /**
  24981. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24982. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24983. * @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
  24984. * @returns the new bounding vectors
  24985. */
  24986. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24987. min: Vector3;
  24988. max: Vector3;
  24989. };
  24990. /**
  24991. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24992. * This means the mesh underlying bounding box and sphere are recomputed.
  24993. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24994. * @returns the current mesh
  24995. */
  24996. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24997. /** @hidden */
  24998. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24999. /** @hidden */
  25000. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25001. /** @hidden */
  25002. _updateBoundingInfo(): AbstractMesh;
  25003. /** @hidden */
  25004. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25005. /** @hidden */
  25006. protected _afterComputeWorldMatrix(): void;
  25007. /** @hidden */
  25008. readonly _effectiveMesh: AbstractMesh;
  25009. /**
  25010. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25011. * A mesh is in the frustum if its bounding box intersects the frustum
  25012. * @param frustumPlanes defines the frustum to test
  25013. * @returns true if the mesh is in the frustum planes
  25014. */
  25015. isInFrustum(frustumPlanes: Plane[]): boolean;
  25016. /**
  25017. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25018. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25019. * @param frustumPlanes defines the frustum to test
  25020. * @returns true if the mesh is completely in the frustum planes
  25021. */
  25022. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25023. /**
  25024. * True if the mesh intersects another mesh or a SolidParticle object
  25025. * @param mesh defines a target mesh or SolidParticle to test
  25026. * @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)
  25027. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25028. * @returns true if there is an intersection
  25029. */
  25030. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25031. /**
  25032. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25033. * @param point defines the point to test
  25034. * @returns true if there is an intersection
  25035. */
  25036. intersectsPoint(point: Vector3): boolean;
  25037. /**
  25038. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25039. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25040. */
  25041. checkCollisions: boolean;
  25042. /**
  25043. * Gets Collider object used to compute collisions (not physics)
  25044. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25045. */
  25046. readonly collider: Collider;
  25047. /**
  25048. * Move the mesh using collision engine
  25049. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25050. * @param displacement defines the requested displacement vector
  25051. * @returns the current mesh
  25052. */
  25053. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25054. private _onCollisionPositionChange;
  25055. /** @hidden */
  25056. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25057. /** @hidden */
  25058. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25059. /** @hidden */
  25060. _checkCollision(collider: Collider): AbstractMesh;
  25061. /** @hidden */
  25062. _generatePointsArray(): boolean;
  25063. /**
  25064. * Checks if the passed Ray intersects with the mesh
  25065. * @param ray defines the ray to use
  25066. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25067. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25068. * @returns the picking info
  25069. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25070. */
  25071. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25072. /**
  25073. * Clones the current mesh
  25074. * @param name defines the mesh name
  25075. * @param newParent defines the new mesh parent
  25076. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25077. * @returns the new mesh
  25078. */
  25079. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25080. /**
  25081. * Disposes all the submeshes of the current meshnp
  25082. * @returns the current mesh
  25083. */
  25084. releaseSubMeshes(): AbstractMesh;
  25085. /**
  25086. * Releases resources associated with this abstract mesh.
  25087. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25088. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25089. */
  25090. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25091. /**
  25092. * Adds the passed mesh as a child to the current mesh
  25093. * @param mesh defines the child mesh
  25094. * @returns the current mesh
  25095. */
  25096. addChild(mesh: AbstractMesh): AbstractMesh;
  25097. /**
  25098. * Removes the passed mesh from the current mesh children list
  25099. * @param mesh defines the child mesh
  25100. * @returns the current mesh
  25101. */
  25102. removeChild(mesh: AbstractMesh): AbstractMesh;
  25103. /** @hidden */
  25104. private _initFacetData;
  25105. /**
  25106. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25107. * This method can be called within the render loop.
  25108. * 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
  25109. * @returns the current mesh
  25110. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25111. */
  25112. updateFacetData(): AbstractMesh;
  25113. /**
  25114. * Returns the facetLocalNormals array.
  25115. * The normals are expressed in the mesh local spac
  25116. * @returns an array of Vector3
  25117. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25118. */
  25119. getFacetLocalNormals(): Vector3[];
  25120. /**
  25121. * Returns the facetLocalPositions array.
  25122. * The facet positions are expressed in the mesh local space
  25123. * @returns an array of Vector3
  25124. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25125. */
  25126. getFacetLocalPositions(): Vector3[];
  25127. /**
  25128. * Returns the facetLocalPartioning array
  25129. * @returns an array of array of numbers
  25130. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25131. */
  25132. getFacetLocalPartitioning(): number[][];
  25133. /**
  25134. * Returns the i-th facet position in the world system.
  25135. * This method allocates a new Vector3 per call
  25136. * @param i defines the facet index
  25137. * @returns a new Vector3
  25138. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25139. */
  25140. getFacetPosition(i: number): Vector3;
  25141. /**
  25142. * Sets the reference Vector3 with the i-th facet position in the world system
  25143. * @param i defines the facet index
  25144. * @param ref defines the target vector
  25145. * @returns the current mesh
  25146. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25147. */
  25148. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25149. /**
  25150. * Returns the i-th facet normal in the world system.
  25151. * This method allocates a new Vector3 per call
  25152. * @param i defines the facet index
  25153. * @returns a new Vector3
  25154. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25155. */
  25156. getFacetNormal(i: number): Vector3;
  25157. /**
  25158. * Sets the reference Vector3 with the i-th facet normal in the world system
  25159. * @param i defines the facet index
  25160. * @param ref defines the target vector
  25161. * @returns the current mesh
  25162. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25163. */
  25164. getFacetNormalToRef(i: number, ref: Vector3): this;
  25165. /**
  25166. * 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)
  25167. * @param x defines x coordinate
  25168. * @param y defines y coordinate
  25169. * @param z defines z coordinate
  25170. * @returns the array of facet indexes
  25171. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25172. */
  25173. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25174. /**
  25175. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25176. * @param projected sets as the (x,y,z) world projection on the facet
  25177. * @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
  25178. * @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
  25179. * @param x defines x coordinate
  25180. * @param y defines y coordinate
  25181. * @param z defines z coordinate
  25182. * @returns the face index if found (or null instead)
  25183. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25184. */
  25185. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25186. /**
  25187. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25188. * @param projected sets as the (x,y,z) local projection on the facet
  25189. * @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
  25190. * @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
  25191. * @param x defines x coordinate
  25192. * @param y defines y coordinate
  25193. * @param z defines z coordinate
  25194. * @returns the face index if found (or null instead)
  25195. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25196. */
  25197. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25198. /**
  25199. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25200. * @returns the parameters
  25201. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25202. */
  25203. getFacetDataParameters(): any;
  25204. /**
  25205. * Disables the feature FacetData and frees the related memory
  25206. * @returns the current mesh
  25207. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25208. */
  25209. disableFacetData(): AbstractMesh;
  25210. /**
  25211. * Updates the AbstractMesh indices array
  25212. * @param indices defines the data source
  25213. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25214. * @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)
  25215. * @returns the current mesh
  25216. */
  25217. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25218. /**
  25219. * Creates new normals data for the mesh
  25220. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25221. * @returns the current mesh
  25222. */
  25223. createNormals(updatable: boolean): AbstractMesh;
  25224. /**
  25225. * Align the mesh with a normal
  25226. * @param normal defines the normal to use
  25227. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25228. * @returns the current mesh
  25229. */
  25230. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25231. /** @hidden */
  25232. _checkOcclusionQuery(): boolean;
  25233. }
  25234. }
  25235. declare module "babylonjs/Actions/actionEvent" {
  25236. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25237. import { Nullable } from "babylonjs/types";
  25238. import { Sprite } from "babylonjs/Sprites/sprite";
  25239. import { Scene } from "babylonjs/scene";
  25240. import { Vector2 } from "babylonjs/Maths/math";
  25241. /**
  25242. * Interface used to define ActionEvent
  25243. */
  25244. export interface IActionEvent {
  25245. /** The mesh or sprite that triggered the action */
  25246. source: any;
  25247. /** The X mouse cursor position at the time of the event */
  25248. pointerX: number;
  25249. /** The Y mouse cursor position at the time of the event */
  25250. pointerY: number;
  25251. /** The mesh that is currently pointed at (can be null) */
  25252. meshUnderPointer: Nullable<AbstractMesh>;
  25253. /** the original (browser) event that triggered the ActionEvent */
  25254. sourceEvent?: any;
  25255. /** additional data for the event */
  25256. additionalData?: any;
  25257. }
  25258. /**
  25259. * ActionEvent is the event being sent when an action is triggered.
  25260. */
  25261. export class ActionEvent implements IActionEvent {
  25262. /** The mesh or sprite that triggered the action */
  25263. source: any;
  25264. /** The X mouse cursor position at the time of the event */
  25265. pointerX: number;
  25266. /** The Y mouse cursor position at the time of the event */
  25267. pointerY: number;
  25268. /** The mesh that is currently pointed at (can be null) */
  25269. meshUnderPointer: Nullable<AbstractMesh>;
  25270. /** the original (browser) event that triggered the ActionEvent */
  25271. sourceEvent?: any;
  25272. /** additional data for the event */
  25273. additionalData?: any;
  25274. /**
  25275. * Creates a new ActionEvent
  25276. * @param source The mesh or sprite that triggered the action
  25277. * @param pointerX The X mouse cursor position at the time of the event
  25278. * @param pointerY The Y mouse cursor position at the time of the event
  25279. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25280. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25281. * @param additionalData additional data for the event
  25282. */
  25283. constructor(
  25284. /** The mesh or sprite that triggered the action */
  25285. source: any,
  25286. /** The X mouse cursor position at the time of the event */
  25287. pointerX: number,
  25288. /** The Y mouse cursor position at the time of the event */
  25289. pointerY: number,
  25290. /** The mesh that is currently pointed at (can be null) */
  25291. meshUnderPointer: Nullable<AbstractMesh>,
  25292. /** the original (browser) event that triggered the ActionEvent */
  25293. sourceEvent?: any,
  25294. /** additional data for the event */
  25295. additionalData?: any);
  25296. /**
  25297. * Helper function to auto-create an ActionEvent from a source mesh.
  25298. * @param source The source mesh that triggered the event
  25299. * @param evt The original (browser) event
  25300. * @param additionalData additional data for the event
  25301. * @returns the new ActionEvent
  25302. */
  25303. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25304. /**
  25305. * Helper function to auto-create an ActionEvent from a source sprite
  25306. * @param source The source sprite that triggered the event
  25307. * @param scene Scene associated with the sprite
  25308. * @param evt The original (browser) event
  25309. * @param additionalData additional data for the event
  25310. * @returns the new ActionEvent
  25311. */
  25312. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25313. /**
  25314. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25315. * @param scene the scene where the event occurred
  25316. * @param evt The original (browser) event
  25317. * @returns the new ActionEvent
  25318. */
  25319. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25320. /**
  25321. * Helper function to auto-create an ActionEvent from a primitive
  25322. * @param prim defines the target primitive
  25323. * @param pointerPos defines the pointer position
  25324. * @param evt The original (browser) event
  25325. * @param additionalData additional data for the event
  25326. * @returns the new ActionEvent
  25327. */
  25328. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25329. }
  25330. }
  25331. declare module "babylonjs/Actions/abstractActionManager" {
  25332. import { IDisposable } from "babylonjs/scene";
  25333. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  25334. import { IAction } from "babylonjs/Actions/action";
  25335. import { Nullable } from "babylonjs/types";
  25336. /**
  25337. * Abstract class used to decouple action Manager from scene and meshes.
  25338. * Do not instantiate.
  25339. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25340. */
  25341. export abstract class AbstractActionManager implements IDisposable {
  25342. /** Gets the list of active triggers */
  25343. static Triggers: {
  25344. [key: string]: number;
  25345. };
  25346. /** Gets the cursor to use when hovering items */
  25347. hoverCursor: string;
  25348. /** Gets the list of actions */
  25349. actions: IAction[];
  25350. /**
  25351. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25352. */
  25353. isRecursive: boolean;
  25354. /**
  25355. * Releases all associated resources
  25356. */
  25357. abstract dispose(): void;
  25358. /**
  25359. * Does this action manager has pointer triggers
  25360. */
  25361. abstract readonly hasPointerTriggers: boolean;
  25362. /**
  25363. * Does this action manager has pick triggers
  25364. */
  25365. abstract readonly hasPickTriggers: boolean;
  25366. /**
  25367. * Process a specific trigger
  25368. * @param trigger defines the trigger to process
  25369. * @param evt defines the event details to be processed
  25370. */
  25371. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25372. /**
  25373. * Does this action manager handles actions of any of the given triggers
  25374. * @param triggers defines the triggers to be tested
  25375. * @return a boolean indicating whether one (or more) of the triggers is handled
  25376. */
  25377. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25378. /**
  25379. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25380. * speed.
  25381. * @param triggerA defines the trigger to be tested
  25382. * @param triggerB defines the trigger to be tested
  25383. * @return a boolean indicating whether one (or more) of the triggers is handled
  25384. */
  25385. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  25386. /**
  25387. * Does this action manager handles actions of a given trigger
  25388. * @param trigger defines the trigger to be tested
  25389. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  25390. * @return whether the trigger is handled
  25391. */
  25392. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  25393. /**
  25394. * Serialize this manager to a JSON object
  25395. * @param name defines the property name to store this manager
  25396. * @returns a JSON representation of this manager
  25397. */
  25398. abstract serialize(name: string): any;
  25399. /**
  25400. * Registers an action to this action manager
  25401. * @param action defines the action to be registered
  25402. * @return the action amended (prepared) after registration
  25403. */
  25404. abstract registerAction(action: IAction): Nullable<IAction>;
  25405. /**
  25406. * Unregisters an action to this action manager
  25407. * @param action defines the action to be unregistered
  25408. * @return a boolean indicating whether the action has been unregistered
  25409. */
  25410. abstract unregisterAction(action: IAction): Boolean;
  25411. /**
  25412. * Does exist one action manager with at least one trigger
  25413. **/
  25414. static readonly HasTriggers: boolean;
  25415. /**
  25416. * Does exist one action manager with at least one pick trigger
  25417. **/
  25418. static readonly HasPickTriggers: boolean;
  25419. /**
  25420. * Does exist one action manager that handles actions of a given trigger
  25421. * @param trigger defines the trigger to be tested
  25422. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25423. **/
  25424. static HasSpecificTrigger(trigger: number): boolean;
  25425. }
  25426. }
  25427. declare module "babylonjs/node" {
  25428. import { Scene } from "babylonjs/scene";
  25429. import { Nullable } from "babylonjs/types";
  25430. import { Matrix } from "babylonjs/Maths/math";
  25431. import { Engine } from "babylonjs/Engines/engine";
  25432. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  25433. import { Observable } from "babylonjs/Misc/observable";
  25434. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  25435. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25436. import { Animatable } from "babylonjs/Animations/animatable";
  25437. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  25438. import { Animation } from "babylonjs/Animations/animation";
  25439. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25440. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25441. /**
  25442. * Defines how a node can be built from a string name.
  25443. */
  25444. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25445. /**
  25446. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25447. */
  25448. export class Node implements IBehaviorAware<Node> {
  25449. /** @hidden */
  25450. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  25451. private static _NodeConstructors;
  25452. /**
  25453. * Add a new node constructor
  25454. * @param type defines the type name of the node to construct
  25455. * @param constructorFunc defines the constructor function
  25456. */
  25457. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25458. /**
  25459. * Returns a node constructor based on type name
  25460. * @param type defines the type name
  25461. * @param name defines the new node name
  25462. * @param scene defines the hosting scene
  25463. * @param options defines optional options to transmit to constructors
  25464. * @returns the new constructor or null
  25465. */
  25466. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25467. /**
  25468. * Gets or sets the name of the node
  25469. */
  25470. name: string;
  25471. /**
  25472. * Gets or sets the id of the node
  25473. */
  25474. id: string;
  25475. /**
  25476. * Gets or sets the unique id of the node
  25477. */
  25478. uniqueId: number;
  25479. /**
  25480. * Gets or sets a string used to store user defined state for the node
  25481. */
  25482. state: string;
  25483. /**
  25484. * Gets or sets an object used to store user defined information for the node
  25485. */
  25486. metadata: any;
  25487. /**
  25488. * For internal use only. Please do not use.
  25489. */
  25490. reservedDataStore: any;
  25491. /**
  25492. * List of inspectable custom properties (used by the Inspector)
  25493. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25494. */
  25495. inspectableCustomProperties: IInspectable[];
  25496. /**
  25497. * Gets or sets a boolean used to define if the node must be serialized
  25498. */
  25499. doNotSerialize: boolean;
  25500. /** @hidden */
  25501. _isDisposed: boolean;
  25502. /**
  25503. * Gets a list of Animations associated with the node
  25504. */
  25505. animations: import("babylonjs/Animations/animation").Animation[];
  25506. protected _ranges: {
  25507. [name: string]: Nullable<AnimationRange>;
  25508. };
  25509. /**
  25510. * Callback raised when the node is ready to be used
  25511. */
  25512. onReady: (node: Node) => void;
  25513. private _isEnabled;
  25514. private _isParentEnabled;
  25515. private _isReady;
  25516. /** @hidden */
  25517. _currentRenderId: number;
  25518. private _parentUpdateId;
  25519. protected _childUpdateId: number;
  25520. /** @hidden */
  25521. _waitingParentId: Nullable<string>;
  25522. /** @hidden */
  25523. _scene: Scene;
  25524. /** @hidden */
  25525. _cache: any;
  25526. private _parentNode;
  25527. private _children;
  25528. /** @hidden */
  25529. _worldMatrix: Matrix;
  25530. /** @hidden */
  25531. _worldMatrixDeterminant: number;
  25532. /** @hidden */
  25533. _worldMatrixDeterminantIsDirty: boolean;
  25534. /** @hidden */
  25535. private _sceneRootNodesIndex;
  25536. /**
  25537. * Gets a boolean indicating if the node has been disposed
  25538. * @returns true if the node was disposed
  25539. */
  25540. isDisposed(): boolean;
  25541. /**
  25542. * Gets or sets the parent of the node (without keeping the current position in the scene)
  25543. * @see https://doc.babylonjs.com/how_to/parenting
  25544. */
  25545. parent: Nullable<Node>;
  25546. private addToSceneRootNodes;
  25547. private removeFromSceneRootNodes;
  25548. private _animationPropertiesOverride;
  25549. /**
  25550. * Gets or sets the animation properties override
  25551. */
  25552. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25553. /**
  25554. * Gets a string idenfifying the name of the class
  25555. * @returns "Node" string
  25556. */
  25557. getClassName(): string;
  25558. /** @hidden */
  25559. readonly _isNode: boolean;
  25560. /**
  25561. * An event triggered when the mesh is disposed
  25562. */
  25563. onDisposeObservable: Observable<Node>;
  25564. private _onDisposeObserver;
  25565. /**
  25566. * Sets a callback that will be raised when the node will be disposed
  25567. */
  25568. onDispose: () => void;
  25569. /**
  25570. * Creates a new Node
  25571. * @param name the name and id to be given to this node
  25572. * @param scene the scene this node will be added to
  25573. * @param addToRootNodes the node will be added to scene.rootNodes
  25574. */
  25575. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25576. /**
  25577. * Gets the scene of the node
  25578. * @returns a scene
  25579. */
  25580. getScene(): Scene;
  25581. /**
  25582. * Gets the engine of the node
  25583. * @returns a Engine
  25584. */
  25585. getEngine(): Engine;
  25586. private _behaviors;
  25587. /**
  25588. * Attach a behavior to the node
  25589. * @see http://doc.babylonjs.com/features/behaviour
  25590. * @param behavior defines the behavior to attach
  25591. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  25592. * @returns the current Node
  25593. */
  25594. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  25595. /**
  25596. * Remove an attached behavior
  25597. * @see http://doc.babylonjs.com/features/behaviour
  25598. * @param behavior defines the behavior to attach
  25599. * @returns the current Node
  25600. */
  25601. removeBehavior(behavior: Behavior<Node>): Node;
  25602. /**
  25603. * Gets the list of attached behaviors
  25604. * @see http://doc.babylonjs.com/features/behaviour
  25605. */
  25606. readonly behaviors: Behavior<Node>[];
  25607. /**
  25608. * Gets an attached behavior by name
  25609. * @param name defines the name of the behavior to look for
  25610. * @see http://doc.babylonjs.com/features/behaviour
  25611. * @returns null if behavior was not found else the requested behavior
  25612. */
  25613. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  25614. /**
  25615. * Returns the latest update of the World matrix
  25616. * @returns a Matrix
  25617. */
  25618. getWorldMatrix(): Matrix;
  25619. /** @hidden */
  25620. _getWorldMatrixDeterminant(): number;
  25621. /**
  25622. * Returns directly the latest state of the mesh World matrix.
  25623. * A Matrix is returned.
  25624. */
  25625. readonly worldMatrixFromCache: Matrix;
  25626. /** @hidden */
  25627. _initCache(): void;
  25628. /** @hidden */
  25629. updateCache(force?: boolean): void;
  25630. /** @hidden */
  25631. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25632. /** @hidden */
  25633. _updateCache(ignoreParentClass?: boolean): void;
  25634. /** @hidden */
  25635. _isSynchronized(): boolean;
  25636. /** @hidden */
  25637. _markSyncedWithParent(): void;
  25638. /** @hidden */
  25639. isSynchronizedWithParent(): boolean;
  25640. /** @hidden */
  25641. isSynchronized(): boolean;
  25642. /**
  25643. * Is this node ready to be used/rendered
  25644. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25645. * @return true if the node is ready
  25646. */
  25647. isReady(completeCheck?: boolean): boolean;
  25648. /**
  25649. * Is this node enabled?
  25650. * 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
  25651. * @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
  25652. * @return whether this node (and its parent) is enabled
  25653. */
  25654. isEnabled(checkAncestors?: boolean): boolean;
  25655. /** @hidden */
  25656. protected _syncParentEnabledState(): void;
  25657. /**
  25658. * Set the enabled state of this node
  25659. * @param value defines the new enabled state
  25660. */
  25661. setEnabled(value: boolean): void;
  25662. /**
  25663. * Is this node a descendant of the given node?
  25664. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25665. * @param ancestor defines the parent node to inspect
  25666. * @returns a boolean indicating if this node is a descendant of the given node
  25667. */
  25668. isDescendantOf(ancestor: Node): boolean;
  25669. /** @hidden */
  25670. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25671. /**
  25672. * Will return all nodes that have this node as ascendant
  25673. * @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
  25674. * @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
  25675. * @return all children nodes of all types
  25676. */
  25677. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25678. /**
  25679. * Get all child-meshes of this node
  25680. * @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)
  25681. * @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
  25682. * @returns an array of AbstractMesh
  25683. */
  25684. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25685. /**
  25686. * Get all direct children of this node
  25687. * @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
  25688. * @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)
  25689. * @returns an array of Node
  25690. */
  25691. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25692. /** @hidden */
  25693. _setReady(state: boolean): void;
  25694. /**
  25695. * Get an animation by name
  25696. * @param name defines the name of the animation to look for
  25697. * @returns null if not found else the requested animation
  25698. */
  25699. getAnimationByName(name: string): Nullable<Animation>;
  25700. /**
  25701. * Creates an animation range for this node
  25702. * @param name defines the name of the range
  25703. * @param from defines the starting key
  25704. * @param to defines the end key
  25705. */
  25706. createAnimationRange(name: string, from: number, to: number): void;
  25707. /**
  25708. * Delete a specific animation range
  25709. * @param name defines the name of the range to delete
  25710. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25711. */
  25712. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25713. /**
  25714. * Get an animation range by name
  25715. * @param name defines the name of the animation range to look for
  25716. * @returns null if not found else the requested animation range
  25717. */
  25718. getAnimationRange(name: string): Nullable<AnimationRange>;
  25719. /**
  25720. * Gets the list of all animation ranges defined on this node
  25721. * @returns an array
  25722. */
  25723. getAnimationRanges(): Nullable<AnimationRange>[];
  25724. /**
  25725. * Will start the animation sequence
  25726. * @param name defines the range frames for animation sequence
  25727. * @param loop defines if the animation should loop (false by default)
  25728. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25729. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25730. * @returns the object created for this animation. If range does not exist, it will return null
  25731. */
  25732. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25733. /**
  25734. * Serialize animation ranges into a JSON compatible object
  25735. * @returns serialization object
  25736. */
  25737. serializeAnimationRanges(): any;
  25738. /**
  25739. * Computes the world matrix of the node
  25740. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25741. * @returns the world matrix
  25742. */
  25743. computeWorldMatrix(force?: boolean): Matrix;
  25744. /**
  25745. * Releases resources associated with this node.
  25746. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25747. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25748. */
  25749. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25750. /**
  25751. * Parse animation range data from a serialization object and store them into a given node
  25752. * @param node defines where to store the animation ranges
  25753. * @param parsedNode defines the serialization object to read data from
  25754. * @param scene defines the hosting scene
  25755. */
  25756. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25757. }
  25758. }
  25759. declare module "babylonjs/Animations/animation" {
  25760. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  25761. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  25762. import { Nullable } from "babylonjs/types";
  25763. import { Scene } from "babylonjs/scene";
  25764. import { IAnimatable } from "babylonjs/Misc/tools";
  25765. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  25766. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25767. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  25768. import { Node } from "babylonjs/node";
  25769. import { Animatable } from "babylonjs/Animations/animatable";
  25770. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  25771. /**
  25772. * Class used to store any kind of animation
  25773. */
  25774. export class Animation {
  25775. /**Name of the animation */
  25776. name: string;
  25777. /**Property to animate */
  25778. targetProperty: string;
  25779. /**The frames per second of the animation */
  25780. framePerSecond: number;
  25781. /**The data type of the animation */
  25782. dataType: number;
  25783. /**The loop mode of the animation */
  25784. loopMode?: number | undefined;
  25785. /**Specifies if blending should be enabled */
  25786. enableBlending?: boolean | undefined;
  25787. /**
  25788. * Use matrix interpolation instead of using direct key value when animating matrices
  25789. */
  25790. static AllowMatricesInterpolation: boolean;
  25791. /**
  25792. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25793. */
  25794. static AllowMatrixDecomposeForInterpolation: boolean;
  25795. /**
  25796. * Stores the key frames of the animation
  25797. */
  25798. private _keys;
  25799. /**
  25800. * Stores the easing function of the animation
  25801. */
  25802. private _easingFunction;
  25803. /**
  25804. * @hidden Internal use only
  25805. */
  25806. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  25807. /**
  25808. * The set of event that will be linked to this animation
  25809. */
  25810. private _events;
  25811. /**
  25812. * Stores an array of target property paths
  25813. */
  25814. targetPropertyPath: string[];
  25815. /**
  25816. * Stores the blending speed of the animation
  25817. */
  25818. blendingSpeed: number;
  25819. /**
  25820. * Stores the animation ranges for the animation
  25821. */
  25822. private _ranges;
  25823. /**
  25824. * @hidden Internal use
  25825. */
  25826. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25827. /**
  25828. * Sets up an animation
  25829. * @param property The property to animate
  25830. * @param animationType The animation type to apply
  25831. * @param framePerSecond The frames per second of the animation
  25832. * @param easingFunction The easing function used in the animation
  25833. * @returns The created animation
  25834. */
  25835. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25836. /**
  25837. * Create and start an animation on a node
  25838. * @param name defines the name of the global animation that will be run on all nodes
  25839. * @param node defines the root node where the animation will take place
  25840. * @param targetProperty defines property to animate
  25841. * @param framePerSecond defines the number of frame per second yo use
  25842. * @param totalFrame defines the number of frames in total
  25843. * @param from defines the initial value
  25844. * @param to defines the final value
  25845. * @param loopMode defines which loop mode you want to use (off by default)
  25846. * @param easingFunction defines the easing function to use (linear by default)
  25847. * @param onAnimationEnd defines the callback to call when animation end
  25848. * @returns the animatable created for this animation
  25849. */
  25850. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25851. /**
  25852. * Create and start an animation on a node and its descendants
  25853. * @param name defines the name of the global animation that will be run on all nodes
  25854. * @param node defines the root node where the animation will take place
  25855. * @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
  25856. * @param targetProperty defines property to animate
  25857. * @param framePerSecond defines the number of frame per second to use
  25858. * @param totalFrame defines the number of frames in total
  25859. * @param from defines the initial value
  25860. * @param to defines the final value
  25861. * @param loopMode defines which loop mode you want to use (off by default)
  25862. * @param easingFunction defines the easing function to use (linear by default)
  25863. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25864. * @returns the list of animatables created for all nodes
  25865. * @example https://www.babylonjs-playground.com/#MH0VLI
  25866. */
  25867. 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[]>;
  25868. /**
  25869. * Creates a new animation, merges it with the existing animations and starts it
  25870. * @param name Name of the animation
  25871. * @param node Node which contains the scene that begins the animations
  25872. * @param targetProperty Specifies which property to animate
  25873. * @param framePerSecond The frames per second of the animation
  25874. * @param totalFrame The total number of frames
  25875. * @param from The frame at the beginning of the animation
  25876. * @param to The frame at the end of the animation
  25877. * @param loopMode Specifies the loop mode of the animation
  25878. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25879. * @param onAnimationEnd Callback to run once the animation is complete
  25880. * @returns Nullable animation
  25881. */
  25882. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25883. /**
  25884. * Transition property of an host to the target Value
  25885. * @param property The property to transition
  25886. * @param targetValue The target Value of the property
  25887. * @param host The object where the property to animate belongs
  25888. * @param scene Scene used to run the animation
  25889. * @param frameRate Framerate (in frame/s) to use
  25890. * @param transition The transition type we want to use
  25891. * @param duration The duration of the animation, in milliseconds
  25892. * @param onAnimationEnd Callback trigger at the end of the animation
  25893. * @returns Nullable animation
  25894. */
  25895. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25896. /**
  25897. * Return the array of runtime animations currently using this animation
  25898. */
  25899. readonly runtimeAnimations: RuntimeAnimation[];
  25900. /**
  25901. * Specifies if any of the runtime animations are currently running
  25902. */
  25903. readonly hasRunningRuntimeAnimations: boolean;
  25904. /**
  25905. * Initializes the animation
  25906. * @param name Name of the animation
  25907. * @param targetProperty Property to animate
  25908. * @param framePerSecond The frames per second of the animation
  25909. * @param dataType The data type of the animation
  25910. * @param loopMode The loop mode of the animation
  25911. * @param enableBlending Specifies if blending should be enabled
  25912. */
  25913. constructor(
  25914. /**Name of the animation */
  25915. name: string,
  25916. /**Property to animate */
  25917. targetProperty: string,
  25918. /**The frames per second of the animation */
  25919. framePerSecond: number,
  25920. /**The data type of the animation */
  25921. dataType: number,
  25922. /**The loop mode of the animation */
  25923. loopMode?: number | undefined,
  25924. /**Specifies if blending should be enabled */
  25925. enableBlending?: boolean | undefined);
  25926. /**
  25927. * Converts the animation to a string
  25928. * @param fullDetails support for multiple levels of logging within scene loading
  25929. * @returns String form of the animation
  25930. */
  25931. toString(fullDetails?: boolean): string;
  25932. /**
  25933. * Add an event to this animation
  25934. * @param event Event to add
  25935. */
  25936. addEvent(event: AnimationEvent): void;
  25937. /**
  25938. * Remove all events found at the given frame
  25939. * @param frame The frame to remove events from
  25940. */
  25941. removeEvents(frame: number): void;
  25942. /**
  25943. * Retrieves all the events from the animation
  25944. * @returns Events from the animation
  25945. */
  25946. getEvents(): AnimationEvent[];
  25947. /**
  25948. * Creates an animation range
  25949. * @param name Name of the animation range
  25950. * @param from Starting frame of the animation range
  25951. * @param to Ending frame of the animation
  25952. */
  25953. createRange(name: string, from: number, to: number): void;
  25954. /**
  25955. * Deletes an animation range by name
  25956. * @param name Name of the animation range to delete
  25957. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25958. */
  25959. deleteRange(name: string, deleteFrames?: boolean): void;
  25960. /**
  25961. * Gets the animation range by name, or null if not defined
  25962. * @param name Name of the animation range
  25963. * @returns Nullable animation range
  25964. */
  25965. getRange(name: string): Nullable<AnimationRange>;
  25966. /**
  25967. * Gets the key frames from the animation
  25968. * @returns The key frames of the animation
  25969. */
  25970. getKeys(): Array<IAnimationKey>;
  25971. /**
  25972. * Gets the highest frame rate of the animation
  25973. * @returns Highest frame rate of the animation
  25974. */
  25975. getHighestFrame(): number;
  25976. /**
  25977. * Gets the easing function of the animation
  25978. * @returns Easing function of the animation
  25979. */
  25980. getEasingFunction(): IEasingFunction;
  25981. /**
  25982. * Sets the easing function of the animation
  25983. * @param easingFunction A custom mathematical formula for animation
  25984. */
  25985. setEasingFunction(easingFunction: EasingFunction): void;
  25986. /**
  25987. * Interpolates a scalar linearly
  25988. * @param startValue Start value of the animation curve
  25989. * @param endValue End value of the animation curve
  25990. * @param gradient Scalar amount to interpolate
  25991. * @returns Interpolated scalar value
  25992. */
  25993. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25994. /**
  25995. * Interpolates a scalar cubically
  25996. * @param startValue Start value of the animation curve
  25997. * @param outTangent End tangent of the animation
  25998. * @param endValue End value of the animation curve
  25999. * @param inTangent Start tangent of the animation curve
  26000. * @param gradient Scalar amount to interpolate
  26001. * @returns Interpolated scalar value
  26002. */
  26003. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26004. /**
  26005. * Interpolates a quaternion using a spherical linear interpolation
  26006. * @param startValue Start value of the animation curve
  26007. * @param endValue End value of the animation curve
  26008. * @param gradient Scalar amount to interpolate
  26009. * @returns Interpolated quaternion value
  26010. */
  26011. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26012. /**
  26013. * Interpolates a quaternion cubically
  26014. * @param startValue Start value of the animation curve
  26015. * @param outTangent End tangent of the animation curve
  26016. * @param endValue End value of the animation curve
  26017. * @param inTangent Start tangent of the animation curve
  26018. * @param gradient Scalar amount to interpolate
  26019. * @returns Interpolated quaternion value
  26020. */
  26021. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26022. /**
  26023. * Interpolates a Vector3 linearl
  26024. * @param startValue Start value of the animation curve
  26025. * @param endValue End value of the animation curve
  26026. * @param gradient Scalar amount to interpolate
  26027. * @returns Interpolated scalar value
  26028. */
  26029. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26030. /**
  26031. * Interpolates a Vector3 cubically
  26032. * @param startValue Start value of the animation curve
  26033. * @param outTangent End tangent of the animation
  26034. * @param endValue End value of the animation curve
  26035. * @param inTangent Start tangent of the animation curve
  26036. * @param gradient Scalar amount to interpolate
  26037. * @returns InterpolatedVector3 value
  26038. */
  26039. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26040. /**
  26041. * Interpolates a Vector2 linearly
  26042. * @param startValue Start value of the animation curve
  26043. * @param endValue End value of the animation curve
  26044. * @param gradient Scalar amount to interpolate
  26045. * @returns Interpolated Vector2 value
  26046. */
  26047. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26048. /**
  26049. * Interpolates a Vector2 cubically
  26050. * @param startValue Start value of the animation curve
  26051. * @param outTangent End tangent of the animation
  26052. * @param endValue End value of the animation curve
  26053. * @param inTangent Start tangent of the animation curve
  26054. * @param gradient Scalar amount to interpolate
  26055. * @returns Interpolated Vector2 value
  26056. */
  26057. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26058. /**
  26059. * Interpolates a size linearly
  26060. * @param startValue Start value of the animation curve
  26061. * @param endValue End value of the animation curve
  26062. * @param gradient Scalar amount to interpolate
  26063. * @returns Interpolated Size value
  26064. */
  26065. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26066. /**
  26067. * Interpolates a Color3 linearly
  26068. * @param startValue Start value of the animation curve
  26069. * @param endValue End value of the animation curve
  26070. * @param gradient Scalar amount to interpolate
  26071. * @returns Interpolated Color3 value
  26072. */
  26073. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26074. /**
  26075. * @hidden Internal use only
  26076. */
  26077. _getKeyValue(value: any): any;
  26078. /**
  26079. * @hidden Internal use only
  26080. */
  26081. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  26082. /**
  26083. * Defines the function to use to interpolate matrices
  26084. * @param startValue defines the start matrix
  26085. * @param endValue defines the end matrix
  26086. * @param gradient defines the gradient between both matrices
  26087. * @param result defines an optional target matrix where to store the interpolation
  26088. * @returns the interpolated matrix
  26089. */
  26090. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26091. /**
  26092. * Makes a copy of the animation
  26093. * @returns Cloned animation
  26094. */
  26095. clone(): Animation;
  26096. /**
  26097. * Sets the key frames of the animation
  26098. * @param values The animation key frames to set
  26099. */
  26100. setKeys(values: Array<IAnimationKey>): void;
  26101. /**
  26102. * Serializes the animation to an object
  26103. * @returns Serialized object
  26104. */
  26105. serialize(): any;
  26106. /**
  26107. * Float animation type
  26108. */
  26109. private static _ANIMATIONTYPE_FLOAT;
  26110. /**
  26111. * Vector3 animation type
  26112. */
  26113. private static _ANIMATIONTYPE_VECTOR3;
  26114. /**
  26115. * Quaternion animation type
  26116. */
  26117. private static _ANIMATIONTYPE_QUATERNION;
  26118. /**
  26119. * Matrix animation type
  26120. */
  26121. private static _ANIMATIONTYPE_MATRIX;
  26122. /**
  26123. * Color3 animation type
  26124. */
  26125. private static _ANIMATIONTYPE_COLOR3;
  26126. /**
  26127. * Vector2 animation type
  26128. */
  26129. private static _ANIMATIONTYPE_VECTOR2;
  26130. /**
  26131. * Size animation type
  26132. */
  26133. private static _ANIMATIONTYPE_SIZE;
  26134. /**
  26135. * Relative Loop Mode
  26136. */
  26137. private static _ANIMATIONLOOPMODE_RELATIVE;
  26138. /**
  26139. * Cycle Loop Mode
  26140. */
  26141. private static _ANIMATIONLOOPMODE_CYCLE;
  26142. /**
  26143. * Constant Loop Mode
  26144. */
  26145. private static _ANIMATIONLOOPMODE_CONSTANT;
  26146. /**
  26147. * Get the float animation type
  26148. */
  26149. static readonly ANIMATIONTYPE_FLOAT: number;
  26150. /**
  26151. * Get the Vector3 animation type
  26152. */
  26153. static readonly ANIMATIONTYPE_VECTOR3: number;
  26154. /**
  26155. * Get the Vector2 animation type
  26156. */
  26157. static readonly ANIMATIONTYPE_VECTOR2: number;
  26158. /**
  26159. * Get the Size animation type
  26160. */
  26161. static readonly ANIMATIONTYPE_SIZE: number;
  26162. /**
  26163. * Get the Quaternion animation type
  26164. */
  26165. static readonly ANIMATIONTYPE_QUATERNION: number;
  26166. /**
  26167. * Get the Matrix animation type
  26168. */
  26169. static readonly ANIMATIONTYPE_MATRIX: number;
  26170. /**
  26171. * Get the Color3 animation type
  26172. */
  26173. static readonly ANIMATIONTYPE_COLOR3: number;
  26174. /**
  26175. * Get the Relative Loop Mode
  26176. */
  26177. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26178. /**
  26179. * Get the Cycle Loop Mode
  26180. */
  26181. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26182. /**
  26183. * Get the Constant Loop Mode
  26184. */
  26185. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26186. /** @hidden */
  26187. static _UniversalLerp(left: any, right: any, amount: number): any;
  26188. /**
  26189. * Parses an animation object and creates an animation
  26190. * @param parsedAnimation Parsed animation object
  26191. * @returns Animation object
  26192. */
  26193. static Parse(parsedAnimation: any): Animation;
  26194. /**
  26195. * Appends the serialized animations from the source animations
  26196. * @param source Source containing the animations
  26197. * @param destination Target to store the animations
  26198. */
  26199. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26200. }
  26201. }
  26202. declare module "babylonjs/Materials/Textures/baseTexture" {
  26203. import { Observable } from "babylonjs/Misc/observable";
  26204. import { IAnimatable } from "babylonjs/Misc/tools";
  26205. import { Nullable } from "babylonjs/types";
  26206. import { Scene } from "babylonjs/scene";
  26207. import { Matrix, ISize } from "babylonjs/Maths/math";
  26208. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26209. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26210. /**
  26211. * Base class of all the textures in babylon.
  26212. * It groups all the common properties the materials, post process, lights... might need
  26213. * in order to make a correct use of the texture.
  26214. */
  26215. export class BaseTexture implements IAnimatable {
  26216. /**
  26217. * Default anisotropic filtering level for the application.
  26218. * It is set to 4 as a good tradeoff between perf and quality.
  26219. */
  26220. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26221. /**
  26222. * Gets or sets the unique id of the texture
  26223. */
  26224. uniqueId: number;
  26225. /**
  26226. * Define the name of the texture.
  26227. */
  26228. name: string;
  26229. /**
  26230. * Gets or sets an object used to store user defined information.
  26231. */
  26232. metadata: any;
  26233. /**
  26234. * For internal use only. Please do not use.
  26235. */
  26236. reservedDataStore: any;
  26237. private _hasAlpha;
  26238. /**
  26239. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26240. */
  26241. hasAlpha: boolean;
  26242. /**
  26243. * Defines if the alpha value should be determined via the rgb values.
  26244. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26245. */
  26246. getAlphaFromRGB: boolean;
  26247. /**
  26248. * Intensity or strength of the texture.
  26249. * It is commonly used by materials to fine tune the intensity of the texture
  26250. */
  26251. level: number;
  26252. /**
  26253. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26254. * This is part of the texture as textures usually maps to one uv set.
  26255. */
  26256. coordinatesIndex: number;
  26257. private _coordinatesMode;
  26258. /**
  26259. * How a texture is mapped.
  26260. *
  26261. * | Value | Type | Description |
  26262. * | ----- | ----------------------------------- | ----------- |
  26263. * | 0 | EXPLICIT_MODE | |
  26264. * | 1 | SPHERICAL_MODE | |
  26265. * | 2 | PLANAR_MODE | |
  26266. * | 3 | CUBIC_MODE | |
  26267. * | 4 | PROJECTION_MODE | |
  26268. * | 5 | SKYBOX_MODE | |
  26269. * | 6 | INVCUBIC_MODE | |
  26270. * | 7 | EQUIRECTANGULAR_MODE | |
  26271. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26272. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26273. */
  26274. coordinatesMode: number;
  26275. /**
  26276. * | Value | Type | Description |
  26277. * | ----- | ------------------ | ----------- |
  26278. * | 0 | CLAMP_ADDRESSMODE | |
  26279. * | 1 | WRAP_ADDRESSMODE | |
  26280. * | 2 | MIRROR_ADDRESSMODE | |
  26281. */
  26282. wrapU: number;
  26283. /**
  26284. * | Value | Type | Description |
  26285. * | ----- | ------------------ | ----------- |
  26286. * | 0 | CLAMP_ADDRESSMODE | |
  26287. * | 1 | WRAP_ADDRESSMODE | |
  26288. * | 2 | MIRROR_ADDRESSMODE | |
  26289. */
  26290. wrapV: number;
  26291. /**
  26292. * | Value | Type | Description |
  26293. * | ----- | ------------------ | ----------- |
  26294. * | 0 | CLAMP_ADDRESSMODE | |
  26295. * | 1 | WRAP_ADDRESSMODE | |
  26296. * | 2 | MIRROR_ADDRESSMODE | |
  26297. */
  26298. wrapR: number;
  26299. /**
  26300. * With compliant hardware and browser (supporting anisotropic filtering)
  26301. * this defines the level of anisotropic filtering in the texture.
  26302. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26303. */
  26304. anisotropicFilteringLevel: number;
  26305. /**
  26306. * Define if the texture is a cube texture or if false a 2d texture.
  26307. */
  26308. isCube: boolean;
  26309. /**
  26310. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26311. */
  26312. is3D: boolean;
  26313. /**
  26314. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26315. * HDR texture are usually stored in linear space.
  26316. * This only impacts the PBR and Background materials
  26317. */
  26318. gammaSpace: boolean;
  26319. /**
  26320. * Gets whether or not the texture contains RGBD data.
  26321. */
  26322. readonly isRGBD: boolean;
  26323. /**
  26324. * Is Z inverted in the texture (useful in a cube texture).
  26325. */
  26326. invertZ: boolean;
  26327. /**
  26328. * Are mip maps generated for this texture or not.
  26329. */
  26330. readonly noMipmap: boolean;
  26331. /**
  26332. * @hidden
  26333. */
  26334. lodLevelInAlpha: boolean;
  26335. /**
  26336. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26337. */
  26338. lodGenerationOffset: number;
  26339. /**
  26340. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26341. */
  26342. lodGenerationScale: number;
  26343. /**
  26344. * Define if the texture is a render target.
  26345. */
  26346. isRenderTarget: boolean;
  26347. /**
  26348. * Define the unique id of the texture in the scene.
  26349. */
  26350. readonly uid: string;
  26351. /**
  26352. * Return a string representation of the texture.
  26353. * @returns the texture as a string
  26354. */
  26355. toString(): string;
  26356. /**
  26357. * Get the class name of the texture.
  26358. * @returns "BaseTexture"
  26359. */
  26360. getClassName(): string;
  26361. /**
  26362. * Define the list of animation attached to the texture.
  26363. */
  26364. animations: import("babylonjs/Animations/animation").Animation[];
  26365. /**
  26366. * An event triggered when the texture is disposed.
  26367. */
  26368. onDisposeObservable: Observable<BaseTexture>;
  26369. private _onDisposeObserver;
  26370. /**
  26371. * Callback triggered when the texture has been disposed.
  26372. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26373. */
  26374. onDispose: () => void;
  26375. /**
  26376. * Define the current state of the loading sequence when in delayed load mode.
  26377. */
  26378. delayLoadState: number;
  26379. private _scene;
  26380. /** @hidden */
  26381. _texture: Nullable<InternalTexture>;
  26382. private _uid;
  26383. /**
  26384. * Define if the texture is preventinga material to render or not.
  26385. * If not and the texture is not ready, the engine will use a default black texture instead.
  26386. */
  26387. readonly isBlocking: boolean;
  26388. /**
  26389. * Instantiates a new BaseTexture.
  26390. * Base class of all the textures in babylon.
  26391. * It groups all the common properties the materials, post process, lights... might need
  26392. * in order to make a correct use of the texture.
  26393. * @param scene Define the scene the texture blongs to
  26394. */
  26395. constructor(scene: Nullable<Scene>);
  26396. /**
  26397. * Get the scene the texture belongs to.
  26398. * @returns the scene or null if undefined
  26399. */
  26400. getScene(): Nullable<Scene>;
  26401. /**
  26402. * Get the texture transform matrix used to offset tile the texture for istance.
  26403. * @returns the transformation matrix
  26404. */
  26405. getTextureMatrix(): Matrix;
  26406. /**
  26407. * Get the texture reflection matrix used to rotate/transform the reflection.
  26408. * @returns the reflection matrix
  26409. */
  26410. getReflectionTextureMatrix(): Matrix;
  26411. /**
  26412. * Get the underlying lower level texture from Babylon.
  26413. * @returns the insternal texture
  26414. */
  26415. getInternalTexture(): Nullable<InternalTexture>;
  26416. /**
  26417. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26418. * @returns true if ready or not blocking
  26419. */
  26420. isReadyOrNotBlocking(): boolean;
  26421. /**
  26422. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26423. * @returns true if fully ready
  26424. */
  26425. isReady(): boolean;
  26426. private _cachedSize;
  26427. /**
  26428. * Get the size of the texture.
  26429. * @returns the texture size.
  26430. */
  26431. getSize(): ISize;
  26432. /**
  26433. * Get the base size of the texture.
  26434. * It can be different from the size if the texture has been resized for POT for instance
  26435. * @returns the base size
  26436. */
  26437. getBaseSize(): ISize;
  26438. /**
  26439. * Update the sampling mode of the texture.
  26440. * Default is Trilinear mode.
  26441. *
  26442. * | Value | Type | Description |
  26443. * | ----- | ------------------ | ----------- |
  26444. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26445. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26446. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26447. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26448. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26449. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26450. * | 7 | NEAREST_LINEAR | |
  26451. * | 8 | NEAREST_NEAREST | |
  26452. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26453. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26454. * | 11 | LINEAR_LINEAR | |
  26455. * | 12 | LINEAR_NEAREST | |
  26456. *
  26457. * > _mag_: magnification filter (close to the viewer)
  26458. * > _min_: minification filter (far from the viewer)
  26459. * > _mip_: filter used between mip map levels
  26460. *@param samplingMode Define the new sampling mode of the texture
  26461. */
  26462. updateSamplingMode(samplingMode: number): void;
  26463. /**
  26464. * Scales the texture if is `canRescale()`
  26465. * @param ratio the resize factor we want to use to rescale
  26466. */
  26467. scale(ratio: number): void;
  26468. /**
  26469. * Get if the texture can rescale.
  26470. */
  26471. readonly canRescale: boolean;
  26472. /** @hidden */
  26473. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26474. /** @hidden */
  26475. _rebuild(): void;
  26476. /**
  26477. * Triggers the load sequence in delayed load mode.
  26478. */
  26479. delayLoad(): void;
  26480. /**
  26481. * Clones the texture.
  26482. * @returns the cloned texture
  26483. */
  26484. clone(): Nullable<BaseTexture>;
  26485. /**
  26486. * Get the texture underlying type (INT, FLOAT...)
  26487. */
  26488. readonly textureType: number;
  26489. /**
  26490. * Get the texture underlying format (RGB, RGBA...)
  26491. */
  26492. readonly textureFormat: number;
  26493. /**
  26494. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26495. * This will returns an RGBA array buffer containing either in values (0-255) or
  26496. * float values (0-1) depending of the underlying buffer type.
  26497. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26498. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26499. * @param buffer defines a user defined buffer to fill with data (can be null)
  26500. * @returns The Array buffer containing the pixels data.
  26501. */
  26502. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26503. /**
  26504. * Release and destroy the underlying lower level texture aka internalTexture.
  26505. */
  26506. releaseInternalTexture(): void;
  26507. /**
  26508. * Get the polynomial representation of the texture data.
  26509. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26510. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26511. */
  26512. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26513. /** @hidden */
  26514. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26515. /** @hidden */
  26516. readonly _lodTextureMid: Nullable<BaseTexture>;
  26517. /** @hidden */
  26518. readonly _lodTextureLow: Nullable<BaseTexture>;
  26519. /**
  26520. * Dispose the texture and release its associated resources.
  26521. */
  26522. dispose(): void;
  26523. /**
  26524. * Serialize the texture into a JSON representation that can be parsed later on.
  26525. * @returns the JSON representation of the texture
  26526. */
  26527. serialize(): any;
  26528. /**
  26529. * Helper function to be called back once a list of texture contains only ready textures.
  26530. * @param textures Define the list of textures to wait for
  26531. * @param callback Define the callback triggered once the entire list will be ready
  26532. */
  26533. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26534. }
  26535. }
  26536. declare module "babylonjs/Materials/uniformBuffer" {
  26537. import { Nullable, FloatArray } from "babylonjs/types";
  26538. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  26539. import { Engine } from "babylonjs/Engines/engine";
  26540. import { Effect } from "babylonjs/Materials/effect";
  26541. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26542. /**
  26543. * Uniform buffer objects.
  26544. *
  26545. * Handles blocks of uniform on the GPU.
  26546. *
  26547. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26548. *
  26549. * For more information, please refer to :
  26550. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26551. */
  26552. export class UniformBuffer {
  26553. private _engine;
  26554. private _buffer;
  26555. private _data;
  26556. private _bufferData;
  26557. private _dynamic?;
  26558. private _uniformLocations;
  26559. private _uniformSizes;
  26560. private _uniformLocationPointer;
  26561. private _needSync;
  26562. private _noUBO;
  26563. private _currentEffect;
  26564. private static _MAX_UNIFORM_SIZE;
  26565. private static _tempBuffer;
  26566. /**
  26567. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  26568. * This is dynamic to allow compat with webgl 1 and 2.
  26569. * You will need to pass the name of the uniform as well as the value.
  26570. */
  26571. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  26572. /**
  26573. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  26574. * This is dynamic to allow compat with webgl 1 and 2.
  26575. * You will need to pass the name of the uniform as well as the value.
  26576. */
  26577. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  26578. /**
  26579. * Lambda to Update a single float in a uniform buffer.
  26580. * This is dynamic to allow compat with webgl 1 and 2.
  26581. * You will need to pass the name of the uniform as well as the value.
  26582. */
  26583. updateFloat: (name: string, x: number) => void;
  26584. /**
  26585. * Lambda to Update a vec2 of float in a uniform buffer.
  26586. * This is dynamic to allow compat with webgl 1 and 2.
  26587. * You will need to pass the name of the uniform as well as the value.
  26588. */
  26589. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  26590. /**
  26591. * Lambda to Update a vec3 of float in a uniform buffer.
  26592. * This is dynamic to allow compat with webgl 1 and 2.
  26593. * You will need to pass the name of the uniform as well as the value.
  26594. */
  26595. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  26596. /**
  26597. * Lambda to Update a vec4 of float in a uniform buffer.
  26598. * This is dynamic to allow compat with webgl 1 and 2.
  26599. * You will need to pass the name of the uniform as well as the value.
  26600. */
  26601. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  26602. /**
  26603. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  26604. * This is dynamic to allow compat with webgl 1 and 2.
  26605. * You will need to pass the name of the uniform as well as the value.
  26606. */
  26607. updateMatrix: (name: string, mat: Matrix) => void;
  26608. /**
  26609. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  26610. * This is dynamic to allow compat with webgl 1 and 2.
  26611. * You will need to pass the name of the uniform as well as the value.
  26612. */
  26613. updateVector3: (name: string, vector: Vector3) => void;
  26614. /**
  26615. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  26616. * This is dynamic to allow compat with webgl 1 and 2.
  26617. * You will need to pass the name of the uniform as well as the value.
  26618. */
  26619. updateVector4: (name: string, vector: Vector4) => void;
  26620. /**
  26621. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  26622. * This is dynamic to allow compat with webgl 1 and 2.
  26623. * You will need to pass the name of the uniform as well as the value.
  26624. */
  26625. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  26626. /**
  26627. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  26628. * This is dynamic to allow compat with webgl 1 and 2.
  26629. * You will need to pass the name of the uniform as well as the value.
  26630. */
  26631. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  26632. /**
  26633. * Instantiates a new Uniform buffer objects.
  26634. *
  26635. * Handles blocks of uniform on the GPU.
  26636. *
  26637. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26638. *
  26639. * For more information, please refer to :
  26640. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26641. * @param engine Define the engine the buffer is associated with
  26642. * @param data Define the data contained in the buffer
  26643. * @param dynamic Define if the buffer is updatable
  26644. */
  26645. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  26646. /**
  26647. * Indicates if the buffer is using the WebGL2 UBO implementation,
  26648. * or just falling back on setUniformXXX calls.
  26649. */
  26650. readonly useUbo: boolean;
  26651. /**
  26652. * Indicates if the WebGL underlying uniform buffer is in sync
  26653. * with the javascript cache data.
  26654. */
  26655. readonly isSync: boolean;
  26656. /**
  26657. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26658. * Also, a dynamic UniformBuffer will disable cache verification and always
  26659. * update the underlying WebGL uniform buffer to the GPU.
  26660. * @returns if Dynamic, otherwise false
  26661. */
  26662. isDynamic(): boolean;
  26663. /**
  26664. * The data cache on JS side.
  26665. * @returns the underlying data as a float array
  26666. */
  26667. getData(): Float32Array;
  26668. /**
  26669. * The underlying WebGL Uniform buffer.
  26670. * @returns the webgl buffer
  26671. */
  26672. getBuffer(): Nullable<WebGLBuffer>;
  26673. /**
  26674. * std140 layout specifies how to align data within an UBO structure.
  26675. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26676. * for specs.
  26677. */
  26678. private _fillAlignment;
  26679. /**
  26680. * Adds an uniform in the buffer.
  26681. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26682. * for the layout to be correct !
  26683. * @param name Name of the uniform, as used in the uniform block in the shader.
  26684. * @param size Data size, or data directly.
  26685. */
  26686. addUniform(name: string, size: number | number[]): void;
  26687. /**
  26688. * Adds a Matrix 4x4 to the uniform buffer.
  26689. * @param name Name of the uniform, as used in the uniform block in the shader.
  26690. * @param mat A 4x4 matrix.
  26691. */
  26692. addMatrix(name: string, mat: Matrix): void;
  26693. /**
  26694. * Adds a vec2 to the uniform buffer.
  26695. * @param name Name of the uniform, as used in the uniform block in the shader.
  26696. * @param x Define the x component value of the vec2
  26697. * @param y Define the y component value of the vec2
  26698. */
  26699. addFloat2(name: string, x: number, y: number): void;
  26700. /**
  26701. * Adds a vec3 to the uniform buffer.
  26702. * @param name Name of the uniform, as used in the uniform block in the shader.
  26703. * @param x Define the x component value of the vec3
  26704. * @param y Define the y component value of the vec3
  26705. * @param z Define the z component value of the vec3
  26706. */
  26707. addFloat3(name: string, x: number, y: number, z: number): void;
  26708. /**
  26709. * Adds a vec3 to the uniform buffer.
  26710. * @param name Name of the uniform, as used in the uniform block in the shader.
  26711. * @param color Define the vec3 from a Color
  26712. */
  26713. addColor3(name: string, color: Color3): void;
  26714. /**
  26715. * Adds a vec4 to the uniform buffer.
  26716. * @param name Name of the uniform, as used in the uniform block in the shader.
  26717. * @param color Define the rgb components from a Color
  26718. * @param alpha Define the a component of the vec4
  26719. */
  26720. addColor4(name: string, color: Color3, alpha: number): void;
  26721. /**
  26722. * Adds a vec3 to the uniform buffer.
  26723. * @param name Name of the uniform, as used in the uniform block in the shader.
  26724. * @param vector Define the vec3 components from a Vector
  26725. */
  26726. addVector3(name: string, vector: Vector3): void;
  26727. /**
  26728. * Adds a Matrix 3x3 to the uniform buffer.
  26729. * @param name Name of the uniform, as used in the uniform block in the shader.
  26730. */
  26731. addMatrix3x3(name: string): void;
  26732. /**
  26733. * Adds a Matrix 2x2 to the uniform buffer.
  26734. * @param name Name of the uniform, as used in the uniform block in the shader.
  26735. */
  26736. addMatrix2x2(name: string): void;
  26737. /**
  26738. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26739. */
  26740. create(): void;
  26741. /** @hidden */
  26742. _rebuild(): void;
  26743. /**
  26744. * Updates the WebGL Uniform Buffer on the GPU.
  26745. * If the `dynamic` flag is set to true, no cache comparison is done.
  26746. * Otherwise, the buffer will be updated only if the cache differs.
  26747. */
  26748. update(): void;
  26749. /**
  26750. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26751. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26752. * @param data Define the flattened data
  26753. * @param size Define the size of the data.
  26754. */
  26755. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26756. private _updateMatrix3x3ForUniform;
  26757. private _updateMatrix3x3ForEffect;
  26758. private _updateMatrix2x2ForEffect;
  26759. private _updateMatrix2x2ForUniform;
  26760. private _updateFloatForEffect;
  26761. private _updateFloatForUniform;
  26762. private _updateFloat2ForEffect;
  26763. private _updateFloat2ForUniform;
  26764. private _updateFloat3ForEffect;
  26765. private _updateFloat3ForUniform;
  26766. private _updateFloat4ForEffect;
  26767. private _updateFloat4ForUniform;
  26768. private _updateMatrixForEffect;
  26769. private _updateMatrixForUniform;
  26770. private _updateVector3ForEffect;
  26771. private _updateVector3ForUniform;
  26772. private _updateVector4ForEffect;
  26773. private _updateVector4ForUniform;
  26774. private _updateColor3ForEffect;
  26775. private _updateColor3ForUniform;
  26776. private _updateColor4ForEffect;
  26777. private _updateColor4ForUniform;
  26778. /**
  26779. * Sets a sampler uniform on the effect.
  26780. * @param name Define the name of the sampler.
  26781. * @param texture Define the texture to set in the sampler
  26782. */
  26783. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26784. /**
  26785. * Directly updates the value of the uniform in the cache AND on the GPU.
  26786. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26787. * @param data Define the flattened data
  26788. */
  26789. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26790. /**
  26791. * Binds this uniform buffer to an effect.
  26792. * @param effect Define the effect to bind the buffer to
  26793. * @param name Name of the uniform block in the shader.
  26794. */
  26795. bindToEffect(effect: Effect, name: string): void;
  26796. /**
  26797. * Disposes the uniform buffer.
  26798. */
  26799. dispose(): void;
  26800. }
  26801. }
  26802. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  26803. import { Nullable } from "babylonjs/types";
  26804. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26805. /**
  26806. * This represents the required contract to create a new type of texture loader.
  26807. */
  26808. export interface IInternalTextureLoader {
  26809. /**
  26810. * Defines wether the loader supports cascade loading the different faces.
  26811. */
  26812. supportCascades: boolean;
  26813. /**
  26814. * This returns if the loader support the current file information.
  26815. * @param extension defines the file extension of the file being loaded
  26816. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26817. * @param fallback defines the fallback internal texture if any
  26818. * @param isBase64 defines whether the texture is encoded as a base64
  26819. * @param isBuffer defines whether the texture data are stored as a buffer
  26820. * @returns true if the loader can load the specified file
  26821. */
  26822. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  26823. /**
  26824. * Transform the url before loading if required.
  26825. * @param rootUrl the url of the texture
  26826. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26827. * @returns the transformed texture
  26828. */
  26829. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  26830. /**
  26831. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  26832. * @param rootUrl the url of the texture
  26833. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26834. * @returns the fallback texture
  26835. */
  26836. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  26837. /**
  26838. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  26839. * @param data contains the texture data
  26840. * @param texture defines the BabylonJS internal texture
  26841. * @param createPolynomials will be true if polynomials have been requested
  26842. * @param onLoad defines the callback to trigger once the texture is ready
  26843. * @param onError defines the callback to trigger in case of error
  26844. */
  26845. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  26846. /**
  26847. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  26848. * @param data contains the texture data
  26849. * @param texture defines the BabylonJS internal texture
  26850. * @param callback defines the method to call once ready to upload
  26851. */
  26852. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  26853. }
  26854. }
  26855. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  26856. import { Scene } from "babylonjs/scene";
  26857. import { Engine } from "babylonjs/Engines/engine";
  26858. import { Texture } from "babylonjs/Materials/Textures/texture";
  26859. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26860. /**
  26861. * Creation options of the multi render target texture.
  26862. */
  26863. export interface IMultiRenderTargetOptions {
  26864. /**
  26865. * Define if the texture needs to create mip maps after render.
  26866. */
  26867. generateMipMaps?: boolean;
  26868. /**
  26869. * Define the types of all the draw buffers we want to create
  26870. */
  26871. types?: number[];
  26872. /**
  26873. * Define the sampling modes of all the draw buffers we want to create
  26874. */
  26875. samplingModes?: number[];
  26876. /**
  26877. * Define if a depth buffer is required
  26878. */
  26879. generateDepthBuffer?: boolean;
  26880. /**
  26881. * Define if a stencil buffer is required
  26882. */
  26883. generateStencilBuffer?: boolean;
  26884. /**
  26885. * Define if a depth texture is required instead of a depth buffer
  26886. */
  26887. generateDepthTexture?: boolean;
  26888. /**
  26889. * Define the number of desired draw buffers
  26890. */
  26891. textureCount?: number;
  26892. /**
  26893. * Define if aspect ratio should be adapted to the texture or stay the scene one
  26894. */
  26895. doNotChangeAspectRatio?: boolean;
  26896. /**
  26897. * Define the default type of the buffers we are creating
  26898. */
  26899. defaultType?: number;
  26900. }
  26901. /**
  26902. * A multi render target, like a render target provides the ability to render to a texture.
  26903. * Unlike the render target, it can render to several draw buffers in one draw.
  26904. * This is specially interesting in deferred rendering or for any effects requiring more than
  26905. * just one color from a single pass.
  26906. */
  26907. export class MultiRenderTarget extends RenderTargetTexture {
  26908. private _internalTextures;
  26909. private _textures;
  26910. private _multiRenderTargetOptions;
  26911. /**
  26912. * Get if draw buffers are currently supported by the used hardware and browser.
  26913. */
  26914. readonly isSupported: boolean;
  26915. /**
  26916. * Get the list of textures generated by the multi render target.
  26917. */
  26918. readonly textures: Texture[];
  26919. /**
  26920. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  26921. */
  26922. readonly depthTexture: Texture;
  26923. /**
  26924. * Set the wrapping mode on U of all the textures we are rendering to.
  26925. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26926. */
  26927. wrapU: number;
  26928. /**
  26929. * Set the wrapping mode on V of all the textures we are rendering to.
  26930. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26931. */
  26932. wrapV: number;
  26933. /**
  26934. * Instantiate a new multi render target texture.
  26935. * A multi render target, like a render target provides the ability to render to a texture.
  26936. * Unlike the render target, it can render to several draw buffers in one draw.
  26937. * This is specially interesting in deferred rendering or for any effects requiring more than
  26938. * just one color from a single pass.
  26939. * @param name Define the name of the texture
  26940. * @param size Define the size of the buffers to render to
  26941. * @param count Define the number of target we are rendering into
  26942. * @param scene Define the scene the texture belongs to
  26943. * @param options Define the options used to create the multi render target
  26944. */
  26945. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  26946. /** @hidden */
  26947. _rebuild(): void;
  26948. private _createInternalTextures;
  26949. private _createTextures;
  26950. /**
  26951. * Define the number of samples used if MSAA is enabled.
  26952. */
  26953. samples: number;
  26954. /**
  26955. * Resize all the textures in the multi render target.
  26956. * Be carrefull as it will recreate all the data in the new texture.
  26957. * @param size Define the new size
  26958. */
  26959. resize(size: any): void;
  26960. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26961. /**
  26962. * Dispose the render targets and their associated resources
  26963. */
  26964. dispose(): void;
  26965. /**
  26966. * Release all the underlying texture used as draw buffers.
  26967. */
  26968. releaseInternalTextures(): void;
  26969. }
  26970. }
  26971. declare module "babylonjs/Audio/analyser" {
  26972. import { Scene } from "babylonjs/scene";
  26973. /**
  26974. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26975. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26976. */
  26977. export class Analyser {
  26978. /**
  26979. * Gets or sets the smoothing
  26980. * @ignorenaming
  26981. */
  26982. SMOOTHING: number;
  26983. /**
  26984. * Gets or sets the FFT table size
  26985. * @ignorenaming
  26986. */
  26987. FFT_SIZE: number;
  26988. /**
  26989. * Gets or sets the bar graph amplitude
  26990. * @ignorenaming
  26991. */
  26992. BARGRAPHAMPLITUDE: number;
  26993. /**
  26994. * Gets or sets the position of the debug canvas
  26995. * @ignorenaming
  26996. */
  26997. DEBUGCANVASPOS: {
  26998. x: number;
  26999. y: number;
  27000. };
  27001. /**
  27002. * Gets or sets the debug canvas size
  27003. * @ignorenaming
  27004. */
  27005. DEBUGCANVASSIZE: {
  27006. width: number;
  27007. height: number;
  27008. };
  27009. private _byteFreqs;
  27010. private _byteTime;
  27011. private _floatFreqs;
  27012. private _webAudioAnalyser;
  27013. private _debugCanvas;
  27014. private _debugCanvasContext;
  27015. private _scene;
  27016. private _registerFunc;
  27017. private _audioEngine;
  27018. /**
  27019. * Creates a new analyser
  27020. * @param scene defines hosting scene
  27021. */
  27022. constructor(scene: Scene);
  27023. /**
  27024. * Get the number of data values you will have to play with for the visualization
  27025. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  27026. * @returns a number
  27027. */
  27028. getFrequencyBinCount(): number;
  27029. /**
  27030. * Gets the current frequency data as a byte array
  27031. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27032. * @returns a Uint8Array
  27033. */
  27034. getByteFrequencyData(): Uint8Array;
  27035. /**
  27036. * Gets the current waveform as a byte array
  27037. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  27038. * @returns a Uint8Array
  27039. */
  27040. getByteTimeDomainData(): Uint8Array;
  27041. /**
  27042. * Gets the current frequency data as a float array
  27043. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27044. * @returns a Float32Array
  27045. */
  27046. getFloatFrequencyData(): Float32Array;
  27047. /**
  27048. * Renders the debug canvas
  27049. */
  27050. drawDebugCanvas(): void;
  27051. /**
  27052. * Stops rendering the debug canvas and removes it
  27053. */
  27054. stopDebugCanvas(): void;
  27055. /**
  27056. * Connects two audio nodes
  27057. * @param inputAudioNode defines first node to connect
  27058. * @param outputAudioNode defines second node to connect
  27059. */
  27060. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  27061. /**
  27062. * Releases all associated resources
  27063. */
  27064. dispose(): void;
  27065. }
  27066. }
  27067. declare module "babylonjs/Audio/audioEngine" {
  27068. import { IDisposable } from "babylonjs/scene";
  27069. import { Analyser } from "babylonjs/Audio/analyser";
  27070. import { Nullable } from "babylonjs/types";
  27071. import { Observable } from "babylonjs/Misc/observable";
  27072. /**
  27073. * This represents an audio engine and it is responsible
  27074. * to play, synchronize and analyse sounds throughout the application.
  27075. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27076. */
  27077. export interface IAudioEngine extends IDisposable {
  27078. /**
  27079. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27080. */
  27081. readonly canUseWebAudio: boolean;
  27082. /**
  27083. * Gets the current AudioContext if available.
  27084. */
  27085. readonly audioContext: Nullable<AudioContext>;
  27086. /**
  27087. * The master gain node defines the global audio volume of your audio engine.
  27088. */
  27089. readonly masterGain: GainNode;
  27090. /**
  27091. * Gets whether or not mp3 are supported by your browser.
  27092. */
  27093. readonly isMP3supported: boolean;
  27094. /**
  27095. * Gets whether or not ogg are supported by your browser.
  27096. */
  27097. readonly isOGGsupported: boolean;
  27098. /**
  27099. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27100. * @ignoreNaming
  27101. */
  27102. WarnedWebAudioUnsupported: boolean;
  27103. /**
  27104. * Defines if the audio engine relies on a custom unlocked button.
  27105. * In this case, the embedded button will not be displayed.
  27106. */
  27107. useCustomUnlockedButton: boolean;
  27108. /**
  27109. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  27110. */
  27111. readonly unlocked: boolean;
  27112. /**
  27113. * Event raised when audio has been unlocked on the browser.
  27114. */
  27115. onAudioUnlockedObservable: Observable<AudioEngine>;
  27116. /**
  27117. * Event raised when audio has been locked on the browser.
  27118. */
  27119. onAudioLockedObservable: Observable<AudioEngine>;
  27120. /**
  27121. * Flags the audio engine in Locked state.
  27122. * This happens due to new browser policies preventing audio to autoplay.
  27123. */
  27124. lock(): void;
  27125. /**
  27126. * Unlocks the audio engine once a user action has been done on the dom.
  27127. * This is helpful to resume play once browser policies have been satisfied.
  27128. */
  27129. unlock(): void;
  27130. }
  27131. /**
  27132. * This represents the default audio engine used in babylon.
  27133. * It is responsible to play, synchronize and analyse sounds throughout the application.
  27134. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27135. */
  27136. export class AudioEngine implements IAudioEngine {
  27137. private _audioContext;
  27138. private _audioContextInitialized;
  27139. private _muteButton;
  27140. private _hostElement;
  27141. /**
  27142. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27143. */
  27144. canUseWebAudio: boolean;
  27145. /**
  27146. * The master gain node defines the global audio volume of your audio engine.
  27147. */
  27148. masterGain: GainNode;
  27149. /**
  27150. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27151. * @ignoreNaming
  27152. */
  27153. WarnedWebAudioUnsupported: boolean;
  27154. /**
  27155. * Gets whether or not mp3 are supported by your browser.
  27156. */
  27157. isMP3supported: boolean;
  27158. /**
  27159. * Gets whether or not ogg are supported by your browser.
  27160. */
  27161. isOGGsupported: boolean;
  27162. /**
  27163. * Gets whether audio has been unlocked on the device.
  27164. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27165. * a user interaction has happened.
  27166. */
  27167. unlocked: boolean;
  27168. /**
  27169. * Defines if the audio engine relies on a custom unlocked button.
  27170. * In this case, the embedded button will not be displayed.
  27171. */
  27172. useCustomUnlockedButton: boolean;
  27173. /**
  27174. * Event raised when audio has been unlocked on the browser.
  27175. */
  27176. onAudioUnlockedObservable: Observable<AudioEngine>;
  27177. /**
  27178. * Event raised when audio has been locked on the browser.
  27179. */
  27180. onAudioLockedObservable: Observable<AudioEngine>;
  27181. /**
  27182. * Gets the current AudioContext if available.
  27183. */
  27184. readonly audioContext: Nullable<AudioContext>;
  27185. private _connectedAnalyser;
  27186. /**
  27187. * Instantiates a new audio engine.
  27188. *
  27189. * There should be only one per page as some browsers restrict the number
  27190. * of audio contexts you can create.
  27191. * @param hostElement defines the host element where to display the mute icon if necessary
  27192. */
  27193. constructor(hostElement?: Nullable<HTMLElement>);
  27194. /**
  27195. * Flags the audio engine in Locked state.
  27196. * This happens due to new browser policies preventing audio to autoplay.
  27197. */
  27198. lock(): void;
  27199. /**
  27200. * Unlocks the audio engine once a user action has been done on the dom.
  27201. * This is helpful to resume play once browser policies have been satisfied.
  27202. */
  27203. unlock(): void;
  27204. private _resumeAudioContext;
  27205. private _initializeAudioContext;
  27206. private _tryToRun;
  27207. private _triggerRunningState;
  27208. private _triggerSuspendedState;
  27209. private _displayMuteButton;
  27210. private _moveButtonToTopLeft;
  27211. private _onResize;
  27212. private _hideMuteButton;
  27213. /**
  27214. * Destroy and release the resources associated with the audio ccontext.
  27215. */
  27216. dispose(): void;
  27217. /**
  27218. * Gets the global volume sets on the master gain.
  27219. * @returns the global volume if set or -1 otherwise
  27220. */
  27221. getGlobalVolume(): number;
  27222. /**
  27223. * Sets the global volume of your experience (sets on the master gain).
  27224. * @param newVolume Defines the new global volume of the application
  27225. */
  27226. setGlobalVolume(newVolume: number): void;
  27227. /**
  27228. * Connect the audio engine to an audio analyser allowing some amazing
  27229. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27230. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27231. * @param analyser The analyser to connect to the engine
  27232. */
  27233. connectToAnalyser(analyser: Analyser): void;
  27234. }
  27235. }
  27236. declare module "babylonjs/Loading/loadingScreen" {
  27237. /**
  27238. * Interface used to present a loading screen while loading a scene
  27239. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27240. */
  27241. export interface ILoadingScreen {
  27242. /**
  27243. * Function called to display the loading screen
  27244. */
  27245. displayLoadingUI: () => void;
  27246. /**
  27247. * Function called to hide the loading screen
  27248. */
  27249. hideLoadingUI: () => void;
  27250. /**
  27251. * Gets or sets the color to use for the background
  27252. */
  27253. loadingUIBackgroundColor: string;
  27254. /**
  27255. * Gets or sets the text to display while loading
  27256. */
  27257. loadingUIText: string;
  27258. }
  27259. /**
  27260. * Class used for the default loading screen
  27261. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27262. */
  27263. export class DefaultLoadingScreen implements ILoadingScreen {
  27264. private _renderingCanvas;
  27265. private _loadingText;
  27266. private _loadingDivBackgroundColor;
  27267. private _loadingDiv;
  27268. private _loadingTextDiv;
  27269. /**
  27270. * Creates a new default loading screen
  27271. * @param _renderingCanvas defines the canvas used to render the scene
  27272. * @param _loadingText defines the default text to display
  27273. * @param _loadingDivBackgroundColor defines the default background color
  27274. */
  27275. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27276. /**
  27277. * Function called to display the loading screen
  27278. */
  27279. displayLoadingUI(): void;
  27280. /**
  27281. * Function called to hide the loading screen
  27282. */
  27283. hideLoadingUI(): void;
  27284. /**
  27285. * Gets or sets the text to display while loading
  27286. */
  27287. loadingUIText: string;
  27288. /**
  27289. * Gets or sets the color to use for the background
  27290. */
  27291. loadingUIBackgroundColor: string;
  27292. private _resizeLoadingUI;
  27293. }
  27294. }
  27295. declare module "babylonjs/Materials/Textures/videoTexture" {
  27296. import { Observable } from "babylonjs/Misc/observable";
  27297. import { Nullable } from "babylonjs/types";
  27298. import { Scene } from "babylonjs/scene";
  27299. import { Texture } from "babylonjs/Materials/Textures/texture";
  27300. /**
  27301. * Settings for finer control over video usage
  27302. */
  27303. export interface VideoTextureSettings {
  27304. /**
  27305. * Applies `autoplay` to video, if specified
  27306. */
  27307. autoPlay?: boolean;
  27308. /**
  27309. * Applies `loop` to video, if specified
  27310. */
  27311. loop?: boolean;
  27312. /**
  27313. * Automatically updates internal texture from video at every frame in the render loop
  27314. */
  27315. autoUpdateTexture: boolean;
  27316. /**
  27317. * Image src displayed during the video loading or until the user interacts with the video.
  27318. */
  27319. poster?: string;
  27320. }
  27321. /**
  27322. * If you want to display a video in your scene, this is the special texture for that.
  27323. * This special texture works similar to other textures, with the exception of a few parameters.
  27324. * @see https://doc.babylonjs.com/how_to/video_texture
  27325. */
  27326. export class VideoTexture extends Texture {
  27327. /**
  27328. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27329. */
  27330. readonly autoUpdateTexture: boolean;
  27331. /**
  27332. * The video instance used by the texture internally
  27333. */
  27334. readonly video: HTMLVideoElement;
  27335. private _onUserActionRequestedObservable;
  27336. /**
  27337. * Event triggerd when a dom action is required by the user to play the video.
  27338. * This happens due to recent changes in browser policies preventing video to auto start.
  27339. */
  27340. readonly onUserActionRequestedObservable: Observable<Texture>;
  27341. private _generateMipMaps;
  27342. private _engine;
  27343. private _stillImageCaptured;
  27344. private _displayingPosterTexture;
  27345. private _settings;
  27346. private _createInternalTextureOnEvent;
  27347. /**
  27348. * Creates a video texture.
  27349. * If you want to display a video in your scene, this is the special texture for that.
  27350. * This special texture works similar to other textures, with the exception of a few parameters.
  27351. * @see https://doc.babylonjs.com/how_to/video_texture
  27352. * @param name optional name, will detect from video source, if not defined
  27353. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27354. * @param scene is obviously the current scene.
  27355. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27356. * @param invertY is false by default but can be used to invert video on Y axis
  27357. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27358. * @param settings allows finer control over video usage
  27359. */
  27360. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27361. private _getName;
  27362. private _getVideo;
  27363. private _createInternalTexture;
  27364. private reset;
  27365. /**
  27366. * @hidden Internal method to initiate `update`.
  27367. */
  27368. _rebuild(): void;
  27369. /**
  27370. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27371. */
  27372. update(): void;
  27373. /**
  27374. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27375. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27376. */
  27377. updateTexture(isVisible: boolean): void;
  27378. protected _updateInternalTexture: () => void;
  27379. /**
  27380. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27381. * @param url New url.
  27382. */
  27383. updateURL(url: string): void;
  27384. /**
  27385. * Dispose the texture and release its associated resources.
  27386. */
  27387. dispose(): void;
  27388. /**
  27389. * Creates a video texture straight from a stream.
  27390. * @param scene Define the scene the texture should be created in
  27391. * @param stream Define the stream the texture should be created from
  27392. * @returns The created video texture as a promise
  27393. */
  27394. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  27395. /**
  27396. * Creates a video texture straight from your WebCam video feed.
  27397. * @param scene Define the scene the texture should be created in
  27398. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27399. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27400. * @returns The created video texture as a promise
  27401. */
  27402. static CreateFromWebCamAsync(scene: Scene, constraints: {
  27403. minWidth: number;
  27404. maxWidth: number;
  27405. minHeight: number;
  27406. maxHeight: number;
  27407. deviceId: string;
  27408. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  27409. /**
  27410. * Creates a video texture straight from your WebCam video feed.
  27411. * @param scene Define the scene the texture should be created in
  27412. * @param onReady Define a callback to triggered once the texture will be ready
  27413. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27414. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27415. */
  27416. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27417. minWidth: number;
  27418. maxWidth: number;
  27419. minHeight: number;
  27420. maxHeight: number;
  27421. deviceId: string;
  27422. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27423. }
  27424. }
  27425. declare module "babylonjs/Engines/engine" {
  27426. import { Observable } from "babylonjs/Misc/observable";
  27427. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  27428. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  27429. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  27430. import { Camera } from "babylonjs/Cameras/camera";
  27431. import { Scene } from "babylonjs/scene";
  27432. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  27433. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  27434. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  27435. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  27436. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  27437. import { Material } from "babylonjs/Materials/material";
  27438. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  27439. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  27440. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27441. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  27442. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  27443. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  27444. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  27445. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  27446. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  27447. import { WebRequest } from "babylonjs/Misc/webRequest";
  27448. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  27449. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27450. /**
  27451. * Interface for attribute information associated with buffer instanciation
  27452. */
  27453. export class InstancingAttributeInfo {
  27454. /**
  27455. * Index/offset of the attribute in the vertex shader
  27456. */
  27457. index: number;
  27458. /**
  27459. * size of the attribute, 1, 2, 3 or 4
  27460. */
  27461. attributeSize: number;
  27462. /**
  27463. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27464. * default is FLOAT
  27465. */
  27466. attribyteType: number;
  27467. /**
  27468. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27469. */
  27470. normalized: boolean;
  27471. /**
  27472. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27473. */
  27474. offset: number;
  27475. /**
  27476. * Name of the GLSL attribute, for debugging purpose only
  27477. */
  27478. attributeName: string;
  27479. }
  27480. /**
  27481. * Define options used to create a depth texture
  27482. */
  27483. export class DepthTextureCreationOptions {
  27484. /** Specifies whether or not a stencil should be allocated in the texture */
  27485. generateStencil?: boolean;
  27486. /** Specifies whether or not bilinear filtering is enable on the texture */
  27487. bilinearFiltering?: boolean;
  27488. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27489. comparisonFunction?: number;
  27490. /** Specifies if the created texture is a cube texture */
  27491. isCube?: boolean;
  27492. }
  27493. /**
  27494. * Class used to describe the capabilities of the engine relatively to the current browser
  27495. */
  27496. export class EngineCapabilities {
  27497. /** Maximum textures units per fragment shader */
  27498. maxTexturesImageUnits: number;
  27499. /** Maximum texture units per vertex shader */
  27500. maxVertexTextureImageUnits: number;
  27501. /** Maximum textures units in the entire pipeline */
  27502. maxCombinedTexturesImageUnits: number;
  27503. /** Maximum texture size */
  27504. maxTextureSize: number;
  27505. /** Maximum cube texture size */
  27506. maxCubemapTextureSize: number;
  27507. /** Maximum render texture size */
  27508. maxRenderTextureSize: number;
  27509. /** Maximum number of vertex attributes */
  27510. maxVertexAttribs: number;
  27511. /** Maximum number of varyings */
  27512. maxVaryingVectors: number;
  27513. /** Maximum number of uniforms per vertex shader */
  27514. maxVertexUniformVectors: number;
  27515. /** Maximum number of uniforms per fragment shader */
  27516. maxFragmentUniformVectors: number;
  27517. /** Defines if standard derivates (dx/dy) are supported */
  27518. standardDerivatives: boolean;
  27519. /** Defines if s3tc texture compression is supported */
  27520. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27521. /** Defines if pvrtc texture compression is supported */
  27522. pvrtc: any;
  27523. /** Defines if etc1 texture compression is supported */
  27524. etc1: any;
  27525. /** Defines if etc2 texture compression is supported */
  27526. etc2: any;
  27527. /** Defines if astc texture compression is supported */
  27528. astc: any;
  27529. /** Defines if float textures are supported */
  27530. textureFloat: boolean;
  27531. /** Defines if vertex array objects are supported */
  27532. vertexArrayObject: boolean;
  27533. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27534. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27535. /** Gets the maximum level of anisotropy supported */
  27536. maxAnisotropy: number;
  27537. /** Defines if instancing is supported */
  27538. instancedArrays: boolean;
  27539. /** Defines if 32 bits indices are supported */
  27540. uintIndices: boolean;
  27541. /** Defines if high precision shaders are supported */
  27542. highPrecisionShaderSupported: boolean;
  27543. /** Defines if depth reading in the fragment shader is supported */
  27544. fragmentDepthSupported: boolean;
  27545. /** Defines if float texture linear filtering is supported*/
  27546. textureFloatLinearFiltering: boolean;
  27547. /** Defines if rendering to float textures is supported */
  27548. textureFloatRender: boolean;
  27549. /** Defines if half float textures are supported*/
  27550. textureHalfFloat: boolean;
  27551. /** Defines if half float texture linear filtering is supported*/
  27552. textureHalfFloatLinearFiltering: boolean;
  27553. /** Defines if rendering to half float textures is supported */
  27554. textureHalfFloatRender: boolean;
  27555. /** Defines if textureLOD shader command is supported */
  27556. textureLOD: boolean;
  27557. /** Defines if draw buffers extension is supported */
  27558. drawBuffersExtension: boolean;
  27559. /** Defines if depth textures are supported */
  27560. depthTextureExtension: boolean;
  27561. /** Defines if float color buffer are supported */
  27562. colorBufferFloat: boolean;
  27563. /** Gets disjoint timer query extension (null if not supported) */
  27564. timerQuery: EXT_disjoint_timer_query;
  27565. /** Defines if timestamp can be used with timer query */
  27566. canUseTimestampForTimerQuery: boolean;
  27567. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  27568. multiview: any;
  27569. /** Function used to let the system compiles shaders in background */
  27570. parallelShaderCompile: {
  27571. COMPLETION_STATUS_KHR: number;
  27572. };
  27573. }
  27574. /** Interface defining initialization parameters for Engine class */
  27575. export interface EngineOptions extends WebGLContextAttributes {
  27576. /**
  27577. * Defines if the engine should no exceed a specified device ratio
  27578. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27579. */
  27580. limitDeviceRatio?: number;
  27581. /**
  27582. * Defines if webvr should be enabled automatically
  27583. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27584. */
  27585. autoEnableWebVR?: boolean;
  27586. /**
  27587. * Defines if webgl2 should be turned off even if supported
  27588. * @see http://doc.babylonjs.com/features/webgl2
  27589. */
  27590. disableWebGL2Support?: boolean;
  27591. /**
  27592. * Defines if webaudio should be initialized as well
  27593. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27594. */
  27595. audioEngine?: boolean;
  27596. /**
  27597. * Defines if animations should run using a deterministic lock step
  27598. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27599. */
  27600. deterministicLockstep?: boolean;
  27601. /** Defines the maximum steps to use with deterministic lock step mode */
  27602. lockstepMaxSteps?: number;
  27603. /**
  27604. * Defines that engine should ignore context lost events
  27605. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27606. */
  27607. doNotHandleContextLost?: boolean;
  27608. /**
  27609. * Defines that engine should ignore modifying touch action attribute and style
  27610. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27611. */
  27612. doNotHandleTouchAction?: boolean;
  27613. /**
  27614. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  27615. */
  27616. useHighPrecisionFloats?: boolean;
  27617. }
  27618. /**
  27619. * Defines the interface used by display changed events
  27620. */
  27621. export interface IDisplayChangedEventArgs {
  27622. /** Gets the vrDisplay object (if any) */
  27623. vrDisplay: Nullable<any>;
  27624. /** Gets a boolean indicating if webVR is supported */
  27625. vrSupported: boolean;
  27626. }
  27627. /**
  27628. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27629. */
  27630. export class Engine {
  27631. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27632. static ExceptionList: ({
  27633. key: string;
  27634. capture: string;
  27635. captureConstraint: number;
  27636. targets: string[];
  27637. } | {
  27638. key: string;
  27639. capture: null;
  27640. captureConstraint: null;
  27641. targets: string[];
  27642. })[];
  27643. /** Gets the list of created engines */
  27644. static readonly Instances: Engine[];
  27645. /**
  27646. * Gets the latest created engine
  27647. */
  27648. static readonly LastCreatedEngine: Nullable<Engine>;
  27649. /**
  27650. * Gets the latest created scene
  27651. */
  27652. static readonly LastCreatedScene: Nullable<Scene>;
  27653. /**
  27654. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27655. * @param flag defines which part of the materials must be marked as dirty
  27656. * @param predicate defines a predicate used to filter which materials should be affected
  27657. */
  27658. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27659. /**
  27660. * Hidden
  27661. */
  27662. static _TextureLoaders: IInternalTextureLoader[];
  27663. /** Defines that alpha blending is disabled */
  27664. static readonly ALPHA_DISABLE: number;
  27665. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27666. static readonly ALPHA_ADD: number;
  27667. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27668. static readonly ALPHA_COMBINE: number;
  27669. /** Defines that alpha blending to DEST - SRC * DEST */
  27670. static readonly ALPHA_SUBTRACT: number;
  27671. /** Defines that alpha blending to SRC * DEST */
  27672. static readonly ALPHA_MULTIPLY: number;
  27673. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27674. static readonly ALPHA_MAXIMIZED: number;
  27675. /** Defines that alpha blending to SRC + DEST */
  27676. static readonly ALPHA_ONEONE: number;
  27677. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27678. static readonly ALPHA_PREMULTIPLIED: number;
  27679. /**
  27680. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27681. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27682. */
  27683. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27684. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27685. static readonly ALPHA_INTERPOLATE: number;
  27686. /**
  27687. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27688. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27689. */
  27690. static readonly ALPHA_SCREENMODE: number;
  27691. /** Defines that the ressource is not delayed*/
  27692. static readonly DELAYLOADSTATE_NONE: number;
  27693. /** Defines that the ressource was successfully delay loaded */
  27694. static readonly DELAYLOADSTATE_LOADED: number;
  27695. /** Defines that the ressource is currently delay loading */
  27696. static readonly DELAYLOADSTATE_LOADING: number;
  27697. /** Defines that the ressource is delayed and has not started loading */
  27698. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27699. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27700. static readonly NEVER: number;
  27701. /** 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 */
  27702. static readonly ALWAYS: number;
  27703. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27704. static readonly LESS: number;
  27705. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27706. static readonly EQUAL: number;
  27707. /** 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 */
  27708. static readonly LEQUAL: number;
  27709. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27710. static readonly GREATER: number;
  27711. /** 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 */
  27712. static readonly GEQUAL: number;
  27713. /** 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 */
  27714. static readonly NOTEQUAL: number;
  27715. /** Passed to stencilOperation to specify that stencil value must be kept */
  27716. static readonly KEEP: number;
  27717. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27718. static readonly REPLACE: number;
  27719. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27720. static readonly INCR: number;
  27721. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27722. static readonly DECR: number;
  27723. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27724. static readonly INVERT: number;
  27725. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27726. static readonly INCR_WRAP: number;
  27727. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27728. static readonly DECR_WRAP: number;
  27729. /** Texture is not repeating outside of 0..1 UVs */
  27730. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27731. /** Texture is repeating outside of 0..1 UVs */
  27732. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27733. /** Texture is repeating and mirrored */
  27734. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27735. /** ALPHA */
  27736. static readonly TEXTUREFORMAT_ALPHA: number;
  27737. /** LUMINANCE */
  27738. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27739. /** LUMINANCE_ALPHA */
  27740. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27741. /** RGB */
  27742. static readonly TEXTUREFORMAT_RGB: number;
  27743. /** RGBA */
  27744. static readonly TEXTUREFORMAT_RGBA: number;
  27745. /** RED */
  27746. static readonly TEXTUREFORMAT_RED: number;
  27747. /** RED (2nd reference) */
  27748. static readonly TEXTUREFORMAT_R: number;
  27749. /** RG */
  27750. static readonly TEXTUREFORMAT_RG: number;
  27751. /** RED_INTEGER */
  27752. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27753. /** RED_INTEGER (2nd reference) */
  27754. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27755. /** RG_INTEGER */
  27756. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27757. /** RGB_INTEGER */
  27758. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27759. /** RGBA_INTEGER */
  27760. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27761. /** UNSIGNED_BYTE */
  27762. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27763. /** UNSIGNED_BYTE (2nd reference) */
  27764. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27765. /** FLOAT */
  27766. static readonly TEXTURETYPE_FLOAT: number;
  27767. /** HALF_FLOAT */
  27768. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27769. /** BYTE */
  27770. static readonly TEXTURETYPE_BYTE: number;
  27771. /** SHORT */
  27772. static readonly TEXTURETYPE_SHORT: number;
  27773. /** UNSIGNED_SHORT */
  27774. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27775. /** INT */
  27776. static readonly TEXTURETYPE_INT: number;
  27777. /** UNSIGNED_INT */
  27778. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27779. /** UNSIGNED_SHORT_4_4_4_4 */
  27780. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27781. /** UNSIGNED_SHORT_5_5_5_1 */
  27782. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27783. /** UNSIGNED_SHORT_5_6_5 */
  27784. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27785. /** UNSIGNED_INT_2_10_10_10_REV */
  27786. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27787. /** UNSIGNED_INT_24_8 */
  27788. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27789. /** UNSIGNED_INT_10F_11F_11F_REV */
  27790. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27791. /** UNSIGNED_INT_5_9_9_9_REV */
  27792. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27793. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27794. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27795. /** nearest is mag = nearest and min = nearest and mip = linear */
  27796. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27797. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27798. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27799. /** Trilinear is mag = linear and min = linear and mip = linear */
  27800. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27801. /** nearest is mag = nearest and min = nearest and mip = linear */
  27802. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27803. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27804. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27805. /** Trilinear is mag = linear and min = linear and mip = linear */
  27806. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27807. /** mag = nearest and min = nearest and mip = nearest */
  27808. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27809. /** mag = nearest and min = linear and mip = nearest */
  27810. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27811. /** mag = nearest and min = linear and mip = linear */
  27812. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27813. /** mag = nearest and min = linear and mip = none */
  27814. static readonly TEXTURE_NEAREST_LINEAR: number;
  27815. /** mag = nearest and min = nearest and mip = none */
  27816. static readonly TEXTURE_NEAREST_NEAREST: number;
  27817. /** mag = linear and min = nearest and mip = nearest */
  27818. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27819. /** mag = linear and min = nearest and mip = linear */
  27820. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27821. /** mag = linear and min = linear and mip = none */
  27822. static readonly TEXTURE_LINEAR_LINEAR: number;
  27823. /** mag = linear and min = nearest and mip = none */
  27824. static readonly TEXTURE_LINEAR_NEAREST: number;
  27825. /** Explicit coordinates mode */
  27826. static readonly TEXTURE_EXPLICIT_MODE: number;
  27827. /** Spherical coordinates mode */
  27828. static readonly TEXTURE_SPHERICAL_MODE: number;
  27829. /** Planar coordinates mode */
  27830. static readonly TEXTURE_PLANAR_MODE: number;
  27831. /** Cubic coordinates mode */
  27832. static readonly TEXTURE_CUBIC_MODE: number;
  27833. /** Projection coordinates mode */
  27834. static readonly TEXTURE_PROJECTION_MODE: number;
  27835. /** Skybox coordinates mode */
  27836. static readonly TEXTURE_SKYBOX_MODE: number;
  27837. /** Inverse Cubic coordinates mode */
  27838. static readonly TEXTURE_INVCUBIC_MODE: number;
  27839. /** Equirectangular coordinates mode */
  27840. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27841. /** Equirectangular Fixed coordinates mode */
  27842. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27843. /** Equirectangular Fixed Mirrored coordinates mode */
  27844. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27845. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27846. static readonly SCALEMODE_FLOOR: number;
  27847. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27848. static readonly SCALEMODE_NEAREST: number;
  27849. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27850. static readonly SCALEMODE_CEILING: number;
  27851. /**
  27852. * Returns the current npm package of the sdk
  27853. */
  27854. static readonly NpmPackage: string;
  27855. /**
  27856. * Returns the current version of the framework
  27857. */
  27858. static readonly Version: string;
  27859. /**
  27860. * Returns a string describing the current engine
  27861. */
  27862. readonly description: string;
  27863. /**
  27864. * Gets or sets the epsilon value used by collision engine
  27865. */
  27866. static CollisionsEpsilon: number;
  27867. /**
  27868. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27869. */
  27870. static ShadersRepository: string;
  27871. /**
  27872. * Method called to create the default loading screen.
  27873. * This can be overriden in your own app.
  27874. * @param canvas The rendering canvas element
  27875. * @returns The loading screen
  27876. */
  27877. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27878. /**
  27879. * Method called to create the default rescale post process on each engine.
  27880. */
  27881. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27882. /**
  27883. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27884. */
  27885. forcePOTTextures: boolean;
  27886. /**
  27887. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27888. */
  27889. isFullscreen: boolean;
  27890. /**
  27891. * Gets a boolean indicating if the pointer is currently locked
  27892. */
  27893. isPointerLock: boolean;
  27894. /**
  27895. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27896. */
  27897. cullBackFaces: boolean;
  27898. /**
  27899. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27900. */
  27901. renderEvenInBackground: boolean;
  27902. /**
  27903. * Gets or sets a boolean indicating that cache can be kept between frames
  27904. */
  27905. preventCacheWipeBetweenFrames: boolean;
  27906. /**
  27907. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27908. **/
  27909. enableOfflineSupport: boolean;
  27910. /**
  27911. * 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)
  27912. **/
  27913. disableManifestCheck: boolean;
  27914. /**
  27915. * Gets the list of created scenes
  27916. */
  27917. scenes: Scene[];
  27918. /**
  27919. * Event raised when a new scene is created
  27920. */
  27921. onNewSceneAddedObservable: Observable<Scene>;
  27922. /**
  27923. * Gets the list of created postprocesses
  27924. */
  27925. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  27926. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27927. validateShaderPrograms: boolean;
  27928. /**
  27929. * Observable event triggered each time the rendering canvas is resized
  27930. */
  27931. onResizeObservable: Observable<Engine>;
  27932. /**
  27933. * Observable event triggered each time the canvas loses focus
  27934. */
  27935. onCanvasBlurObservable: Observable<Engine>;
  27936. /**
  27937. * Observable event triggered each time the canvas gains focus
  27938. */
  27939. onCanvasFocusObservable: Observable<Engine>;
  27940. /**
  27941. * Observable event triggered each time the canvas receives pointerout event
  27942. */
  27943. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27944. /**
  27945. * Observable event triggered before each texture is initialized
  27946. */
  27947. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  27948. private _vrDisplay;
  27949. private _vrSupported;
  27950. private _oldSize;
  27951. private _oldHardwareScaleFactor;
  27952. private _vrExclusivePointerMode;
  27953. private _webVRInitPromise;
  27954. /**
  27955. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27956. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27957. */
  27958. readonly isInVRExclusivePointerMode: boolean;
  27959. /**
  27960. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27961. */
  27962. disableUniformBuffers: boolean;
  27963. /** @hidden */
  27964. _uniformBuffers: UniformBuffer[];
  27965. /**
  27966. * Gets a boolean indicating that the engine supports uniform buffers
  27967. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27968. */
  27969. readonly supportsUniformBuffers: boolean;
  27970. /**
  27971. * Observable raised when the engine begins a new frame
  27972. */
  27973. onBeginFrameObservable: Observable<Engine>;
  27974. /**
  27975. * If set, will be used to request the next animation frame for the render loop
  27976. */
  27977. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27978. /**
  27979. * Observable raised when the engine ends the current frame
  27980. */
  27981. onEndFrameObservable: Observable<Engine>;
  27982. /**
  27983. * Observable raised when the engine is about to compile a shader
  27984. */
  27985. onBeforeShaderCompilationObservable: Observable<Engine>;
  27986. /**
  27987. * Observable raised when the engine has jsut compiled a shader
  27988. */
  27989. onAfterShaderCompilationObservable: Observable<Engine>;
  27990. /** @hidden */
  27991. _gl: WebGLRenderingContext;
  27992. private _renderingCanvas;
  27993. private _windowIsBackground;
  27994. private _webGLVersion;
  27995. protected _highPrecisionShadersAllowed: boolean;
  27996. /** @hidden */
  27997. readonly _shouldUseHighPrecisionShader: boolean;
  27998. /**
  27999. * Gets a boolean indicating that only power of 2 textures are supported
  28000. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28001. */
  28002. readonly needPOTTextures: boolean;
  28003. /** @hidden */
  28004. _badOS: boolean;
  28005. /** @hidden */
  28006. _badDesktopOS: boolean;
  28007. /**
  28008. * Gets the audio engine
  28009. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28010. * @ignorenaming
  28011. */
  28012. static audioEngine: IAudioEngine;
  28013. /**
  28014. * Default AudioEngine factory responsible of creating the Audio Engine.
  28015. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  28016. */
  28017. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  28018. /**
  28019. * Default offline support factory responsible of creating a tool used to store data locally.
  28020. * By default, this will create a Database object if the workload has been embedded.
  28021. */
  28022. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  28023. private _onFocus;
  28024. private _onBlur;
  28025. private _onCanvasPointerOut;
  28026. private _onCanvasBlur;
  28027. private _onCanvasFocus;
  28028. private _onFullscreenChange;
  28029. private _onPointerLockChange;
  28030. private _onVRDisplayPointerRestricted;
  28031. private _onVRDisplayPointerUnrestricted;
  28032. private _onVrDisplayConnect;
  28033. private _onVrDisplayDisconnect;
  28034. private _onVrDisplayPresentChange;
  28035. /**
  28036. * Observable signaled when VR display mode changes
  28037. */
  28038. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  28039. /**
  28040. * Observable signaled when VR request present is complete
  28041. */
  28042. onVRRequestPresentComplete: Observable<boolean>;
  28043. /**
  28044. * Observable signaled when VR request present starts
  28045. */
  28046. onVRRequestPresentStart: Observable<Engine>;
  28047. private _hardwareScalingLevel;
  28048. /** @hidden */
  28049. protected _caps: EngineCapabilities;
  28050. private _pointerLockRequested;
  28051. private _isStencilEnable;
  28052. private _colorWrite;
  28053. private _loadingScreen;
  28054. /** @hidden */
  28055. _drawCalls: PerfCounter;
  28056. private _glVersion;
  28057. private _glRenderer;
  28058. private _glVendor;
  28059. private _videoTextureSupported;
  28060. private _renderingQueueLaunched;
  28061. private _activeRenderLoops;
  28062. private _deterministicLockstep;
  28063. private _lockstepMaxSteps;
  28064. /**
  28065. * Observable signaled when a context lost event is raised
  28066. */
  28067. onContextLostObservable: Observable<Engine>;
  28068. /**
  28069. * Observable signaled when a context restored event is raised
  28070. */
  28071. onContextRestoredObservable: Observable<Engine>;
  28072. private _onContextLost;
  28073. private _onContextRestored;
  28074. private _contextWasLost;
  28075. private _doNotHandleContextLost;
  28076. /**
  28077. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28078. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28079. */
  28080. doNotHandleContextLost: boolean;
  28081. private _performanceMonitor;
  28082. private _fps;
  28083. private _deltaTime;
  28084. /**
  28085. * Turn this value on if you want to pause FPS computation when in background
  28086. */
  28087. disablePerformanceMonitorInBackground: boolean;
  28088. /**
  28089. * Gets the performance monitor attached to this engine
  28090. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28091. */
  28092. readonly performanceMonitor: PerformanceMonitor;
  28093. /**
  28094. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  28095. */
  28096. disableVertexArrayObjects: boolean;
  28097. /** @hidden */
  28098. protected _depthCullingState: _DepthCullingState;
  28099. /** @hidden */
  28100. protected _stencilState: _StencilState;
  28101. /** @hidden */
  28102. protected _alphaState: _AlphaState;
  28103. /** @hidden */
  28104. protected _alphaMode: number;
  28105. protected _internalTexturesCache: InternalTexture[];
  28106. /** @hidden */
  28107. protected _activeChannel: number;
  28108. private _currentTextureChannel;
  28109. /** @hidden */
  28110. protected _boundTexturesCache: {
  28111. [key: string]: Nullable<InternalTexture>;
  28112. };
  28113. /** @hidden */
  28114. protected _currentEffect: Nullable<Effect>;
  28115. /** @hidden */
  28116. protected _currentProgram: Nullable<WebGLProgram>;
  28117. private _compiledEffects;
  28118. private _vertexAttribArraysEnabled;
  28119. /** @hidden */
  28120. protected _cachedViewport: Nullable<Viewport>;
  28121. private _cachedVertexArrayObject;
  28122. /** @hidden */
  28123. protected _cachedVertexBuffers: any;
  28124. /** @hidden */
  28125. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  28126. /** @hidden */
  28127. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28128. /** @hidden */
  28129. protected _currentRenderTarget: Nullable<InternalTexture>;
  28130. private _uintIndicesCurrentlySet;
  28131. private _currentBoundBuffer;
  28132. /** @hidden */
  28133. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28134. private _currentBufferPointers;
  28135. private _currentInstanceLocations;
  28136. private _currentInstanceBuffers;
  28137. private _textureUnits;
  28138. private _workingCanvas;
  28139. private _workingContext;
  28140. private _rescalePostProcess;
  28141. private _dummyFramebuffer;
  28142. private _externalData;
  28143. private _bindedRenderFunction;
  28144. private _vaoRecordInProgress;
  28145. private _mustWipeVertexAttributes;
  28146. private _emptyTexture;
  28147. private _emptyCubeTexture;
  28148. private _emptyTexture3D;
  28149. /** @hidden */
  28150. _frameHandler: number;
  28151. private _nextFreeTextureSlots;
  28152. private _maxSimultaneousTextures;
  28153. private _activeRequests;
  28154. private _texturesSupported;
  28155. private _textureFormatInUse;
  28156. /**
  28157. * Gets the list of texture formats supported
  28158. */
  28159. readonly texturesSupported: Array<string>;
  28160. /**
  28161. * Gets the list of texture formats in use
  28162. */
  28163. readonly textureFormatInUse: Nullable<string>;
  28164. /**
  28165. * Gets the current viewport
  28166. */
  28167. readonly currentViewport: Nullable<Viewport>;
  28168. /**
  28169. * Gets the default empty texture
  28170. */
  28171. readonly emptyTexture: InternalTexture;
  28172. /**
  28173. * Gets the default empty 3D texture
  28174. */
  28175. readonly emptyTexture3D: InternalTexture;
  28176. /**
  28177. * Gets the default empty cube texture
  28178. */
  28179. readonly emptyCubeTexture: InternalTexture;
  28180. /**
  28181. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28182. */
  28183. readonly premultipliedAlpha: boolean;
  28184. /**
  28185. * Creates a new engine
  28186. * @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
  28187. * @param antialias defines enable antialiasing (default: false)
  28188. * @param options defines further options to be sent to the getContext() function
  28189. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28190. */
  28191. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28192. private _disableTouchAction;
  28193. private _rebuildInternalTextures;
  28194. private _rebuildEffects;
  28195. /**
  28196. * Gets a boolean indicating if all created effects are ready
  28197. * @returns true if all effects are ready
  28198. */
  28199. areAllEffectsReady(): boolean;
  28200. private _rebuildBuffers;
  28201. private _initGLContext;
  28202. /**
  28203. * Gets version of the current webGL context
  28204. */
  28205. readonly webGLVersion: number;
  28206. /**
  28207. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28208. */
  28209. readonly isStencilEnable: boolean;
  28210. private _prepareWorkingCanvas;
  28211. /**
  28212. * Reset the texture cache to empty state
  28213. */
  28214. resetTextureCache(): void;
  28215. /**
  28216. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28217. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28218. * @returns true if engine is in deterministic lock step mode
  28219. */
  28220. isDeterministicLockStep(): boolean;
  28221. /**
  28222. * Gets the max steps when engine is running in deterministic lock step
  28223. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28224. * @returns the max steps
  28225. */
  28226. getLockstepMaxSteps(): number;
  28227. /**
  28228. * Gets an object containing information about the current webGL context
  28229. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28230. */
  28231. getGlInfo(): {
  28232. vendor: string;
  28233. renderer: string;
  28234. version: string;
  28235. };
  28236. /**
  28237. * Gets current aspect ratio
  28238. * @param camera defines the camera to use to get the aspect ratio
  28239. * @param useScreen defines if screen size must be used (or the current render target if any)
  28240. * @returns a number defining the aspect ratio
  28241. */
  28242. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28243. /**
  28244. * Gets current screen aspect ratio
  28245. * @returns a number defining the aspect ratio
  28246. */
  28247. getScreenAspectRatio(): number;
  28248. /**
  28249. * Gets the current render width
  28250. * @param useScreen defines if screen size must be used (or the current render target if any)
  28251. * @returns a number defining the current render width
  28252. */
  28253. getRenderWidth(useScreen?: boolean): number;
  28254. /**
  28255. * Gets the current render height
  28256. * @param useScreen defines if screen size must be used (or the current render target if any)
  28257. * @returns a number defining the current render height
  28258. */
  28259. getRenderHeight(useScreen?: boolean): number;
  28260. /**
  28261. * Gets the HTML canvas attached with the current webGL context
  28262. * @returns a HTML canvas
  28263. */
  28264. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28265. /**
  28266. * Gets the client rect of the HTML canvas attached with the current webGL context
  28267. * @returns a client rectanglee
  28268. */
  28269. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28270. /**
  28271. * Defines the hardware scaling level.
  28272. * By default the hardware scaling level is computed from the window device ratio.
  28273. * 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.
  28274. * @param level defines the level to use
  28275. */
  28276. setHardwareScalingLevel(level: number): void;
  28277. /**
  28278. * Gets the current hardware scaling level.
  28279. * By default the hardware scaling level is computed from the window device ratio.
  28280. * 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.
  28281. * @returns a number indicating the current hardware scaling level
  28282. */
  28283. getHardwareScalingLevel(): number;
  28284. /**
  28285. * Gets the list of loaded textures
  28286. * @returns an array containing all loaded textures
  28287. */
  28288. getLoadedTexturesCache(): InternalTexture[];
  28289. /**
  28290. * Gets the object containing all engine capabilities
  28291. * @returns the EngineCapabilities object
  28292. */
  28293. getCaps(): EngineCapabilities;
  28294. /**
  28295. * Gets the current depth function
  28296. * @returns a number defining the depth function
  28297. */
  28298. getDepthFunction(): Nullable<number>;
  28299. /**
  28300. * Sets the current depth function
  28301. * @param depthFunc defines the function to use
  28302. */
  28303. setDepthFunction(depthFunc: number): void;
  28304. /**
  28305. * Sets the current depth function to GREATER
  28306. */
  28307. setDepthFunctionToGreater(): void;
  28308. /**
  28309. * Sets the current depth function to GEQUAL
  28310. */
  28311. setDepthFunctionToGreaterOrEqual(): void;
  28312. /**
  28313. * Sets the current depth function to LESS
  28314. */
  28315. setDepthFunctionToLess(): void;
  28316. private _cachedStencilBuffer;
  28317. private _cachedStencilFunction;
  28318. private _cachedStencilMask;
  28319. private _cachedStencilOperationPass;
  28320. private _cachedStencilOperationFail;
  28321. private _cachedStencilOperationDepthFail;
  28322. private _cachedStencilReference;
  28323. /**
  28324. * Caches the the state of the stencil buffer
  28325. */
  28326. cacheStencilState(): void;
  28327. /**
  28328. * Restores the state of the stencil buffer
  28329. */
  28330. restoreStencilState(): void;
  28331. /**
  28332. * Sets the current depth function to LEQUAL
  28333. */
  28334. setDepthFunctionToLessOrEqual(): void;
  28335. /**
  28336. * Gets a boolean indicating if stencil buffer is enabled
  28337. * @returns the current stencil buffer state
  28338. */
  28339. getStencilBuffer(): boolean;
  28340. /**
  28341. * Enable or disable the stencil buffer
  28342. * @param enable defines if the stencil buffer must be enabled or disabled
  28343. */
  28344. setStencilBuffer(enable: boolean): void;
  28345. /**
  28346. * Gets the current stencil mask
  28347. * @returns a number defining the new stencil mask to use
  28348. */
  28349. getStencilMask(): number;
  28350. /**
  28351. * Sets the current stencil mask
  28352. * @param mask defines the new stencil mask to use
  28353. */
  28354. setStencilMask(mask: number): void;
  28355. /**
  28356. * Gets the current stencil function
  28357. * @returns a number defining the stencil function to use
  28358. */
  28359. getStencilFunction(): number;
  28360. /**
  28361. * Gets the current stencil reference value
  28362. * @returns a number defining the stencil reference value to use
  28363. */
  28364. getStencilFunctionReference(): number;
  28365. /**
  28366. * Gets the current stencil mask
  28367. * @returns a number defining the stencil mask to use
  28368. */
  28369. getStencilFunctionMask(): number;
  28370. /**
  28371. * Sets the current stencil function
  28372. * @param stencilFunc defines the new stencil function to use
  28373. */
  28374. setStencilFunction(stencilFunc: number): void;
  28375. /**
  28376. * Sets the current stencil reference
  28377. * @param reference defines the new stencil reference to use
  28378. */
  28379. setStencilFunctionReference(reference: number): void;
  28380. /**
  28381. * Sets the current stencil mask
  28382. * @param mask defines the new stencil mask to use
  28383. */
  28384. setStencilFunctionMask(mask: number): void;
  28385. /**
  28386. * Gets the current stencil operation when stencil fails
  28387. * @returns a number defining stencil operation to use when stencil fails
  28388. */
  28389. getStencilOperationFail(): number;
  28390. /**
  28391. * Gets the current stencil operation when depth fails
  28392. * @returns a number defining stencil operation to use when depth fails
  28393. */
  28394. getStencilOperationDepthFail(): number;
  28395. /**
  28396. * Gets the current stencil operation when stencil passes
  28397. * @returns a number defining stencil operation to use when stencil passes
  28398. */
  28399. getStencilOperationPass(): number;
  28400. /**
  28401. * Sets the stencil operation to use when stencil fails
  28402. * @param operation defines the stencil operation to use when stencil fails
  28403. */
  28404. setStencilOperationFail(operation: number): void;
  28405. /**
  28406. * Sets the stencil operation to use when depth fails
  28407. * @param operation defines the stencil operation to use when depth fails
  28408. */
  28409. setStencilOperationDepthFail(operation: number): void;
  28410. /**
  28411. * Sets the stencil operation to use when stencil passes
  28412. * @param operation defines the stencil operation to use when stencil passes
  28413. */
  28414. setStencilOperationPass(operation: number): void;
  28415. /**
  28416. * Sets a boolean indicating if the dithering state is enabled or disabled
  28417. * @param value defines the dithering state
  28418. */
  28419. setDitheringState(value: boolean): void;
  28420. /**
  28421. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28422. * @param value defines the rasterizer state
  28423. */
  28424. setRasterizerState(value: boolean): void;
  28425. /**
  28426. * stop executing a render loop function and remove it from the execution array
  28427. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28428. */
  28429. stopRenderLoop(renderFunction?: () => void): void;
  28430. /** @hidden */
  28431. _renderLoop(): void;
  28432. /**
  28433. * Register and execute a render loop. The engine can have more than one render function
  28434. * @param renderFunction defines the function to continuously execute
  28435. */
  28436. runRenderLoop(renderFunction: () => void): void;
  28437. /**
  28438. * Toggle full screen mode
  28439. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28440. */
  28441. switchFullscreen(requestPointerLock: boolean): void;
  28442. /**
  28443. * Enters full screen mode
  28444. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28445. */
  28446. enterFullscreen(requestPointerLock: boolean): void;
  28447. /**
  28448. * Exits full screen mode
  28449. */
  28450. exitFullscreen(): void;
  28451. /**
  28452. * Clear the current render buffer or the current render target (if any is set up)
  28453. * @param color defines the color to use
  28454. * @param backBuffer defines if the back buffer must be cleared
  28455. * @param depth defines if the depth buffer must be cleared
  28456. * @param stencil defines if the stencil buffer must be cleared
  28457. */
  28458. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28459. /**
  28460. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28461. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28462. * @param y defines the y-coordinate of the corner of the clear rectangle
  28463. * @param width defines the width of the clear rectangle
  28464. * @param height defines the height of the clear rectangle
  28465. * @param clearColor defines the clear color
  28466. */
  28467. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28468. /**
  28469. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28470. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28471. * @param y defines the y-coordinate of the corner of the clear rectangle
  28472. * @param width defines the width of the clear rectangle
  28473. * @param height defines the height of the clear rectangle
  28474. */
  28475. enableScissor(x: number, y: number, width: number, height: number): void;
  28476. /**
  28477. * Disable previously set scissor test rectangle
  28478. */
  28479. disableScissor(): void;
  28480. private _viewportCached;
  28481. /** @hidden */
  28482. _viewport(x: number, y: number, width: number, height: number): void;
  28483. /**
  28484. * Set the WebGL's viewport
  28485. * @param viewport defines the viewport element to be used
  28486. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28487. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28488. */
  28489. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28490. /**
  28491. * Directly set the WebGL Viewport
  28492. * @param x defines the x coordinate of the viewport (in screen space)
  28493. * @param y defines the y coordinate of the viewport (in screen space)
  28494. * @param width defines the width of the viewport (in screen space)
  28495. * @param height defines the height of the viewport (in screen space)
  28496. * @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
  28497. */
  28498. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28499. /**
  28500. * Begin a new frame
  28501. */
  28502. beginFrame(): void;
  28503. /**
  28504. * Enf the current frame
  28505. */
  28506. endFrame(): void;
  28507. /**
  28508. * Resize the view according to the canvas' size
  28509. */
  28510. resize(): void;
  28511. /**
  28512. * Force a specific size of the canvas
  28513. * @param width defines the new canvas' width
  28514. * @param height defines the new canvas' height
  28515. */
  28516. setSize(width: number, height: number): void;
  28517. /**
  28518. * Gets a boolean indicating if a webVR device was detected
  28519. * @returns true if a webVR device was detected
  28520. */
  28521. isVRDevicePresent(): boolean;
  28522. /**
  28523. * Gets the current webVR device
  28524. * @returns the current webVR device (or null)
  28525. */
  28526. getVRDevice(): any;
  28527. /**
  28528. * Initializes a webVR display and starts listening to display change events
  28529. * The onVRDisplayChangedObservable will be notified upon these changes
  28530. * @returns The onVRDisplayChangedObservable
  28531. */
  28532. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28533. /**
  28534. * Initializes a webVR display and starts listening to display change events
  28535. * The onVRDisplayChangedObservable will be notified upon these changes
  28536. * @returns A promise containing a VRDisplay and if vr is supported
  28537. */
  28538. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  28539. /**
  28540. * Call this function to switch to webVR mode
  28541. * Will do nothing if webVR is not supported or if there is no webVR device
  28542. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28543. */
  28544. enableVR(): void;
  28545. /**
  28546. * Call this function to leave webVR mode
  28547. * Will do nothing if webVR is not supported or if there is no webVR device
  28548. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28549. */
  28550. disableVR(): void;
  28551. private _onVRFullScreenTriggered;
  28552. private _getVRDisplaysAsync;
  28553. /**
  28554. * Binds the frame buffer to the specified texture.
  28555. * @param texture The texture to render to or null for the default canvas
  28556. * @param faceIndex The face of the texture to render to in case of cube texture
  28557. * @param requiredWidth The width of the target to render to
  28558. * @param requiredHeight The height of the target to render to
  28559. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28560. * @param depthStencilTexture The depth stencil texture to use to render
  28561. * @param lodLevel defines le lod level to bind to the frame buffer
  28562. */
  28563. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28564. private bindUnboundFramebuffer;
  28565. /**
  28566. * Unbind the current render target texture from the webGL context
  28567. * @param texture defines the render target texture to unbind
  28568. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28569. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28570. */
  28571. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28572. /**
  28573. * Unbind a list of render target textures from the webGL context
  28574. * This is used only when drawBuffer extension or webGL2 are active
  28575. * @param textures defines the render target textures to unbind
  28576. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28577. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28578. */
  28579. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28580. /**
  28581. * Force the mipmap generation for the given render target texture
  28582. * @param texture defines the render target texture to use
  28583. */
  28584. generateMipMapsForCubemap(texture: InternalTexture): void;
  28585. /**
  28586. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28587. */
  28588. flushFramebuffer(): void;
  28589. /**
  28590. * Unbind the current render target and bind the default framebuffer
  28591. */
  28592. restoreDefaultFramebuffer(): void;
  28593. /**
  28594. * Create an uniform buffer
  28595. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28596. * @param elements defines the content of the uniform buffer
  28597. * @returns the webGL uniform buffer
  28598. */
  28599. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  28600. /**
  28601. * Create a dynamic uniform buffer
  28602. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28603. * @param elements defines the content of the uniform buffer
  28604. * @returns the webGL uniform buffer
  28605. */
  28606. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  28607. /**
  28608. * Update an existing uniform buffer
  28609. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28610. * @param uniformBuffer defines the target uniform buffer
  28611. * @param elements defines the content to update
  28612. * @param offset defines the offset in the uniform buffer where update should start
  28613. * @param count defines the size of the data to update
  28614. */
  28615. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28616. private _resetVertexBufferBinding;
  28617. /**
  28618. * Creates a vertex buffer
  28619. * @param data the data for the vertex buffer
  28620. * @returns the new WebGL static buffer
  28621. */
  28622. createVertexBuffer(data: DataArray): WebGLBuffer;
  28623. /**
  28624. * Creates a dynamic vertex buffer
  28625. * @param data the data for the dynamic vertex buffer
  28626. * @returns the new WebGL dynamic buffer
  28627. */
  28628. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  28629. /**
  28630. * Update a dynamic index buffer
  28631. * @param indexBuffer defines the target index buffer
  28632. * @param indices defines the data to update
  28633. * @param offset defines the offset in the target index buffer where update should start
  28634. */
  28635. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  28636. /**
  28637. * Updates a dynamic vertex buffer.
  28638. * @param vertexBuffer the vertex buffer to update
  28639. * @param data the data used to update the vertex buffer
  28640. * @param byteOffset the byte offset of the data
  28641. * @param byteLength the byte length of the data
  28642. */
  28643. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28644. private _resetIndexBufferBinding;
  28645. /**
  28646. * Creates a new index buffer
  28647. * @param indices defines the content of the index buffer
  28648. * @param updatable defines if the index buffer must be updatable
  28649. * @returns a new webGL buffer
  28650. */
  28651. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  28652. /**
  28653. * Bind a webGL buffer to the webGL context
  28654. * @param buffer defines the buffer to bind
  28655. */
  28656. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  28657. /**
  28658. * Bind an uniform buffer to the current webGL context
  28659. * @param buffer defines the buffer to bind
  28660. */
  28661. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  28662. /**
  28663. * Bind a buffer to the current webGL context at a given location
  28664. * @param buffer defines the buffer to bind
  28665. * @param location defines the index where to bind the buffer
  28666. */
  28667. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  28668. /**
  28669. * Bind a specific block at a given index in a specific shader program
  28670. * @param shaderProgram defines the shader program
  28671. * @param blockName defines the block name
  28672. * @param index defines the index where to bind the block
  28673. */
  28674. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  28675. private bindIndexBuffer;
  28676. private bindBuffer;
  28677. /**
  28678. * update the bound buffer with the given data
  28679. * @param data defines the data to update
  28680. */
  28681. updateArrayBuffer(data: Float32Array): void;
  28682. private _vertexAttribPointer;
  28683. private _bindIndexBufferWithCache;
  28684. private _bindVertexBuffersAttributes;
  28685. /**
  28686. * Records a vertex array object
  28687. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28688. * @param vertexBuffers defines the list of vertex buffers to store
  28689. * @param indexBuffer defines the index buffer to store
  28690. * @param effect defines the effect to store
  28691. * @returns the new vertex array object
  28692. */
  28693. recordVertexArrayObject(vertexBuffers: {
  28694. [key: string]: VertexBuffer;
  28695. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  28696. /**
  28697. * Bind a specific vertex array object
  28698. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28699. * @param vertexArrayObject defines the vertex array object to bind
  28700. * @param indexBuffer defines the index buffer to bind
  28701. */
  28702. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  28703. /**
  28704. * Bind webGl buffers directly to the webGL context
  28705. * @param vertexBuffer defines the vertex buffer to bind
  28706. * @param indexBuffer defines the index buffer to bind
  28707. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28708. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28709. * @param effect defines the effect associated with the vertex buffer
  28710. */
  28711. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28712. private _unbindVertexArrayObject;
  28713. /**
  28714. * Bind a list of vertex buffers to the webGL context
  28715. * @param vertexBuffers defines the list of vertex buffers to bind
  28716. * @param indexBuffer defines the index buffer to bind
  28717. * @param effect defines the effect associated with the vertex buffers
  28718. */
  28719. bindBuffers(vertexBuffers: {
  28720. [key: string]: Nullable<VertexBuffer>;
  28721. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  28722. /**
  28723. * Unbind all instance attributes
  28724. */
  28725. unbindInstanceAttributes(): void;
  28726. /**
  28727. * Release and free the memory of a vertex array object
  28728. * @param vao defines the vertex array object to delete
  28729. */
  28730. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28731. /** @hidden */
  28732. _releaseBuffer(buffer: WebGLBuffer): boolean;
  28733. /**
  28734. * Creates a webGL buffer to use with instanciation
  28735. * @param capacity defines the size of the buffer
  28736. * @returns the webGL buffer
  28737. */
  28738. createInstancesBuffer(capacity: number): WebGLBuffer;
  28739. /**
  28740. * Delete a webGL buffer used with instanciation
  28741. * @param buffer defines the webGL buffer to delete
  28742. */
  28743. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28744. /**
  28745. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28746. * @param instancesBuffer defines the webGL buffer to update and bind
  28747. * @param data defines the data to store in the buffer
  28748. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28749. */
  28750. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28751. /**
  28752. * Apply all cached states (depth, culling, stencil and alpha)
  28753. */
  28754. applyStates(): void;
  28755. /**
  28756. * Send a draw order
  28757. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28758. * @param indexStart defines the starting index
  28759. * @param indexCount defines the number of index to draw
  28760. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28761. */
  28762. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28763. /**
  28764. * Draw a list of points
  28765. * @param verticesStart defines the index of first vertex to draw
  28766. * @param verticesCount defines the count of vertices to draw
  28767. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28768. */
  28769. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28770. /**
  28771. * Draw a list of unindexed primitives
  28772. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28773. * @param verticesStart defines the index of first vertex to draw
  28774. * @param verticesCount defines the count of vertices to draw
  28775. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28776. */
  28777. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28778. /**
  28779. * Draw a list of indexed primitives
  28780. * @param fillMode defines the primitive to use
  28781. * @param indexStart defines the starting index
  28782. * @param indexCount defines the number of index to draw
  28783. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28784. */
  28785. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28786. /**
  28787. * Draw a list of unindexed primitives
  28788. * @param fillMode defines the primitive to use
  28789. * @param verticesStart defines the index of first vertex to draw
  28790. * @param verticesCount defines the count of vertices to draw
  28791. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28792. */
  28793. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28794. private _drawMode;
  28795. /** @hidden */
  28796. _releaseEffect(effect: Effect): void;
  28797. /** @hidden */
  28798. _deleteProgram(program: WebGLProgram): void;
  28799. /**
  28800. * Create a new effect (used to store vertex/fragment shaders)
  28801. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28802. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28803. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28804. * @param samplers defines an array of string used to represent textures
  28805. * @param defines defines the string containing the defines to use to compile the shaders
  28806. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28807. * @param onCompiled defines a function to call when the effect creation is successful
  28808. * @param onError defines a function to call when the effect creation has failed
  28809. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28810. * @returns the new Effect
  28811. */
  28812. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any): Effect;
  28813. private _compileShader;
  28814. private _compileRawShader;
  28815. /**
  28816. * Directly creates a webGL program
  28817. * @param vertexCode defines the vertex shader code to use
  28818. * @param fragmentCode defines the fragment shader code to use
  28819. * @param context defines the webGL context to use (if not set, the current one will be used)
  28820. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28821. * @returns the new webGL program
  28822. */
  28823. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28824. /**
  28825. * Creates a webGL program
  28826. * @param vertexCode defines the vertex shader code to use
  28827. * @param fragmentCode defines the fragment shader code to use
  28828. * @param defines defines the string containing the defines to use to compile the shaders
  28829. * @param context defines the webGL context to use (if not set, the current one will be used)
  28830. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28831. * @returns the new webGL program
  28832. */
  28833. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28834. private _createShaderProgram;
  28835. private _finalizeProgram;
  28836. /** @hidden */
  28837. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  28838. /** @hidden */
  28839. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  28840. /**
  28841. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28842. * @param shaderProgram defines the webGL program to use
  28843. * @param uniformsNames defines the list of uniform names
  28844. * @returns an array of webGL uniform locations
  28845. */
  28846. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28847. /**
  28848. * Gets the lsit of active attributes for a given webGL program
  28849. * @param shaderProgram defines the webGL program to use
  28850. * @param attributesNames defines the list of attribute names to get
  28851. * @returns an array of indices indicating the offset of each attribute
  28852. */
  28853. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  28854. /**
  28855. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28856. * @param effect defines the effect to activate
  28857. */
  28858. enableEffect(effect: Nullable<Effect>): void;
  28859. /**
  28860. * Set the value of an uniform to an array of int32
  28861. * @param uniform defines the webGL uniform location where to store the value
  28862. * @param array defines the array of int32 to store
  28863. */
  28864. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28865. /**
  28866. * Set the value of an uniform to an array of int32 (stored as vec2)
  28867. * @param uniform defines the webGL uniform location where to store the value
  28868. * @param array defines the array of int32 to store
  28869. */
  28870. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28871. /**
  28872. * Set the value of an uniform to an array of int32 (stored as vec3)
  28873. * @param uniform defines the webGL uniform location where to store the value
  28874. * @param array defines the array of int32 to store
  28875. */
  28876. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28877. /**
  28878. * Set the value of an uniform to an array of int32 (stored as vec4)
  28879. * @param uniform defines the webGL uniform location where to store the value
  28880. * @param array defines the array of int32 to store
  28881. */
  28882. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28883. /**
  28884. * Set the value of an uniform to an array of float32
  28885. * @param uniform defines the webGL uniform location where to store the value
  28886. * @param array defines the array of float32 to store
  28887. */
  28888. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28889. /**
  28890. * Set the value of an uniform to an array of float32 (stored as vec2)
  28891. * @param uniform defines the webGL uniform location where to store the value
  28892. * @param array defines the array of float32 to store
  28893. */
  28894. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28895. /**
  28896. * Set the value of an uniform to an array of float32 (stored as vec3)
  28897. * @param uniform defines the webGL uniform location where to store the value
  28898. * @param array defines the array of float32 to store
  28899. */
  28900. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28901. /**
  28902. * Set the value of an uniform to an array of float32 (stored as vec4)
  28903. * @param uniform defines the webGL uniform location where to store the value
  28904. * @param array defines the array of float32 to store
  28905. */
  28906. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28907. /**
  28908. * Set the value of an uniform to an array of number
  28909. * @param uniform defines the webGL uniform location where to store the value
  28910. * @param array defines the array of number to store
  28911. */
  28912. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28913. /**
  28914. * Set the value of an uniform to an array of number (stored as vec2)
  28915. * @param uniform defines the webGL uniform location where to store the value
  28916. * @param array defines the array of number to store
  28917. */
  28918. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28919. /**
  28920. * Set the value of an uniform to an array of number (stored as vec3)
  28921. * @param uniform defines the webGL uniform location where to store the value
  28922. * @param array defines the array of number to store
  28923. */
  28924. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28925. /**
  28926. * Set the value of an uniform to an array of number (stored as vec4)
  28927. * @param uniform defines the webGL uniform location where to store the value
  28928. * @param array defines the array of number to store
  28929. */
  28930. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28931. /**
  28932. * Set the value of an uniform to an array of float32 (stored as matrices)
  28933. * @param uniform defines the webGL uniform location where to store the value
  28934. * @param matrices defines the array of float32 to store
  28935. */
  28936. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28937. /**
  28938. * Set the value of an uniform to a matrix
  28939. * @param uniform defines the webGL uniform location where to store the value
  28940. * @param matrix defines the matrix to store
  28941. */
  28942. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28943. /**
  28944. * Set the value of an uniform to a matrix (3x3)
  28945. * @param uniform defines the webGL uniform location where to store the value
  28946. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28947. */
  28948. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28949. /**
  28950. * Set the value of an uniform to a matrix (2x2)
  28951. * @param uniform defines the webGL uniform location where to store the value
  28952. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28953. */
  28954. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28955. /**
  28956. * Set the value of an uniform to a number (int)
  28957. * @param uniform defines the webGL uniform location where to store the value
  28958. * @param value defines the int number to store
  28959. */
  28960. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28961. /**
  28962. * Set the value of an uniform to a number (float)
  28963. * @param uniform defines the webGL uniform location where to store the value
  28964. * @param value defines the float number to store
  28965. */
  28966. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28967. /**
  28968. * Set the value of an uniform to a vec2
  28969. * @param uniform defines the webGL uniform location where to store the value
  28970. * @param x defines the 1st component of the value
  28971. * @param y defines the 2nd component of the value
  28972. */
  28973. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28974. /**
  28975. * Set the value of an uniform to a vec3
  28976. * @param uniform defines the webGL uniform location where to store the value
  28977. * @param x defines the 1st component of the value
  28978. * @param y defines the 2nd component of the value
  28979. * @param z defines the 3rd component of the value
  28980. */
  28981. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28982. /**
  28983. * Set the value of an uniform to a boolean
  28984. * @param uniform defines the webGL uniform location where to store the value
  28985. * @param bool defines the boolean to store
  28986. */
  28987. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28988. /**
  28989. * Set the value of an uniform to a vec4
  28990. * @param uniform defines the webGL uniform location where to store the value
  28991. * @param x defines the 1st component of the value
  28992. * @param y defines the 2nd component of the value
  28993. * @param z defines the 3rd component of the value
  28994. * @param w defines the 4th component of the value
  28995. */
  28996. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28997. /**
  28998. * Set the value of an uniform to a Color3
  28999. * @param uniform defines the webGL uniform location where to store the value
  29000. * @param color3 defines the color to store
  29001. */
  29002. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  29003. /**
  29004. * Set the value of an uniform to a Color3 and an alpha value
  29005. * @param uniform defines the webGL uniform location where to store the value
  29006. * @param color3 defines the color to store
  29007. * @param alpha defines the alpha component to store
  29008. */
  29009. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  29010. /**
  29011. * Sets a Color4 on a uniform variable
  29012. * @param uniform defines the uniform location
  29013. * @param color4 defines the value to be set
  29014. */
  29015. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  29016. /**
  29017. * Set various states to the webGL context
  29018. * @param culling defines backface culling state
  29019. * @param zOffset defines the value to apply to zOffset (0 by default)
  29020. * @param force defines if states must be applied even if cache is up to date
  29021. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  29022. */
  29023. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  29024. /**
  29025. * Set the z offset to apply to current rendering
  29026. * @param value defines the offset to apply
  29027. */
  29028. setZOffset(value: number): void;
  29029. /**
  29030. * Gets the current value of the zOffset
  29031. * @returns the current zOffset state
  29032. */
  29033. getZOffset(): number;
  29034. /**
  29035. * Enable or disable depth buffering
  29036. * @param enable defines the state to set
  29037. */
  29038. setDepthBuffer(enable: boolean): void;
  29039. /**
  29040. * Gets a boolean indicating if depth writing is enabled
  29041. * @returns the current depth writing state
  29042. */
  29043. getDepthWrite(): boolean;
  29044. /**
  29045. * Enable or disable depth writing
  29046. * @param enable defines the state to set
  29047. */
  29048. setDepthWrite(enable: boolean): void;
  29049. /**
  29050. * Enable or disable color writing
  29051. * @param enable defines the state to set
  29052. */
  29053. setColorWrite(enable: boolean): void;
  29054. /**
  29055. * Gets a boolean indicating if color writing is enabled
  29056. * @returns the current color writing state
  29057. */
  29058. getColorWrite(): boolean;
  29059. /**
  29060. * Sets alpha constants used by some alpha blending modes
  29061. * @param r defines the red component
  29062. * @param g defines the green component
  29063. * @param b defines the blue component
  29064. * @param a defines the alpha component
  29065. */
  29066. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  29067. /**
  29068. * Sets the current alpha mode
  29069. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  29070. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  29071. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29072. */
  29073. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  29074. /**
  29075. * Gets the current alpha mode
  29076. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29077. * @returns the current alpha mode
  29078. */
  29079. getAlphaMode(): number;
  29080. /**
  29081. * Clears the list of texture accessible through engine.
  29082. * This can help preventing texture load conflict due to name collision.
  29083. */
  29084. clearInternalTexturesCache(): void;
  29085. /**
  29086. * Force the entire cache to be cleared
  29087. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29088. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29089. */
  29090. wipeCaches(bruteForce?: boolean): void;
  29091. /**
  29092. * Set the compressed texture format to use, based on the formats you have, and the formats
  29093. * supported by the hardware / browser.
  29094. *
  29095. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  29096. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  29097. * to API arguments needed to compressed textures. This puts the burden on the container
  29098. * generator to house the arcane code for determining these for current & future formats.
  29099. *
  29100. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29101. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29102. *
  29103. * Note: The result of this call is not taken into account when a texture is base64.
  29104. *
  29105. * @param formatsAvailable defines the list of those format families you have created
  29106. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  29107. *
  29108. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29109. * @returns The extension selected.
  29110. */
  29111. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  29112. private _getSamplingParameters;
  29113. private _partialLoadImg;
  29114. private _cascadeLoadImgs;
  29115. /** @hidden */
  29116. _createTexture(): WebGLTexture;
  29117. /**
  29118. * Usually called from Texture.ts.
  29119. * Passed information to create a WebGLTexture
  29120. * @param urlArg defines a value which contains one of the following:
  29121. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29122. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29123. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29124. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29125. * @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)
  29126. * @param scene needed for loading to the correct scene
  29127. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29128. * @param onLoad optional callback to be called upon successful completion
  29129. * @param onError optional callback to be called upon failure
  29130. * @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
  29131. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29132. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29133. * @param forcedExtension defines the extension to use to pick the right loader
  29134. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29135. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29136. */
  29137. 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;
  29138. private _rescaleTexture;
  29139. /**
  29140. * Update a raw texture
  29141. * @param texture defines the texture to update
  29142. * @param data defines the data to store in the texture
  29143. * @param format defines the format of the data
  29144. * @param invertY defines if data must be stored with Y axis inverted
  29145. * @param compression defines the compression used (null by default)
  29146. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29147. */
  29148. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  29149. /**
  29150. * Creates a raw texture
  29151. * @param data defines the data to store in the texture
  29152. * @param width defines the width of the texture
  29153. * @param height defines the height of the texture
  29154. * @param format defines the format of the data
  29155. * @param generateMipMaps defines if the engine should generate the mip levels
  29156. * @param invertY defines if data must be stored with Y axis inverted
  29157. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29158. * @param compression defines the compression used (null by default)
  29159. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29160. * @returns the raw texture inside an InternalTexture
  29161. */
  29162. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  29163. private _unpackFlipYCached;
  29164. /**
  29165. * In case you are sharing the context with other applications, it might
  29166. * be interested to not cache the unpack flip y state to ensure a consistent
  29167. * value would be set.
  29168. */
  29169. enableUnpackFlipYCached: boolean;
  29170. /** @hidden */
  29171. _unpackFlipY(value: boolean): void;
  29172. /** @hidden */
  29173. _getUnpackAlignement(): number;
  29174. /**
  29175. * Creates a dynamic texture
  29176. * @param width defines the width of the texture
  29177. * @param height defines the height of the texture
  29178. * @param generateMipMaps defines if the engine should generate the mip levels
  29179. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29180. * @returns the dynamic texture inside an InternalTexture
  29181. */
  29182. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29183. /**
  29184. * Update the sampling mode of a given texture
  29185. * @param samplingMode defines the required sampling mode
  29186. * @param texture defines the texture to update
  29187. */
  29188. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29189. /**
  29190. * Update the content of a dynamic texture
  29191. * @param texture defines the texture to update
  29192. * @param canvas defines the canvas containing the source
  29193. * @param invertY defines if data must be stored with Y axis inverted
  29194. * @param premulAlpha defines if alpha is stored as premultiplied
  29195. * @param format defines the format of the data
  29196. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29197. */
  29198. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29199. /**
  29200. * Update a video texture
  29201. * @param texture defines the texture to update
  29202. * @param video defines the video element to use
  29203. * @param invertY defines if data must be stored with Y axis inverted
  29204. */
  29205. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29206. /**
  29207. * Updates a depth texture Comparison Mode and Function.
  29208. * If the comparison Function is equal to 0, the mode will be set to none.
  29209. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29210. * @param texture The texture to set the comparison function for
  29211. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29212. */
  29213. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29214. private _setupDepthStencilTexture;
  29215. /**
  29216. * Creates a depth stencil texture.
  29217. * This is only available in WebGL 2 or with the depth texture extension available.
  29218. * @param size The size of face edge in the texture.
  29219. * @param options The options defining the texture.
  29220. * @returns The texture
  29221. */
  29222. createDepthStencilTexture(size: number | {
  29223. width: number;
  29224. height: number;
  29225. }, options: DepthTextureCreationOptions): InternalTexture;
  29226. /**
  29227. * Creates a depth stencil texture.
  29228. * This is only available in WebGL 2 or with the depth texture extension available.
  29229. * @param size The size of face edge in the texture.
  29230. * @param options The options defining the texture.
  29231. * @returns The texture
  29232. */
  29233. private _createDepthStencilTexture;
  29234. /**
  29235. * Creates a depth stencil cube texture.
  29236. * This is only available in WebGL 2.
  29237. * @param size The size of face edge in the cube texture.
  29238. * @param options The options defining the cube texture.
  29239. * @returns The cube texture
  29240. */
  29241. private _createDepthStencilCubeTexture;
  29242. /**
  29243. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29244. * @param renderTarget The render target to set the frame buffer for
  29245. */
  29246. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29247. /**
  29248. * Creates a new render target texture
  29249. * @param size defines the size of the texture
  29250. * @param options defines the options used to create the texture
  29251. * @returns a new render target texture stored in an InternalTexture
  29252. */
  29253. createRenderTargetTexture(size: number | {
  29254. width: number;
  29255. height: number;
  29256. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29257. /**
  29258. * Create a multi render target texture
  29259. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  29260. * @param size defines the size of the texture
  29261. * @param options defines the creation options
  29262. * @returns the cube texture as an InternalTexture
  29263. */
  29264. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  29265. private _setupFramebufferDepthAttachments;
  29266. /**
  29267. * Updates the sample count of a render target texture
  29268. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29269. * @param texture defines the texture to update
  29270. * @param samples defines the sample count to set
  29271. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29272. */
  29273. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29274. /**
  29275. * Update the sample count for a given multiple render target texture
  29276. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29277. * @param textures defines the textures to update
  29278. * @param samples defines the sample count to set
  29279. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29280. */
  29281. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  29282. /** @hidden */
  29283. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29284. /** @hidden */
  29285. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29286. /** @hidden */
  29287. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29288. /** @hidden */
  29289. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29290. /**
  29291. * Creates a new render target cube texture
  29292. * @param size defines the size of the texture
  29293. * @param options defines the options used to create the texture
  29294. * @returns a new render target cube texture stored in an InternalTexture
  29295. */
  29296. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  29297. /**
  29298. * Creates a cube texture
  29299. * @param rootUrl defines the url where the files to load is located
  29300. * @param scene defines the current scene
  29301. * @param files defines the list of files to load (1 per face)
  29302. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  29303. * @param onLoad defines an optional callback raised when the texture is loaded
  29304. * @param onError defines an optional callback raised if there is an issue to load the texture
  29305. * @param format defines the format of the data
  29306. * @param forcedExtension defines the extension to use to pick the right loader
  29307. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  29308. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  29309. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  29310. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  29311. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  29312. * @returns the cube texture as an InternalTexture
  29313. */
  29314. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  29315. /**
  29316. * @hidden
  29317. */
  29318. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29319. /**
  29320. * Update a raw cube texture
  29321. * @param texture defines the texture to udpdate
  29322. * @param data defines the data to store
  29323. * @param format defines the data format
  29324. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29325. * @param invertY defines if data must be stored with Y axis inverted
  29326. * @param compression defines the compression used (null by default)
  29327. * @param level defines which level of the texture to update
  29328. */
  29329. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  29330. /**
  29331. * Creates a new raw cube texture
  29332. * @param data defines the array of data to use to create each face
  29333. * @param size defines the size of the textures
  29334. * @param format defines the format of the data
  29335. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29336. * @param generateMipMaps defines if the engine should generate the mip levels
  29337. * @param invertY defines if data must be stored with Y axis inverted
  29338. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29339. * @param compression defines the compression used (null by default)
  29340. * @returns the cube texture as an InternalTexture
  29341. */
  29342. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  29343. /**
  29344. * Creates a new raw cube texture from a specified url
  29345. * @param url defines the url where the data is located
  29346. * @param scene defines the current scene
  29347. * @param size defines the size of the textures
  29348. * @param format defines the format of the data
  29349. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29350. * @param noMipmap defines if the engine should avoid generating the mip levels
  29351. * @param callback defines a callback used to extract texture data from loaded data
  29352. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  29353. * @param onLoad defines a callback called when texture is loaded
  29354. * @param onError defines a callback called if there is an error
  29355. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29356. * @param invertY defines if data must be stored with Y axis inverted
  29357. * @returns the cube texture as an InternalTexture
  29358. */
  29359. 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;
  29360. /**
  29361. * Update a raw 3D texture
  29362. * @param texture defines the texture to update
  29363. * @param data defines the data to store
  29364. * @param format defines the data format
  29365. * @param invertY defines if data must be stored with Y axis inverted
  29366. * @param compression defines the used compression (can be null)
  29367. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  29368. */
  29369. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  29370. /**
  29371. * Creates a new raw 3D texture
  29372. * @param data defines the data used to create the texture
  29373. * @param width defines the width of the texture
  29374. * @param height defines the height of the texture
  29375. * @param depth defines the depth of the texture
  29376. * @param format defines the format of the texture
  29377. * @param generateMipMaps defines if the engine must generate mip levels
  29378. * @param invertY defines if data must be stored with Y axis inverted
  29379. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29380. * @param compression defines the compressed used (can be null)
  29381. * @param textureType defines the compressed used (can be null)
  29382. * @returns a new raw 3D texture (stored in an InternalTexture)
  29383. */
  29384. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  29385. private _prepareWebGLTextureContinuation;
  29386. private _prepareWebGLTexture;
  29387. private _convertRGBtoRGBATextureData;
  29388. /** @hidden */
  29389. _releaseFramebufferObjects(texture: InternalTexture): void;
  29390. /** @hidden */
  29391. _releaseTexture(texture: InternalTexture): void;
  29392. private setProgram;
  29393. private _boundUniforms;
  29394. /**
  29395. * Binds an effect to the webGL context
  29396. * @param effect defines the effect to bind
  29397. */
  29398. bindSamplers(effect: Effect): void;
  29399. private _activateCurrentTexture;
  29400. /** @hidden */
  29401. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29402. /** @hidden */
  29403. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29404. /**
  29405. * Sets a texture to the webGL context from a postprocess
  29406. * @param channel defines the channel to use
  29407. * @param postProcess defines the source postprocess
  29408. */
  29409. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29410. /**
  29411. * Binds the output of the passed in post process to the texture channel specified
  29412. * @param channel The channel the texture should be bound to
  29413. * @param postProcess The post process which's output should be bound
  29414. */
  29415. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29416. /**
  29417. * Unbind all textures from the webGL context
  29418. */
  29419. unbindAllTextures(): void;
  29420. /**
  29421. * Sets a texture to the according uniform.
  29422. * @param channel The texture channel
  29423. * @param uniform The uniform to set
  29424. * @param texture The texture to apply
  29425. */
  29426. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29427. /**
  29428. * Sets a depth stencil texture from a render target to the according uniform.
  29429. * @param channel The texture channel
  29430. * @param uniform The uniform to set
  29431. * @param texture The render target texture containing the depth stencil texture to apply
  29432. */
  29433. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29434. private _bindSamplerUniformToChannel;
  29435. private _getTextureWrapMode;
  29436. private _setTexture;
  29437. /**
  29438. * Sets an array of texture to the webGL context
  29439. * @param channel defines the channel where the texture array must be set
  29440. * @param uniform defines the associated uniform location
  29441. * @param textures defines the array of textures to bind
  29442. */
  29443. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29444. /** @hidden */
  29445. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29446. private _setTextureParameterFloat;
  29447. private _setTextureParameterInteger;
  29448. /**
  29449. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29450. * @param x defines the x coordinate of the rectangle where pixels must be read
  29451. * @param y defines the y coordinate of the rectangle where pixels must be read
  29452. * @param width defines the width of the rectangle where pixels must be read
  29453. * @param height defines the height of the rectangle where pixels must be read
  29454. * @returns a Uint8Array containing RGBA colors
  29455. */
  29456. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29457. /**
  29458. * Add an externaly attached data from its key.
  29459. * This method call will fail and return false, if such key already exists.
  29460. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29461. * @param key the unique key that identifies the data
  29462. * @param data the data object to associate to the key for this Engine instance
  29463. * @return true if no such key were already present and the data was added successfully, false otherwise
  29464. */
  29465. addExternalData<T>(key: string, data: T): boolean;
  29466. /**
  29467. * Get an externaly attached data from its key
  29468. * @param key the unique key that identifies the data
  29469. * @return the associated data, if present (can be null), or undefined if not present
  29470. */
  29471. getExternalData<T>(key: string): T;
  29472. /**
  29473. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29474. * @param key the unique key that identifies the data
  29475. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29476. * @return the associated data, can be null if the factory returned null.
  29477. */
  29478. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29479. /**
  29480. * Remove an externaly attached data from the Engine instance
  29481. * @param key the unique key that identifies the data
  29482. * @return true if the data was successfully removed, false if it doesn't exist
  29483. */
  29484. removeExternalData(key: string): boolean;
  29485. /**
  29486. * Unbind all vertex attributes from the webGL context
  29487. */
  29488. unbindAllAttributes(): void;
  29489. /**
  29490. * 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
  29491. */
  29492. releaseEffects(): void;
  29493. /**
  29494. * Dispose and release all associated resources
  29495. */
  29496. dispose(): void;
  29497. /**
  29498. * Display the loading screen
  29499. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29500. */
  29501. displayLoadingUI(): void;
  29502. /**
  29503. * Hide the loading screen
  29504. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29505. */
  29506. hideLoadingUI(): void;
  29507. /**
  29508. * Gets the current loading screen object
  29509. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29510. */
  29511. /**
  29512. * Sets the current loading screen object
  29513. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29514. */
  29515. loadingScreen: ILoadingScreen;
  29516. /**
  29517. * Sets the current loading screen text
  29518. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29519. */
  29520. loadingUIText: string;
  29521. /**
  29522. * Sets the current loading screen background color
  29523. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29524. */
  29525. loadingUIBackgroundColor: string;
  29526. /**
  29527. * Attach a new callback raised when context lost event is fired
  29528. * @param callback defines the callback to call
  29529. */
  29530. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29531. /**
  29532. * Attach a new callback raised when context restored event is fired
  29533. * @param callback defines the callback to call
  29534. */
  29535. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29536. /**
  29537. * Gets the source code of the vertex shader associated with a specific webGL program
  29538. * @param program defines the program to use
  29539. * @returns a string containing the source code of the vertex shader associated with the program
  29540. */
  29541. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29542. /**
  29543. * Gets the source code of the fragment shader associated with a specific webGL program
  29544. * @param program defines the program to use
  29545. * @returns a string containing the source code of the fragment shader associated with the program
  29546. */
  29547. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29548. /**
  29549. * Get the current error code of the webGL context
  29550. * @returns the error code
  29551. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29552. */
  29553. getError(): number;
  29554. /**
  29555. * Gets the current framerate
  29556. * @returns a number representing the framerate
  29557. */
  29558. getFps(): number;
  29559. /**
  29560. * Gets the time spent between current and previous frame
  29561. * @returns a number representing the delta time in ms
  29562. */
  29563. getDeltaTime(): number;
  29564. private _measureFps;
  29565. /** @hidden */
  29566. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29567. private _canRenderToFloatFramebuffer;
  29568. private _canRenderToHalfFloatFramebuffer;
  29569. private _canRenderToFramebuffer;
  29570. /** @hidden */
  29571. _getWebGLTextureType(type: number): number;
  29572. private _getInternalFormat;
  29573. /** @hidden */
  29574. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29575. /** @hidden */
  29576. _getRGBAMultiSampleBufferFormat(type: number): number;
  29577. /** @hidden */
  29578. _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;
  29579. /** @hidden */
  29580. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29581. private _partialLoadFile;
  29582. private _cascadeLoadFiles;
  29583. /**
  29584. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29585. * @returns true if the engine can be created
  29586. * @ignorenaming
  29587. */
  29588. static isSupported(): boolean;
  29589. }
  29590. }
  29591. declare module "babylonjs/Materials/effect" {
  29592. import { Observable } from "babylonjs/Misc/observable";
  29593. import { Nullable } from "babylonjs/types";
  29594. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  29595. import { Engine } from "babylonjs/Engines/engine";
  29596. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29597. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29598. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29599. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29600. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29601. /**
  29602. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29603. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29604. */
  29605. export class EffectFallbacks {
  29606. private _defines;
  29607. private _currentRank;
  29608. private _maxRank;
  29609. private _mesh;
  29610. /**
  29611. * Removes the fallback from the bound mesh.
  29612. */
  29613. unBindMesh(): void;
  29614. /**
  29615. * Adds a fallback on the specified property.
  29616. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29617. * @param define The name of the define in the shader
  29618. */
  29619. addFallback(rank: number, define: string): void;
  29620. /**
  29621. * Sets the mesh to use CPU skinning when needing to fallback.
  29622. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29623. * @param mesh The mesh to use the fallbacks.
  29624. */
  29625. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29626. /**
  29627. * Checks to see if more fallbacks are still availible.
  29628. */
  29629. readonly isMoreFallbacks: boolean;
  29630. /**
  29631. * Removes the defines that shoould be removed when falling back.
  29632. * @param currentDefines defines the current define statements for the shader.
  29633. * @param effect defines the current effect we try to compile
  29634. * @returns The resulting defines with defines of the current rank removed.
  29635. */
  29636. reduce(currentDefines: string, effect: Effect): string;
  29637. }
  29638. /**
  29639. * Options to be used when creating an effect.
  29640. */
  29641. export class EffectCreationOptions {
  29642. /**
  29643. * Atrributes that will be used in the shader.
  29644. */
  29645. attributes: string[];
  29646. /**
  29647. * Uniform varible names that will be set in the shader.
  29648. */
  29649. uniformsNames: string[];
  29650. /**
  29651. * Uniform buffer varible names that will be set in the shader.
  29652. */
  29653. uniformBuffersNames: string[];
  29654. /**
  29655. * Sampler texture variable names that will be set in the shader.
  29656. */
  29657. samplers: string[];
  29658. /**
  29659. * Define statements that will be set in the shader.
  29660. */
  29661. defines: any;
  29662. /**
  29663. * Possible fallbacks for this effect to improve performance when needed.
  29664. */
  29665. fallbacks: Nullable<EffectFallbacks>;
  29666. /**
  29667. * Callback that will be called when the shader is compiled.
  29668. */
  29669. onCompiled: Nullable<(effect: Effect) => void>;
  29670. /**
  29671. * Callback that will be called if an error occurs during shader compilation.
  29672. */
  29673. onError: Nullable<(effect: Effect, errors: string) => void>;
  29674. /**
  29675. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29676. */
  29677. indexParameters: any;
  29678. /**
  29679. * Max number of lights that can be used in the shader.
  29680. */
  29681. maxSimultaneousLights: number;
  29682. /**
  29683. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29684. */
  29685. transformFeedbackVaryings: Nullable<string[]>;
  29686. }
  29687. /**
  29688. * Effect containing vertex and fragment shader that can be executed on an object.
  29689. */
  29690. export class Effect {
  29691. /**
  29692. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29693. */
  29694. static ShadersRepository: string;
  29695. /**
  29696. * Name of the effect.
  29697. */
  29698. name: any;
  29699. /**
  29700. * String container all the define statements that should be set on the shader.
  29701. */
  29702. defines: string;
  29703. /**
  29704. * Callback that will be called when the shader is compiled.
  29705. */
  29706. onCompiled: Nullable<(effect: Effect) => void>;
  29707. /**
  29708. * Callback that will be called if an error occurs during shader compilation.
  29709. */
  29710. onError: Nullable<(effect: Effect, errors: string) => void>;
  29711. /**
  29712. * Callback that will be called when effect is bound.
  29713. */
  29714. onBind: Nullable<(effect: Effect) => void>;
  29715. /**
  29716. * Unique ID of the effect.
  29717. */
  29718. uniqueId: number;
  29719. /**
  29720. * Observable that will be called when the shader is compiled.
  29721. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29722. */
  29723. onCompileObservable: Observable<Effect>;
  29724. /**
  29725. * Observable that will be called if an error occurs during shader compilation.
  29726. */
  29727. onErrorObservable: Observable<Effect>;
  29728. /** @hidden */
  29729. _onBindObservable: Nullable<Observable<Effect>>;
  29730. /**
  29731. * Observable that will be called when effect is bound.
  29732. */
  29733. readonly onBindObservable: Observable<Effect>;
  29734. /** @hidden */
  29735. _bonesComputationForcedToCPU: boolean;
  29736. private static _uniqueIdSeed;
  29737. private _engine;
  29738. private _uniformBuffersNames;
  29739. private _uniformsNames;
  29740. private _samplerList;
  29741. private _samplers;
  29742. private _isReady;
  29743. private _compilationError;
  29744. private _attributesNames;
  29745. private _attributes;
  29746. private _uniforms;
  29747. /**
  29748. * Key for the effect.
  29749. * @hidden
  29750. */
  29751. _key: string;
  29752. private _indexParameters;
  29753. private _fallbacks;
  29754. private _vertexSourceCode;
  29755. private _fragmentSourceCode;
  29756. private _vertexSourceCodeOverride;
  29757. private _fragmentSourceCodeOverride;
  29758. private _transformFeedbackVaryings;
  29759. /**
  29760. * Compiled shader to webGL program.
  29761. * @hidden
  29762. */
  29763. _program: WebGLProgram;
  29764. private _valueCache;
  29765. private static _baseCache;
  29766. /**
  29767. * Instantiates an effect.
  29768. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29769. * @param baseName Name of the effect.
  29770. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29771. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29772. * @param samplers List of sampler variables that will be passed to the shader.
  29773. * @param engine Engine to be used to render the effect
  29774. * @param defines Define statements to be added to the shader.
  29775. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29776. * @param onCompiled Callback that will be called when the shader is compiled.
  29777. * @param onError Callback that will be called if an error occurs during shader compilation.
  29778. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29779. */
  29780. 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);
  29781. /**
  29782. * Unique key for this effect
  29783. */
  29784. readonly key: string;
  29785. /**
  29786. * If the effect has been compiled and prepared.
  29787. * @returns if the effect is compiled and prepared.
  29788. */
  29789. isReady(): boolean;
  29790. /**
  29791. * The engine the effect was initialized with.
  29792. * @returns the engine.
  29793. */
  29794. getEngine(): Engine;
  29795. /**
  29796. * The compiled webGL program for the effect
  29797. * @returns the webGL program.
  29798. */
  29799. getProgram(): WebGLProgram;
  29800. /**
  29801. * The set of names of attribute variables for the shader.
  29802. * @returns An array of attribute names.
  29803. */
  29804. getAttributesNames(): string[];
  29805. /**
  29806. * Returns the attribute at the given index.
  29807. * @param index The index of the attribute.
  29808. * @returns The location of the attribute.
  29809. */
  29810. getAttributeLocation(index: number): number;
  29811. /**
  29812. * Returns the attribute based on the name of the variable.
  29813. * @param name of the attribute to look up.
  29814. * @returns the attribute location.
  29815. */
  29816. getAttributeLocationByName(name: string): number;
  29817. /**
  29818. * The number of attributes.
  29819. * @returns the numnber of attributes.
  29820. */
  29821. getAttributesCount(): number;
  29822. /**
  29823. * Gets the index of a uniform variable.
  29824. * @param uniformName of the uniform to look up.
  29825. * @returns the index.
  29826. */
  29827. getUniformIndex(uniformName: string): number;
  29828. /**
  29829. * Returns the attribute based on the name of the variable.
  29830. * @param uniformName of the uniform to look up.
  29831. * @returns the location of the uniform.
  29832. */
  29833. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29834. /**
  29835. * Returns an array of sampler variable names
  29836. * @returns The array of sampler variable neames.
  29837. */
  29838. getSamplers(): string[];
  29839. /**
  29840. * The error from the last compilation.
  29841. * @returns the error string.
  29842. */
  29843. getCompilationError(): string;
  29844. /**
  29845. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29846. * @param func The callback to be used.
  29847. */
  29848. executeWhenCompiled(func: (effect: Effect) => void): void;
  29849. private _checkIsReady;
  29850. /** @hidden */
  29851. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29852. /** @hidden */
  29853. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29854. /** @hidden */
  29855. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29856. private _processShaderConversion;
  29857. private _processIncludes;
  29858. private _processPrecision;
  29859. /**
  29860. * Recompiles the webGL program
  29861. * @param vertexSourceCode The source code for the vertex shader.
  29862. * @param fragmentSourceCode The source code for the fragment shader.
  29863. * @param onCompiled Callback called when completed.
  29864. * @param onError Callback called on error.
  29865. * @hidden
  29866. */
  29867. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  29868. /**
  29869. * Gets the uniform locations of the the specified variable names
  29870. * @param names THe names of the variables to lookup.
  29871. * @returns Array of locations in the same order as variable names.
  29872. */
  29873. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  29874. /**
  29875. * Prepares the effect
  29876. * @hidden
  29877. */
  29878. _prepareEffect(): void;
  29879. /**
  29880. * Checks if the effect is supported. (Must be called after compilation)
  29881. */
  29882. readonly isSupported: boolean;
  29883. /**
  29884. * Binds a texture to the engine to be used as output of the shader.
  29885. * @param channel Name of the output variable.
  29886. * @param texture Texture to bind.
  29887. * @hidden
  29888. */
  29889. _bindTexture(channel: string, texture: InternalTexture): void;
  29890. /**
  29891. * Sets a texture on the engine to be used in the shader.
  29892. * @param channel Name of the sampler variable.
  29893. * @param texture Texture to set.
  29894. */
  29895. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29896. /**
  29897. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29898. * @param channel Name of the sampler variable.
  29899. * @param texture Texture to set.
  29900. */
  29901. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29902. /**
  29903. * Sets an array of textures on the engine to be used in the shader.
  29904. * @param channel Name of the variable.
  29905. * @param textures Textures to set.
  29906. */
  29907. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29908. /**
  29909. * 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)
  29910. * @param channel Name of the sampler variable.
  29911. * @param postProcess Post process to get the input texture from.
  29912. */
  29913. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29914. /**
  29915. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29916. * 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)
  29917. * @param channel Name of the sampler variable.
  29918. * @param postProcess Post process to get the output texture from.
  29919. */
  29920. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29921. /** @hidden */
  29922. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29923. /** @hidden */
  29924. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29925. /** @hidden */
  29926. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29927. /** @hidden */
  29928. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29929. /**
  29930. * Binds a buffer to a uniform.
  29931. * @param buffer Buffer to bind.
  29932. * @param name Name of the uniform variable to bind to.
  29933. */
  29934. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  29935. /**
  29936. * Binds block to a uniform.
  29937. * @param blockName Name of the block to bind.
  29938. * @param index Index to bind.
  29939. */
  29940. bindUniformBlock(blockName: string, index: number): void;
  29941. /**
  29942. * Sets an interger value on a uniform variable.
  29943. * @param uniformName Name of the variable.
  29944. * @param value Value to be set.
  29945. * @returns this effect.
  29946. */
  29947. setInt(uniformName: string, value: number): Effect;
  29948. /**
  29949. * Sets an int array on a uniform variable.
  29950. * @param uniformName Name of the variable.
  29951. * @param array array to be set.
  29952. * @returns this effect.
  29953. */
  29954. setIntArray(uniformName: string, array: Int32Array): Effect;
  29955. /**
  29956. * 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)
  29957. * @param uniformName Name of the variable.
  29958. * @param array array to be set.
  29959. * @returns this effect.
  29960. */
  29961. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29962. /**
  29963. * 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)
  29964. * @param uniformName Name of the variable.
  29965. * @param array array to be set.
  29966. * @returns this effect.
  29967. */
  29968. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29969. /**
  29970. * 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)
  29971. * @param uniformName Name of the variable.
  29972. * @param array array to be set.
  29973. * @returns this effect.
  29974. */
  29975. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29976. /**
  29977. * Sets an float array on a uniform variable.
  29978. * @param uniformName Name of the variable.
  29979. * @param array array to be set.
  29980. * @returns this effect.
  29981. */
  29982. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29983. /**
  29984. * 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)
  29985. * @param uniformName Name of the variable.
  29986. * @param array array to be set.
  29987. * @returns this effect.
  29988. */
  29989. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29990. /**
  29991. * 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)
  29992. * @param uniformName Name of the variable.
  29993. * @param array array to be set.
  29994. * @returns this effect.
  29995. */
  29996. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29997. /**
  29998. * 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)
  29999. * @param uniformName Name of the variable.
  30000. * @param array array to be set.
  30001. * @returns this effect.
  30002. */
  30003. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30004. /**
  30005. * Sets an array on a uniform variable.
  30006. * @param uniformName Name of the variable.
  30007. * @param array array to be set.
  30008. * @returns this effect.
  30009. */
  30010. setArray(uniformName: string, array: number[]): Effect;
  30011. /**
  30012. * 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)
  30013. * @param uniformName Name of the variable.
  30014. * @param array array to be set.
  30015. * @returns this effect.
  30016. */
  30017. setArray2(uniformName: string, array: number[]): Effect;
  30018. /**
  30019. * 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)
  30020. * @param uniformName Name of the variable.
  30021. * @param array array to be set.
  30022. * @returns this effect.
  30023. */
  30024. setArray3(uniformName: string, array: number[]): Effect;
  30025. /**
  30026. * 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)
  30027. * @param uniformName Name of the variable.
  30028. * @param array array to be set.
  30029. * @returns this effect.
  30030. */
  30031. setArray4(uniformName: string, array: number[]): Effect;
  30032. /**
  30033. * Sets matrices on a uniform variable.
  30034. * @param uniformName Name of the variable.
  30035. * @param matrices matrices to be set.
  30036. * @returns this effect.
  30037. */
  30038. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30039. /**
  30040. * Sets matrix on a uniform variable.
  30041. * @param uniformName Name of the variable.
  30042. * @param matrix matrix to be set.
  30043. * @returns this effect.
  30044. */
  30045. setMatrix(uniformName: string, matrix: Matrix): Effect;
  30046. /**
  30047. * 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)
  30048. * @param uniformName Name of the variable.
  30049. * @param matrix matrix to be set.
  30050. * @returns this effect.
  30051. */
  30052. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30053. /**
  30054. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30055. * @param uniformName Name of the variable.
  30056. * @param matrix matrix to be set.
  30057. * @returns this effect.
  30058. */
  30059. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30060. /**
  30061. * Sets a float on a uniform variable.
  30062. * @param uniformName Name of the variable.
  30063. * @param value value to be set.
  30064. * @returns this effect.
  30065. */
  30066. setFloat(uniformName: string, value: number): Effect;
  30067. /**
  30068. * Sets a boolean on a uniform variable.
  30069. * @param uniformName Name of the variable.
  30070. * @param bool value to be set.
  30071. * @returns this effect.
  30072. */
  30073. setBool(uniformName: string, bool: boolean): Effect;
  30074. /**
  30075. * Sets a Vector2 on a uniform variable.
  30076. * @param uniformName Name of the variable.
  30077. * @param vector2 vector2 to be set.
  30078. * @returns this effect.
  30079. */
  30080. setVector2(uniformName: string, vector2: Vector2): Effect;
  30081. /**
  30082. * Sets a float2 on a uniform variable.
  30083. * @param uniformName Name of the variable.
  30084. * @param x First float in float2.
  30085. * @param y Second float in float2.
  30086. * @returns this effect.
  30087. */
  30088. setFloat2(uniformName: string, x: number, y: number): Effect;
  30089. /**
  30090. * Sets a Vector3 on a uniform variable.
  30091. * @param uniformName Name of the variable.
  30092. * @param vector3 Value to be set.
  30093. * @returns this effect.
  30094. */
  30095. setVector3(uniformName: string, vector3: Vector3): Effect;
  30096. /**
  30097. * Sets a float3 on a uniform variable.
  30098. * @param uniformName Name of the variable.
  30099. * @param x First float in float3.
  30100. * @param y Second float in float3.
  30101. * @param z Third float in float3.
  30102. * @returns this effect.
  30103. */
  30104. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30105. /**
  30106. * Sets a Vector4 on a uniform variable.
  30107. * @param uniformName Name of the variable.
  30108. * @param vector4 Value to be set.
  30109. * @returns this effect.
  30110. */
  30111. setVector4(uniformName: string, vector4: Vector4): Effect;
  30112. /**
  30113. * Sets a float4 on a uniform variable.
  30114. * @param uniformName Name of the variable.
  30115. * @param x First float in float4.
  30116. * @param y Second float in float4.
  30117. * @param z Third float in float4.
  30118. * @param w Fourth float in float4.
  30119. * @returns this effect.
  30120. */
  30121. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30122. /**
  30123. * Sets a Color3 on a uniform variable.
  30124. * @param uniformName Name of the variable.
  30125. * @param color3 Value to be set.
  30126. * @returns this effect.
  30127. */
  30128. setColor3(uniformName: string, color3: Color3): Effect;
  30129. /**
  30130. * Sets a Color4 on a uniform variable.
  30131. * @param uniformName Name of the variable.
  30132. * @param color3 Value to be set.
  30133. * @param alpha Alpha value to be set.
  30134. * @returns this effect.
  30135. */
  30136. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  30137. /**
  30138. * Sets a Color4 on a uniform variable
  30139. * @param uniformName defines the name of the variable
  30140. * @param color4 defines the value to be set
  30141. * @returns this effect.
  30142. */
  30143. setDirectColor4(uniformName: string, color4: Color4): Effect;
  30144. /**
  30145. * This function will add a new shader to the shader store
  30146. * @param name the name of the shader
  30147. * @param pixelShader optional pixel shader content
  30148. * @param vertexShader optional vertex shader content
  30149. */
  30150. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30151. /**
  30152. * Store of each shader (The can be looked up using effect.key)
  30153. */
  30154. static ShadersStore: {
  30155. [key: string]: string;
  30156. };
  30157. /**
  30158. * Store of each included file for a shader (The can be looked up using effect.key)
  30159. */
  30160. static IncludesShadersStore: {
  30161. [key: string]: string;
  30162. };
  30163. /**
  30164. * Resets the cache of effects.
  30165. */
  30166. static ResetCache(): void;
  30167. }
  30168. }
  30169. declare module "babylonjs/Materials/colorCurves" {
  30170. import { Effect } from "babylonjs/Materials/effect";
  30171. /**
  30172. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30173. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30174. * 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;
  30175. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30176. */
  30177. export class ColorCurves {
  30178. private _dirty;
  30179. private _tempColor;
  30180. private _globalCurve;
  30181. private _highlightsCurve;
  30182. private _midtonesCurve;
  30183. private _shadowsCurve;
  30184. private _positiveCurve;
  30185. private _negativeCurve;
  30186. private _globalHue;
  30187. private _globalDensity;
  30188. private _globalSaturation;
  30189. private _globalExposure;
  30190. /**
  30191. * Gets the global Hue value.
  30192. * 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).
  30193. */
  30194. /**
  30195. * Sets the global Hue value.
  30196. * 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).
  30197. */
  30198. globalHue: number;
  30199. /**
  30200. * Gets the global Density value.
  30201. * 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.
  30202. * Values less than zero provide a filter of opposite hue.
  30203. */
  30204. /**
  30205. * Sets the global Density value.
  30206. * 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.
  30207. * Values less than zero provide a filter of opposite hue.
  30208. */
  30209. globalDensity: number;
  30210. /**
  30211. * Gets the global Saturation value.
  30212. * 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.
  30213. */
  30214. /**
  30215. * Sets the global Saturation value.
  30216. * 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.
  30217. */
  30218. globalSaturation: number;
  30219. /**
  30220. * Gets the global Exposure value.
  30221. * 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.
  30222. */
  30223. /**
  30224. * Sets the global Exposure value.
  30225. * 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.
  30226. */
  30227. globalExposure: number;
  30228. private _highlightsHue;
  30229. private _highlightsDensity;
  30230. private _highlightsSaturation;
  30231. private _highlightsExposure;
  30232. /**
  30233. * Gets the highlights Hue value.
  30234. * 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).
  30235. */
  30236. /**
  30237. * Sets the highlights Hue value.
  30238. * 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).
  30239. */
  30240. highlightsHue: number;
  30241. /**
  30242. * Gets the highlights Density value.
  30243. * 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.
  30244. * Values less than zero provide a filter of opposite hue.
  30245. */
  30246. /**
  30247. * Sets the highlights Density value.
  30248. * 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.
  30249. * Values less than zero provide a filter of opposite hue.
  30250. */
  30251. highlightsDensity: number;
  30252. /**
  30253. * Gets the highlights Saturation value.
  30254. * 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.
  30255. */
  30256. /**
  30257. * Sets the highlights Saturation value.
  30258. * 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.
  30259. */
  30260. highlightsSaturation: number;
  30261. /**
  30262. * Gets the highlights Exposure value.
  30263. * 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.
  30264. */
  30265. /**
  30266. * Sets the highlights Exposure value.
  30267. * 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.
  30268. */
  30269. highlightsExposure: number;
  30270. private _midtonesHue;
  30271. private _midtonesDensity;
  30272. private _midtonesSaturation;
  30273. private _midtonesExposure;
  30274. /**
  30275. * Gets the midtones Hue value.
  30276. * 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).
  30277. */
  30278. /**
  30279. * Sets the midtones Hue value.
  30280. * 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).
  30281. */
  30282. midtonesHue: number;
  30283. /**
  30284. * Gets the midtones Density value.
  30285. * 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.
  30286. * Values less than zero provide a filter of opposite hue.
  30287. */
  30288. /**
  30289. * Sets the midtones Density value.
  30290. * 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.
  30291. * Values less than zero provide a filter of opposite hue.
  30292. */
  30293. midtonesDensity: number;
  30294. /**
  30295. * Gets the midtones Saturation value.
  30296. * 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.
  30297. */
  30298. /**
  30299. * Sets the midtones Saturation value.
  30300. * 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.
  30301. */
  30302. midtonesSaturation: number;
  30303. /**
  30304. * Gets the midtones Exposure value.
  30305. * 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.
  30306. */
  30307. /**
  30308. * Sets the midtones Exposure value.
  30309. * 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.
  30310. */
  30311. midtonesExposure: number;
  30312. private _shadowsHue;
  30313. private _shadowsDensity;
  30314. private _shadowsSaturation;
  30315. private _shadowsExposure;
  30316. /**
  30317. * Gets the shadows Hue value.
  30318. * 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).
  30319. */
  30320. /**
  30321. * Sets the shadows Hue value.
  30322. * 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).
  30323. */
  30324. shadowsHue: number;
  30325. /**
  30326. * Gets the shadows 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. /**
  30331. * Sets the shadows Density value.
  30332. * 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.
  30333. * Values less than zero provide a filter of opposite hue.
  30334. */
  30335. shadowsDensity: number;
  30336. /**
  30337. * Gets the shadows Saturation value.
  30338. * 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.
  30339. */
  30340. /**
  30341. * Sets the shadows Saturation 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 saturation and negative values decrease saturation.
  30343. */
  30344. shadowsSaturation: number;
  30345. /**
  30346. * Gets the shadows Exposure value.
  30347. * 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.
  30348. */
  30349. /**
  30350. * Sets the shadows Exposure value.
  30351. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  30352. */
  30353. shadowsExposure: number;
  30354. /**
  30355. * Returns the class name
  30356. * @returns The class name
  30357. */
  30358. getClassName(): string;
  30359. /**
  30360. * Binds the color curves to the shader.
  30361. * @param colorCurves The color curve to bind
  30362. * @param effect The effect to bind to
  30363. * @param positiveUniform The positive uniform shader parameter
  30364. * @param neutralUniform The neutral uniform shader parameter
  30365. * @param negativeUniform The negative uniform shader parameter
  30366. */
  30367. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30368. /**
  30369. * Prepare the list of uniforms associated with the ColorCurves effects.
  30370. * @param uniformsList The list of uniforms used in the effect
  30371. */
  30372. static PrepareUniforms(uniformsList: string[]): void;
  30373. /**
  30374. * Returns color grading data based on a hue, density, saturation and exposure value.
  30375. * @param filterHue The hue of the color filter.
  30376. * @param filterDensity The density of the color filter.
  30377. * @param saturation The saturation.
  30378. * @param exposure The exposure.
  30379. * @param result The result data container.
  30380. */
  30381. private getColorGradingDataToRef;
  30382. /**
  30383. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30384. * @param value The input slider value in range [-100,100].
  30385. * @returns Adjusted value.
  30386. */
  30387. private static applyColorGradingSliderNonlinear;
  30388. /**
  30389. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30390. * @param hue The hue (H) input.
  30391. * @param saturation The saturation (S) input.
  30392. * @param brightness The brightness (B) input.
  30393. * @result An RGBA color represented as Vector4.
  30394. */
  30395. private static fromHSBToRef;
  30396. /**
  30397. * Returns a value clamped between min and max
  30398. * @param value The value to clamp
  30399. * @param min The minimum of value
  30400. * @param max The maximum of value
  30401. * @returns The clamped value.
  30402. */
  30403. private static clamp;
  30404. /**
  30405. * Clones the current color curve instance.
  30406. * @return The cloned curves
  30407. */
  30408. clone(): ColorCurves;
  30409. /**
  30410. * Serializes the current color curve instance to a json representation.
  30411. * @return a JSON representation
  30412. */
  30413. serialize(): any;
  30414. /**
  30415. * Parses the color curve from a json representation.
  30416. * @param source the JSON source to parse
  30417. * @return The parsed curves
  30418. */
  30419. static Parse(source: any): ColorCurves;
  30420. }
  30421. }
  30422. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  30423. import { Observable } from "babylonjs/Misc/observable";
  30424. import { Nullable } from "babylonjs/types";
  30425. import { Color4 } from "babylonjs/Maths/math";
  30426. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30427. import { Effect } from "babylonjs/Materials/effect";
  30428. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30429. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30430. /**
  30431. * Interface to follow in your material defines to integrate easily the
  30432. * Image proccessing functions.
  30433. * @hidden
  30434. */
  30435. export interface IImageProcessingConfigurationDefines {
  30436. IMAGEPROCESSING: boolean;
  30437. VIGNETTE: boolean;
  30438. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30439. VIGNETTEBLENDMODEOPAQUE: boolean;
  30440. TONEMAPPING: boolean;
  30441. TONEMAPPING_ACES: boolean;
  30442. CONTRAST: boolean;
  30443. EXPOSURE: boolean;
  30444. COLORCURVES: boolean;
  30445. COLORGRADING: boolean;
  30446. COLORGRADING3D: boolean;
  30447. SAMPLER3DGREENDEPTH: boolean;
  30448. SAMPLER3DBGRMAP: boolean;
  30449. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30450. }
  30451. /**
  30452. * @hidden
  30453. */
  30454. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30455. IMAGEPROCESSING: boolean;
  30456. VIGNETTE: boolean;
  30457. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30458. VIGNETTEBLENDMODEOPAQUE: boolean;
  30459. TONEMAPPING: boolean;
  30460. TONEMAPPING_ACES: boolean;
  30461. CONTRAST: boolean;
  30462. COLORCURVES: boolean;
  30463. COLORGRADING: boolean;
  30464. COLORGRADING3D: boolean;
  30465. SAMPLER3DGREENDEPTH: boolean;
  30466. SAMPLER3DBGRMAP: boolean;
  30467. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30468. EXPOSURE: boolean;
  30469. constructor();
  30470. }
  30471. /**
  30472. * This groups together the common properties used for image processing either in direct forward pass
  30473. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30474. * or not.
  30475. */
  30476. export class ImageProcessingConfiguration {
  30477. /**
  30478. * Default tone mapping applied in BabylonJS.
  30479. */
  30480. static readonly TONEMAPPING_STANDARD: number;
  30481. /**
  30482. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30483. * to other engines rendering to increase portability.
  30484. */
  30485. static readonly TONEMAPPING_ACES: number;
  30486. /**
  30487. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30488. */
  30489. colorCurves: Nullable<ColorCurves>;
  30490. private _colorCurvesEnabled;
  30491. /**
  30492. * Gets wether the color curves effect is enabled.
  30493. */
  30494. /**
  30495. * Sets wether the color curves effect is enabled.
  30496. */
  30497. colorCurvesEnabled: boolean;
  30498. private _colorGradingTexture;
  30499. /**
  30500. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30501. */
  30502. /**
  30503. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30504. */
  30505. colorGradingTexture: Nullable<BaseTexture>;
  30506. private _colorGradingEnabled;
  30507. /**
  30508. * Gets wether the color grading effect is enabled.
  30509. */
  30510. /**
  30511. * Sets wether the color grading effect is enabled.
  30512. */
  30513. colorGradingEnabled: boolean;
  30514. private _colorGradingWithGreenDepth;
  30515. /**
  30516. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30517. */
  30518. /**
  30519. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30520. */
  30521. colorGradingWithGreenDepth: boolean;
  30522. private _colorGradingBGR;
  30523. /**
  30524. * Gets wether the color grading texture contains BGR values.
  30525. */
  30526. /**
  30527. * Sets wether the color grading texture contains BGR values.
  30528. */
  30529. colorGradingBGR: boolean;
  30530. /** @hidden */
  30531. _exposure: number;
  30532. /**
  30533. * Gets the Exposure used in the effect.
  30534. */
  30535. /**
  30536. * Sets the Exposure used in the effect.
  30537. */
  30538. exposure: number;
  30539. private _toneMappingEnabled;
  30540. /**
  30541. * Gets wether the tone mapping effect is enabled.
  30542. */
  30543. /**
  30544. * Sets wether the tone mapping effect is enabled.
  30545. */
  30546. toneMappingEnabled: boolean;
  30547. private _toneMappingType;
  30548. /**
  30549. * Gets the type of tone mapping effect.
  30550. */
  30551. /**
  30552. * Sets the type of tone mapping effect used in BabylonJS.
  30553. */
  30554. toneMappingType: number;
  30555. protected _contrast: number;
  30556. /**
  30557. * Gets the contrast used in the effect.
  30558. */
  30559. /**
  30560. * Sets the contrast used in the effect.
  30561. */
  30562. contrast: number;
  30563. /**
  30564. * Vignette stretch size.
  30565. */
  30566. vignetteStretch: number;
  30567. /**
  30568. * Vignette centre X Offset.
  30569. */
  30570. vignetteCentreX: number;
  30571. /**
  30572. * Vignette centre Y Offset.
  30573. */
  30574. vignetteCentreY: number;
  30575. /**
  30576. * Vignette weight or intensity of the vignette effect.
  30577. */
  30578. vignetteWeight: number;
  30579. /**
  30580. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30581. * if vignetteEnabled is set to true.
  30582. */
  30583. vignetteColor: Color4;
  30584. /**
  30585. * Camera field of view used by the Vignette effect.
  30586. */
  30587. vignetteCameraFov: number;
  30588. private _vignetteBlendMode;
  30589. /**
  30590. * Gets the vignette blend mode allowing different kind of effect.
  30591. */
  30592. /**
  30593. * Sets the vignette blend mode allowing different kind of effect.
  30594. */
  30595. vignetteBlendMode: number;
  30596. private _vignetteEnabled;
  30597. /**
  30598. * Gets wether the vignette effect is enabled.
  30599. */
  30600. /**
  30601. * Sets wether the vignette effect is enabled.
  30602. */
  30603. vignetteEnabled: boolean;
  30604. private _applyByPostProcess;
  30605. /**
  30606. * Gets wether the image processing is applied through a post process or not.
  30607. */
  30608. /**
  30609. * Sets wether the image processing is applied through a post process or not.
  30610. */
  30611. applyByPostProcess: boolean;
  30612. private _isEnabled;
  30613. /**
  30614. * Gets wether the image processing is enabled or not.
  30615. */
  30616. /**
  30617. * Sets wether the image processing is enabled or not.
  30618. */
  30619. isEnabled: boolean;
  30620. /**
  30621. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30622. */
  30623. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30624. /**
  30625. * Method called each time the image processing information changes requires to recompile the effect.
  30626. */
  30627. protected _updateParameters(): void;
  30628. /**
  30629. * Gets the current class name.
  30630. * @return "ImageProcessingConfiguration"
  30631. */
  30632. getClassName(): string;
  30633. /**
  30634. * Prepare the list of uniforms associated with the Image Processing effects.
  30635. * @param uniforms The list of uniforms used in the effect
  30636. * @param defines the list of defines currently in use
  30637. */
  30638. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30639. /**
  30640. * Prepare the list of samplers associated with the Image Processing effects.
  30641. * @param samplersList The list of uniforms used in the effect
  30642. * @param defines the list of defines currently in use
  30643. */
  30644. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30645. /**
  30646. * Prepare the list of defines associated to the shader.
  30647. * @param defines the list of defines to complete
  30648. * @param forPostProcess Define if we are currently in post process mode or not
  30649. */
  30650. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30651. /**
  30652. * Returns true if all the image processing information are ready.
  30653. * @returns True if ready, otherwise, false
  30654. */
  30655. isReady(): boolean;
  30656. /**
  30657. * Binds the image processing to the shader.
  30658. * @param effect The effect to bind to
  30659. * @param aspectRatio Define the current aspect ratio of the effect
  30660. */
  30661. bind(effect: Effect, aspectRatio?: number): void;
  30662. /**
  30663. * Clones the current image processing instance.
  30664. * @return The cloned image processing
  30665. */
  30666. clone(): ImageProcessingConfiguration;
  30667. /**
  30668. * Serializes the current image processing instance to a json representation.
  30669. * @return a JSON representation
  30670. */
  30671. serialize(): any;
  30672. /**
  30673. * Parses the image processing from a json representation.
  30674. * @param source the JSON source to parse
  30675. * @return The parsed image processing
  30676. */
  30677. static Parse(source: any): ImageProcessingConfiguration;
  30678. private static _VIGNETTEMODE_MULTIPLY;
  30679. private static _VIGNETTEMODE_OPAQUE;
  30680. /**
  30681. * Used to apply the vignette as a mix with the pixel color.
  30682. */
  30683. static readonly VIGNETTEMODE_MULTIPLY: number;
  30684. /**
  30685. * Used to apply the vignette as a replacement of the pixel color.
  30686. */
  30687. static readonly VIGNETTEMODE_OPAQUE: number;
  30688. }
  30689. }
  30690. declare module "babylonjs/Materials/fresnelParameters" {
  30691. import { Color3 } from "babylonjs/Maths/math";
  30692. /**
  30693. * This represents all the required information to add a fresnel effect on a material:
  30694. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30695. */
  30696. export class FresnelParameters {
  30697. private _isEnabled;
  30698. /**
  30699. * Define if the fresnel effect is enable or not.
  30700. */
  30701. isEnabled: boolean;
  30702. /**
  30703. * Define the color used on edges (grazing angle)
  30704. */
  30705. leftColor: Color3;
  30706. /**
  30707. * Define the color used on center
  30708. */
  30709. rightColor: Color3;
  30710. /**
  30711. * Define bias applied to computed fresnel term
  30712. */
  30713. bias: number;
  30714. /**
  30715. * Defined the power exponent applied to fresnel term
  30716. */
  30717. power: number;
  30718. /**
  30719. * Clones the current fresnel and its valuues
  30720. * @returns a clone fresnel configuration
  30721. */
  30722. clone(): FresnelParameters;
  30723. /**
  30724. * Serializes the current fresnel parameters to a JSON representation.
  30725. * @return the JSON serialization
  30726. */
  30727. serialize(): any;
  30728. /**
  30729. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30730. * @param parsedFresnelParameters Define the JSON representation
  30731. * @returns the parsed parameters
  30732. */
  30733. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30734. }
  30735. }
  30736. declare module "babylonjs/Misc/decorators" {
  30737. import { Nullable } from "babylonjs/types";
  30738. import { Scene } from "babylonjs/scene";
  30739. import { IAnimatable } from "babylonjs/Misc/tools";
  30740. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30741. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30742. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30743. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30744. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30745. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30746. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30747. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30748. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30749. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30750. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30751. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30752. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30753. /**
  30754. * Decorator used to define property that can be serialized as reference to a camera
  30755. * @param sourceName defines the name of the property to decorate
  30756. */
  30757. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30758. /**
  30759. * Class used to help serialization objects
  30760. */
  30761. export class SerializationHelper {
  30762. /** hidden */
  30763. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30764. /** hidden */
  30765. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30766. /** hidden */
  30767. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30768. /** hidden */
  30769. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30770. /**
  30771. * Appends the serialized animations from the source animations
  30772. * @param source Source containing the animations
  30773. * @param destination Target to store the animations
  30774. */
  30775. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30776. /**
  30777. * Static function used to serialized a specific entity
  30778. * @param entity defines the entity to serialize
  30779. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30780. * @returns a JSON compatible object representing the serialization of the entity
  30781. */
  30782. static Serialize<T>(entity: T, serializationObject?: any): any;
  30783. /**
  30784. * Creates a new entity from a serialization data object
  30785. * @param creationFunction defines a function used to instanciated the new entity
  30786. * @param source defines the source serialization data
  30787. * @param scene defines the hosting scene
  30788. * @param rootUrl defines the root url for resources
  30789. * @returns a new entity
  30790. */
  30791. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30792. /**
  30793. * Clones an object
  30794. * @param creationFunction defines the function used to instanciate the new object
  30795. * @param source defines the source object
  30796. * @returns the cloned object
  30797. */
  30798. static Clone<T>(creationFunction: () => T, source: T): T;
  30799. /**
  30800. * Instanciates a new object based on a source one (some data will be shared between both object)
  30801. * @param creationFunction defines the function used to instanciate the new object
  30802. * @param source defines the source object
  30803. * @returns the new object
  30804. */
  30805. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30806. }
  30807. }
  30808. declare module "babylonjs/Cameras/camera" {
  30809. import { SmartArray } from "babylonjs/Misc/smartArray";
  30810. import { Observable } from "babylonjs/Misc/observable";
  30811. import { Nullable } from "babylonjs/types";
  30812. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30813. import { Scene } from "babylonjs/scene";
  30814. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  30815. import { Node } from "babylonjs/node";
  30816. import { Mesh } from "babylonjs/Meshes/mesh";
  30817. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30818. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30819. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30820. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30821. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30822. import { Ray } from "babylonjs/Culling/ray";
  30823. /**
  30824. * This is the base class of all the camera used in the application.
  30825. * @see http://doc.babylonjs.com/features/cameras
  30826. */
  30827. export class Camera extends Node {
  30828. /** @hidden */
  30829. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30830. /**
  30831. * This is the default projection mode used by the cameras.
  30832. * It helps recreating a feeling of perspective and better appreciate depth.
  30833. * This is the best way to simulate real life cameras.
  30834. */
  30835. static readonly PERSPECTIVE_CAMERA: number;
  30836. /**
  30837. * This helps creating camera with an orthographic mode.
  30838. * 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.
  30839. */
  30840. static readonly ORTHOGRAPHIC_CAMERA: number;
  30841. /**
  30842. * This is the default FOV mode for perspective cameras.
  30843. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30844. */
  30845. static readonly FOVMODE_VERTICAL_FIXED: number;
  30846. /**
  30847. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30848. */
  30849. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30850. /**
  30851. * This specifies ther is no need for a camera rig.
  30852. * Basically only one eye is rendered corresponding to the camera.
  30853. */
  30854. static readonly RIG_MODE_NONE: number;
  30855. /**
  30856. * Simulates a camera Rig with one blue eye and one red eye.
  30857. * This can be use with 3d blue and red glasses.
  30858. */
  30859. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30860. /**
  30861. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30862. */
  30863. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30864. /**
  30865. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30866. */
  30867. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30868. /**
  30869. * Defines that both eyes of the camera will be rendered over under each other.
  30870. */
  30871. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30872. /**
  30873. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30874. */
  30875. static readonly RIG_MODE_VR: number;
  30876. /**
  30877. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30878. */
  30879. static readonly RIG_MODE_WEBVR: number;
  30880. /**
  30881. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30882. */
  30883. static readonly RIG_MODE_CUSTOM: number;
  30884. /**
  30885. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30886. */
  30887. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30888. /**
  30889. * Define the input manager associated with the camera.
  30890. */
  30891. inputs: CameraInputsManager<Camera>;
  30892. /** @hidden */
  30893. _position: Vector3;
  30894. /**
  30895. * Define the current local position of the camera in the scene
  30896. */
  30897. position: Vector3;
  30898. /**
  30899. * The vector the camera should consider as up.
  30900. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30901. */
  30902. upVector: Vector3;
  30903. /**
  30904. * Define the current limit on the left side for an orthographic camera
  30905. * In scene unit
  30906. */
  30907. orthoLeft: Nullable<number>;
  30908. /**
  30909. * Define the current limit on the right side for an orthographic camera
  30910. * In scene unit
  30911. */
  30912. orthoRight: Nullable<number>;
  30913. /**
  30914. * Define the current limit on the bottom side for an orthographic camera
  30915. * In scene unit
  30916. */
  30917. orthoBottom: Nullable<number>;
  30918. /**
  30919. * Define the current limit on the top side for an orthographic camera
  30920. * In scene unit
  30921. */
  30922. orthoTop: Nullable<number>;
  30923. /**
  30924. * Field Of View is set in Radians. (default is 0.8)
  30925. */
  30926. fov: number;
  30927. /**
  30928. * Define the minimum distance the camera can see from.
  30929. * This is important to note that the depth buffer are not infinite and the closer it starts
  30930. * the more your scene might encounter depth fighting issue.
  30931. */
  30932. minZ: number;
  30933. /**
  30934. * Define the maximum distance the camera can see to.
  30935. * This is important to note that the depth buffer are not infinite and the further it end
  30936. * the more your scene might encounter depth fighting issue.
  30937. */
  30938. maxZ: number;
  30939. /**
  30940. * Define the default inertia of the camera.
  30941. * This helps giving a smooth feeling to the camera movement.
  30942. */
  30943. inertia: number;
  30944. /**
  30945. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30946. */
  30947. mode: number;
  30948. /**
  30949. * Define wether the camera is intermediate.
  30950. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30951. */
  30952. isIntermediate: boolean;
  30953. /**
  30954. * Define the viewport of the camera.
  30955. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30956. */
  30957. viewport: Viewport;
  30958. /**
  30959. * Restricts the camera to viewing objects with the same layerMask.
  30960. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30961. */
  30962. layerMask: number;
  30963. /**
  30964. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30965. */
  30966. fovMode: number;
  30967. /**
  30968. * Rig mode of the camera.
  30969. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30970. * This is normally controlled byt the camera themselves as internal use.
  30971. */
  30972. cameraRigMode: number;
  30973. /**
  30974. * Defines the distance between both "eyes" in case of a RIG
  30975. */
  30976. interaxialDistance: number;
  30977. /**
  30978. * Defines if stereoscopic rendering is done side by side or over under.
  30979. */
  30980. isStereoscopicSideBySide: boolean;
  30981. /**
  30982. * 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
  30983. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30984. * else in the scene.
  30985. */
  30986. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30987. /**
  30988. * When set, the camera will render to this render target instead of the default canvas
  30989. */
  30990. outputRenderTarget: Nullable<RenderTargetTexture>;
  30991. /**
  30992. * Observable triggered when the camera view matrix has changed.
  30993. */
  30994. onViewMatrixChangedObservable: Observable<Camera>;
  30995. /**
  30996. * Observable triggered when the camera Projection matrix has changed.
  30997. */
  30998. onProjectionMatrixChangedObservable: Observable<Camera>;
  30999. /**
  31000. * Observable triggered when the inputs have been processed.
  31001. */
  31002. onAfterCheckInputsObservable: Observable<Camera>;
  31003. /**
  31004. * Observable triggered when reset has been called and applied to the camera.
  31005. */
  31006. onRestoreStateObservable: Observable<Camera>;
  31007. /** @hidden */
  31008. _cameraRigParams: any;
  31009. /** @hidden */
  31010. _rigCameras: Camera[];
  31011. /** @hidden */
  31012. _rigPostProcess: Nullable<PostProcess>;
  31013. protected _webvrViewMatrix: Matrix;
  31014. /** @hidden */
  31015. _skipRendering: boolean;
  31016. /** @hidden */
  31017. _projectionMatrix: Matrix;
  31018. /** @hidden */
  31019. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  31020. /** @hidden */
  31021. _activeMeshes: SmartArray<AbstractMesh>;
  31022. protected _globalPosition: Vector3;
  31023. /** hidden */
  31024. _computedViewMatrix: Matrix;
  31025. private _doNotComputeProjectionMatrix;
  31026. private _transformMatrix;
  31027. private _frustumPlanes;
  31028. private _refreshFrustumPlanes;
  31029. private _storedFov;
  31030. private _stateStored;
  31031. /**
  31032. * Instantiates a new camera object.
  31033. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  31034. * @see http://doc.babylonjs.com/features/cameras
  31035. * @param name Defines the name of the camera in the scene
  31036. * @param position Defines the position of the camera
  31037. * @param scene Defines the scene the camera belongs too
  31038. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  31039. */
  31040. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  31041. /**
  31042. * Store current camera state (fov, position, etc..)
  31043. * @returns the camera
  31044. */
  31045. storeState(): Camera;
  31046. /**
  31047. * Restores the camera state values if it has been stored. You must call storeState() first
  31048. */
  31049. protected _restoreStateValues(): boolean;
  31050. /**
  31051. * Restored camera state. You must call storeState() first.
  31052. * @returns true if restored and false otherwise
  31053. */
  31054. restoreState(): boolean;
  31055. /**
  31056. * Gets the class name of the camera.
  31057. * @returns the class name
  31058. */
  31059. getClassName(): string;
  31060. /** @hidden */
  31061. readonly _isCamera: boolean;
  31062. /**
  31063. * Gets a string representation of the camera useful for debug purpose.
  31064. * @param fullDetails Defines that a more verboe level of logging is required
  31065. * @returns the string representation
  31066. */
  31067. toString(fullDetails?: boolean): string;
  31068. /**
  31069. * Gets the current world space position of the camera.
  31070. */
  31071. readonly globalPosition: Vector3;
  31072. /**
  31073. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  31074. * @returns the active meshe list
  31075. */
  31076. getActiveMeshes(): SmartArray<AbstractMesh>;
  31077. /**
  31078. * Check wether a mesh is part of the current active mesh list of the camera
  31079. * @param mesh Defines the mesh to check
  31080. * @returns true if active, false otherwise
  31081. */
  31082. isActiveMesh(mesh: Mesh): boolean;
  31083. /**
  31084. * Is this camera ready to be used/rendered
  31085. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  31086. * @return true if the camera is ready
  31087. */
  31088. isReady(completeCheck?: boolean): boolean;
  31089. /** @hidden */
  31090. _initCache(): void;
  31091. /** @hidden */
  31092. _updateCache(ignoreParentClass?: boolean): void;
  31093. /** @hidden */
  31094. _isSynchronized(): boolean;
  31095. /** @hidden */
  31096. _isSynchronizedViewMatrix(): boolean;
  31097. /** @hidden */
  31098. _isSynchronizedProjectionMatrix(): boolean;
  31099. /**
  31100. * Attach the input controls to a specific dom element to get the input from.
  31101. * @param element Defines the element the controls should be listened from
  31102. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  31103. */
  31104. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31105. /**
  31106. * Detach the current controls from the specified dom element.
  31107. * @param element Defines the element to stop listening the inputs from
  31108. */
  31109. detachControl(element: HTMLElement): void;
  31110. /**
  31111. * Update the camera state according to the different inputs gathered during the frame.
  31112. */
  31113. update(): void;
  31114. /** @hidden */
  31115. _checkInputs(): void;
  31116. /** @hidden */
  31117. readonly rigCameras: Camera[];
  31118. /**
  31119. * Gets the post process used by the rig cameras
  31120. */
  31121. readonly rigPostProcess: Nullable<PostProcess>;
  31122. /**
  31123. * Internal, gets the first post proces.
  31124. * @returns the first post process to be run on this camera.
  31125. */
  31126. _getFirstPostProcess(): Nullable<PostProcess>;
  31127. private _cascadePostProcessesToRigCams;
  31128. /**
  31129. * Attach a post process to the camera.
  31130. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31131. * @param postProcess The post process to attach to the camera
  31132. * @param insertAt The position of the post process in case several of them are in use in the scene
  31133. * @returns the position the post process has been inserted at
  31134. */
  31135. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  31136. /**
  31137. * Detach a post process to the camera.
  31138. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31139. * @param postProcess The post process to detach from the camera
  31140. */
  31141. detachPostProcess(postProcess: PostProcess): void;
  31142. /**
  31143. * Gets the current world matrix of the camera
  31144. */
  31145. getWorldMatrix(): Matrix;
  31146. /** @hidden */
  31147. _getViewMatrix(): Matrix;
  31148. /**
  31149. * Gets the current view matrix of the camera.
  31150. * @param force forces the camera to recompute the matrix without looking at the cached state
  31151. * @returns the view matrix
  31152. */
  31153. getViewMatrix(force?: boolean): Matrix;
  31154. /**
  31155. * Freeze the projection matrix.
  31156. * It will prevent the cache check of the camera projection compute and can speed up perf
  31157. * if no parameter of the camera are meant to change
  31158. * @param projection Defines manually a projection if necessary
  31159. */
  31160. freezeProjectionMatrix(projection?: Matrix): void;
  31161. /**
  31162. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  31163. */
  31164. unfreezeProjectionMatrix(): void;
  31165. /**
  31166. * Gets the current projection matrix of the camera.
  31167. * @param force forces the camera to recompute the matrix without looking at the cached state
  31168. * @returns the projection matrix
  31169. */
  31170. getProjectionMatrix(force?: boolean): Matrix;
  31171. /**
  31172. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  31173. * @returns a Matrix
  31174. */
  31175. getTransformationMatrix(): Matrix;
  31176. private _updateFrustumPlanes;
  31177. /**
  31178. * Checks if a cullable object (mesh...) is in the camera frustum
  31179. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  31180. * @param target The object to check
  31181. * @returns true if the object is in frustum otherwise false
  31182. */
  31183. isInFrustum(target: ICullable): boolean;
  31184. /**
  31185. * Checks if a cullable object (mesh...) is in the camera frustum
  31186. * Unlike isInFrustum this cheks the full bounding box
  31187. * @param target The object to check
  31188. * @returns true if the object is in frustum otherwise false
  31189. */
  31190. isCompletelyInFrustum(target: ICullable): boolean;
  31191. /**
  31192. * Gets a ray in the forward direction from the camera.
  31193. * @param length Defines the length of the ray to create
  31194. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  31195. * @param origin Defines the start point of the ray which defaults to the camera position
  31196. * @returns the forward ray
  31197. */
  31198. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  31199. /**
  31200. * Releases resources associated with this node.
  31201. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31202. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31203. */
  31204. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31205. /** @hidden */
  31206. _isLeftCamera: boolean;
  31207. /**
  31208. * Gets the left camera of a rig setup in case of Rigged Camera
  31209. */
  31210. readonly isLeftCamera: boolean;
  31211. /** @hidden */
  31212. _isRightCamera: boolean;
  31213. /**
  31214. * Gets the right camera of a rig setup in case of Rigged Camera
  31215. */
  31216. readonly isRightCamera: boolean;
  31217. /**
  31218. * Gets the left camera of a rig setup in case of Rigged Camera
  31219. */
  31220. readonly leftCamera: Nullable<FreeCamera>;
  31221. /**
  31222. * Gets the right camera of a rig setup in case of Rigged Camera
  31223. */
  31224. readonly rightCamera: Nullable<FreeCamera>;
  31225. /**
  31226. * Gets the left camera target of a rig setup in case of Rigged Camera
  31227. * @returns the target position
  31228. */
  31229. getLeftTarget(): Nullable<Vector3>;
  31230. /**
  31231. * Gets the right camera target of a rig setup in case of Rigged Camera
  31232. * @returns the target position
  31233. */
  31234. getRightTarget(): Nullable<Vector3>;
  31235. /**
  31236. * @hidden
  31237. */
  31238. setCameraRigMode(mode: number, rigParams: any): void;
  31239. /** @hidden */
  31240. static _setStereoscopicRigMode(camera: Camera): void;
  31241. /** @hidden */
  31242. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  31243. /** @hidden */
  31244. static _setVRRigMode(camera: Camera, rigParams: any): void;
  31245. /** @hidden */
  31246. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  31247. /** @hidden */
  31248. _getVRProjectionMatrix(): Matrix;
  31249. protected _updateCameraRotationMatrix(): void;
  31250. protected _updateWebVRCameraRotationMatrix(): void;
  31251. /**
  31252. * This function MUST be overwritten by the different WebVR cameras available.
  31253. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31254. * @hidden
  31255. */
  31256. _getWebVRProjectionMatrix(): Matrix;
  31257. /**
  31258. * This function MUST be overwritten by the different WebVR cameras available.
  31259. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31260. * @hidden
  31261. */
  31262. _getWebVRViewMatrix(): Matrix;
  31263. /** @hidden */
  31264. setCameraRigParameter(name: string, value: any): void;
  31265. /**
  31266. * needs to be overridden by children so sub has required properties to be copied
  31267. * @hidden
  31268. */
  31269. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  31270. /**
  31271. * May need to be overridden by children
  31272. * @hidden
  31273. */
  31274. _updateRigCameras(): void;
  31275. /** @hidden */
  31276. _setupInputs(): void;
  31277. /**
  31278. * Serialiaze the camera setup to a json represention
  31279. * @returns the JSON representation
  31280. */
  31281. serialize(): any;
  31282. /**
  31283. * Clones the current camera.
  31284. * @param name The cloned camera name
  31285. * @returns the cloned camera
  31286. */
  31287. clone(name: string): Camera;
  31288. /**
  31289. * Gets the direction of the camera relative to a given local axis.
  31290. * @param localAxis Defines the reference axis to provide a relative direction.
  31291. * @return the direction
  31292. */
  31293. getDirection(localAxis: Vector3): Vector3;
  31294. /**
  31295. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31296. * @param localAxis Defines the reference axis to provide a relative direction.
  31297. * @param result Defines the vector to store the result in
  31298. */
  31299. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31300. /**
  31301. * Gets a camera constructor for a given camera type
  31302. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31303. * @param name The name of the camera the result will be able to instantiate
  31304. * @param scene The scene the result will construct the camera in
  31305. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31306. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31307. * @returns a factory method to construc the camera
  31308. */
  31309. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31310. /**
  31311. * Compute the world matrix of the camera.
  31312. * @returns the camera workd matrix
  31313. */
  31314. computeWorldMatrix(): Matrix;
  31315. /**
  31316. * Parse a JSON and creates the camera from the parsed information
  31317. * @param parsedCamera The JSON to parse
  31318. * @param scene The scene to instantiate the camera in
  31319. * @returns the newly constructed camera
  31320. */
  31321. static Parse(parsedCamera: any, scene: Scene): Camera;
  31322. }
  31323. }
  31324. declare module "babylonjs/Misc/tools" {
  31325. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  31326. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  31327. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31328. import { Observable } from "babylonjs/Misc/observable";
  31329. import { DomManagement } from "babylonjs/Misc/domManagement";
  31330. import { WebRequest } from "babylonjs/Misc/webRequest";
  31331. import { Camera } from "babylonjs/Cameras/camera";
  31332. import { Engine } from "babylonjs/Engines/engine";
  31333. import { Animation } from "babylonjs/Animations/animation";
  31334. /**
  31335. * Interface for any object that can request an animation frame
  31336. */
  31337. export interface ICustomAnimationFrameRequester {
  31338. /**
  31339. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31340. */
  31341. renderFunction?: Function;
  31342. /**
  31343. * Called to request the next frame to render to
  31344. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31345. */
  31346. requestAnimationFrame: Function;
  31347. /**
  31348. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31349. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31350. */
  31351. requestID?: number;
  31352. }
  31353. /**
  31354. * Interface containing an array of animations
  31355. */
  31356. export interface IAnimatable {
  31357. /**
  31358. * Array of animations
  31359. */
  31360. animations: Array<Animation>;
  31361. }
  31362. /** Interface used by value gradients (color, factor, ...) */
  31363. export interface IValueGradient {
  31364. /**
  31365. * Gets or sets the gradient value (between 0 and 1)
  31366. */
  31367. gradient: number;
  31368. }
  31369. /** Class used to store color4 gradient */
  31370. export class ColorGradient implements IValueGradient {
  31371. /**
  31372. * Gets or sets the gradient value (between 0 and 1)
  31373. */
  31374. gradient: number;
  31375. /**
  31376. * Gets or sets first associated color
  31377. */
  31378. color1: Color4;
  31379. /**
  31380. * Gets or sets second associated color
  31381. */
  31382. color2?: Color4;
  31383. /**
  31384. * Will get a color picked randomly between color1 and color2.
  31385. * If color2 is undefined then color1 will be used
  31386. * @param result defines the target Color4 to store the result in
  31387. */
  31388. getColorToRef(result: Color4): void;
  31389. }
  31390. /** Class used to store color 3 gradient */
  31391. export class Color3Gradient implements IValueGradient {
  31392. /**
  31393. * Gets or sets the gradient value (between 0 and 1)
  31394. */
  31395. gradient: number;
  31396. /**
  31397. * Gets or sets the associated color
  31398. */
  31399. color: Color3;
  31400. }
  31401. /** Class used to store factor gradient */
  31402. export class FactorGradient implements IValueGradient {
  31403. /**
  31404. * Gets or sets the gradient value (between 0 and 1)
  31405. */
  31406. gradient: number;
  31407. /**
  31408. * Gets or sets first associated factor
  31409. */
  31410. factor1: number;
  31411. /**
  31412. * Gets or sets second associated factor
  31413. */
  31414. factor2?: number;
  31415. /**
  31416. * Will get a number picked randomly between factor1 and factor2.
  31417. * If factor2 is undefined then factor1 will be used
  31418. * @returns the picked number
  31419. */
  31420. getFactor(): number;
  31421. }
  31422. /**
  31423. * @ignore
  31424. * Application error to support additional information when loading a file
  31425. */
  31426. export class LoadFileError extends Error {
  31427. /** defines the optional web request */
  31428. request?: WebRequest | undefined;
  31429. private static _setPrototypeOf;
  31430. /**
  31431. * Creates a new LoadFileError
  31432. * @param message defines the message of the error
  31433. * @param request defines the optional web request
  31434. */
  31435. constructor(message: string,
  31436. /** defines the optional web request */
  31437. request?: WebRequest | undefined);
  31438. }
  31439. /**
  31440. * Class used to define a retry strategy when error happens while loading assets
  31441. */
  31442. export class RetryStrategy {
  31443. /**
  31444. * Function used to defines an exponential back off strategy
  31445. * @param maxRetries defines the maximum number of retries (3 by default)
  31446. * @param baseInterval defines the interval between retries
  31447. * @returns the strategy function to use
  31448. */
  31449. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31450. }
  31451. /**
  31452. * File request interface
  31453. */
  31454. export interface IFileRequest {
  31455. /**
  31456. * Raised when the request is complete (success or error).
  31457. */
  31458. onCompleteObservable: Observable<IFileRequest>;
  31459. /**
  31460. * Aborts the request for a file.
  31461. */
  31462. abort: () => void;
  31463. }
  31464. /**
  31465. * Class containing a set of static utilities functions
  31466. */
  31467. export class Tools {
  31468. /**
  31469. * Gets or sets the base URL to use to load assets
  31470. */
  31471. static BaseUrl: string;
  31472. /**
  31473. * Enable/Disable Custom HTTP Request Headers globally.
  31474. * default = false
  31475. * @see CustomRequestHeaders
  31476. */
  31477. static UseCustomRequestHeaders: boolean;
  31478. /**
  31479. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31480. * i.e. when loading files, where the server/service expects an Authorization header
  31481. */
  31482. static CustomRequestHeaders: {
  31483. [key: string]: string;
  31484. };
  31485. /**
  31486. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31487. */
  31488. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31489. /**
  31490. * Default behaviour for cors in the application.
  31491. * It can be a string if the expected behavior is identical in the entire app.
  31492. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31493. */
  31494. static CorsBehavior: string | ((url: string | string[]) => string);
  31495. /**
  31496. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31497. * @ignorenaming
  31498. */
  31499. static UseFallbackTexture: boolean;
  31500. /**
  31501. * Use this object to register external classes like custom textures or material
  31502. * to allow the laoders to instantiate them
  31503. */
  31504. static RegisteredExternalClasses: {
  31505. [key: string]: Object;
  31506. };
  31507. /**
  31508. * Texture content used if a texture cannot loaded
  31509. * @ignorenaming
  31510. */
  31511. static fallbackTexture: string;
  31512. /**
  31513. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31514. * @param u defines the coordinate on X axis
  31515. * @param v defines the coordinate on Y axis
  31516. * @param width defines the width of the source data
  31517. * @param height defines the height of the source data
  31518. * @param pixels defines the source byte array
  31519. * @param color defines the output color
  31520. */
  31521. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31522. /**
  31523. * Interpolates between a and b via alpha
  31524. * @param a The lower value (returned when alpha = 0)
  31525. * @param b The upper value (returned when alpha = 1)
  31526. * @param alpha The interpolation-factor
  31527. * @return The mixed value
  31528. */
  31529. static Mix(a: number, b: number, alpha: number): number;
  31530. /**
  31531. * Tries to instantiate a new object from a given class name
  31532. * @param className defines the class name to instantiate
  31533. * @returns the new object or null if the system was not able to do the instantiation
  31534. */
  31535. static Instantiate(className: string): any;
  31536. /**
  31537. * Provides a slice function that will work even on IE
  31538. * @param data defines the array to slice
  31539. * @param start defines the start of the data (optional)
  31540. * @param end defines the end of the data (optional)
  31541. * @returns the new sliced array
  31542. */
  31543. static Slice<T>(data: T, start?: number, end?: number): T;
  31544. /**
  31545. * Polyfill for setImmediate
  31546. * @param action defines the action to execute after the current execution block
  31547. */
  31548. static SetImmediate(action: () => void): void;
  31549. /**
  31550. * Function indicating if a number is an exponent of 2
  31551. * @param value defines the value to test
  31552. * @returns true if the value is an exponent of 2
  31553. */
  31554. static IsExponentOfTwo(value: number): boolean;
  31555. private static _tmpFloatArray;
  31556. /**
  31557. * Returns the nearest 32-bit single precision float representation of a Number
  31558. * @param value A Number. If the parameter is of a different type, it will get converted
  31559. * to a number or to NaN if it cannot be converted
  31560. * @returns number
  31561. */
  31562. static FloatRound(value: number): number;
  31563. /**
  31564. * Find the next highest power of two.
  31565. * @param x Number to start search from.
  31566. * @return Next highest power of two.
  31567. */
  31568. static CeilingPOT(x: number): number;
  31569. /**
  31570. * Find the next lowest power of two.
  31571. * @param x Number to start search from.
  31572. * @return Next lowest power of two.
  31573. */
  31574. static FloorPOT(x: number): number;
  31575. /**
  31576. * Find the nearest power of two.
  31577. * @param x Number to start search from.
  31578. * @return Next nearest power of two.
  31579. */
  31580. static NearestPOT(x: number): number;
  31581. /**
  31582. * Get the closest exponent of two
  31583. * @param value defines the value to approximate
  31584. * @param max defines the maximum value to return
  31585. * @param mode defines how to define the closest value
  31586. * @returns closest exponent of two of the given value
  31587. */
  31588. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31589. /**
  31590. * Extracts the filename from a path
  31591. * @param path defines the path to use
  31592. * @returns the filename
  31593. */
  31594. static GetFilename(path: string): string;
  31595. /**
  31596. * Extracts the "folder" part of a path (everything before the filename).
  31597. * @param uri The URI to extract the info from
  31598. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31599. * @returns The "folder" part of the path
  31600. */
  31601. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31602. /**
  31603. * Extracts text content from a DOM element hierarchy
  31604. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31605. */
  31606. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31607. /**
  31608. * Convert an angle in radians to degrees
  31609. * @param angle defines the angle to convert
  31610. * @returns the angle in degrees
  31611. */
  31612. static ToDegrees(angle: number): number;
  31613. /**
  31614. * Convert an angle in degrees to radians
  31615. * @param angle defines the angle to convert
  31616. * @returns the angle in radians
  31617. */
  31618. static ToRadians(angle: number): number;
  31619. /**
  31620. * Encode a buffer to a base64 string
  31621. * @param buffer defines the buffer to encode
  31622. * @returns the encoded string
  31623. */
  31624. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31625. /**
  31626. * Extracts minimum and maximum values from a list of indexed positions
  31627. * @param positions defines the positions to use
  31628. * @param indices defines the indices to the positions
  31629. * @param indexStart defines the start index
  31630. * @param indexCount defines the end index
  31631. * @param bias defines bias value to add to the result
  31632. * @return minimum and maximum values
  31633. */
  31634. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31635. minimum: Vector3;
  31636. maximum: Vector3;
  31637. };
  31638. /**
  31639. * Extracts minimum and maximum values from a list of positions
  31640. * @param positions defines the positions to use
  31641. * @param start defines the start index in the positions array
  31642. * @param count defines the number of positions to handle
  31643. * @param bias defines bias value to add to the result
  31644. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31645. * @return minimum and maximum values
  31646. */
  31647. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31648. minimum: Vector3;
  31649. maximum: Vector3;
  31650. };
  31651. /**
  31652. * Returns an array if obj is not an array
  31653. * @param obj defines the object to evaluate as an array
  31654. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31655. * @returns either obj directly if obj is an array or a new array containing obj
  31656. */
  31657. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31658. /**
  31659. * Gets the pointer prefix to use
  31660. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31661. */
  31662. static GetPointerPrefix(): string;
  31663. /**
  31664. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31665. * @param func - the function to be called
  31666. * @param requester - the object that will request the next frame. Falls back to window.
  31667. * @returns frame number
  31668. */
  31669. static QueueNewFrame(func: () => void, requester?: any): number;
  31670. /**
  31671. * Ask the browser to promote the current element to fullscreen rendering mode
  31672. * @param element defines the DOM element to promote
  31673. */
  31674. static RequestFullscreen(element: HTMLElement): void;
  31675. /**
  31676. * Asks the browser to exit fullscreen mode
  31677. */
  31678. static ExitFullscreen(): void;
  31679. /**
  31680. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31681. * @param url define the url we are trying
  31682. * @param element define the dom element where to configure the cors policy
  31683. */
  31684. static SetCorsBehavior(url: string | string[], element: {
  31685. crossOrigin: string | null;
  31686. }): void;
  31687. /**
  31688. * Removes unwanted characters from an url
  31689. * @param url defines the url to clean
  31690. * @returns the cleaned url
  31691. */
  31692. static CleanUrl(url: string): string;
  31693. /**
  31694. * Gets or sets a function used to pre-process url before using them to load assets
  31695. */
  31696. static PreprocessUrl: (url: string) => string;
  31697. /**
  31698. * Loads an image as an HTMLImageElement.
  31699. * @param input url string, ArrayBuffer, or Blob to load
  31700. * @param onLoad callback called when the image successfully loads
  31701. * @param onError callback called when the image fails to load
  31702. * @param offlineProvider offline provider for caching
  31703. * @returns the HTMLImageElement of the loaded image
  31704. */
  31705. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31706. /**
  31707. * Loads a file
  31708. * @param url url string, ArrayBuffer, or Blob to load
  31709. * @param onSuccess callback called when the file successfully loads
  31710. * @param onProgress callback called while file is loading (if the server supports this mode)
  31711. * @param offlineProvider defines the offline provider for caching
  31712. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31713. * @param onError callback called when the file fails to load
  31714. * @returns a file request object
  31715. */
  31716. 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;
  31717. /**
  31718. * Load a script (identified by an url). When the url returns, the
  31719. * content of this file is added into a new script element, attached to the DOM (body element)
  31720. * @param scriptUrl defines the url of the script to laod
  31721. * @param onSuccess defines the callback called when the script is loaded
  31722. * @param onError defines the callback to call if an error occurs
  31723. * @param scriptId defines the id of the script element
  31724. */
  31725. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31726. /**
  31727. * Load an asynchronous script (identified by an url). When the url returns, the
  31728. * content of this file is added into a new script element, attached to the DOM (body element)
  31729. * @param scriptUrl defines the url of the script to laod
  31730. * @param scriptId defines the id of the script element
  31731. * @returns a promise request object
  31732. */
  31733. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  31734. /**
  31735. * Loads a file from a blob
  31736. * @param fileToLoad defines the blob to use
  31737. * @param callback defines the callback to call when data is loaded
  31738. * @param progressCallback defines the callback to call during loading process
  31739. * @returns a file request object
  31740. */
  31741. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31742. /**
  31743. * Loads a file
  31744. * @param fileToLoad defines the file to load
  31745. * @param callback defines the callback to call when data is loaded
  31746. * @param progressCallBack defines the callback to call during loading process
  31747. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31748. * @returns a file request object
  31749. */
  31750. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31751. /**
  31752. * Creates a data url from a given string content
  31753. * @param content defines the content to convert
  31754. * @returns the new data url link
  31755. */
  31756. static FileAsURL(content: string): string;
  31757. /**
  31758. * Format the given number to a specific decimal format
  31759. * @param value defines the number to format
  31760. * @param decimals defines the number of decimals to use
  31761. * @returns the formatted string
  31762. */
  31763. static Format(value: number, decimals?: number): string;
  31764. /**
  31765. * Checks if a given vector is inside a specific range
  31766. * @param v defines the vector to test
  31767. * @param min defines the minimum range
  31768. * @param max defines the maximum range
  31769. */
  31770. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31771. /**
  31772. * Tries to copy an object by duplicating every property
  31773. * @param source defines the source object
  31774. * @param destination defines the target object
  31775. * @param doNotCopyList defines a list of properties to avoid
  31776. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31777. */
  31778. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31779. /**
  31780. * Gets a boolean indicating if the given object has no own property
  31781. * @param obj defines the object to test
  31782. * @returns true if object has no own property
  31783. */
  31784. static IsEmpty(obj: any): boolean;
  31785. /**
  31786. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  31787. * @param str Source string
  31788. * @param suffix Suffix to search for in the source string
  31789. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31790. */
  31791. static EndsWith(str: string, suffix: string): boolean;
  31792. /**
  31793. * Function used to register events at window level
  31794. * @param events defines the events to register
  31795. */
  31796. static RegisterTopRootEvents(events: {
  31797. name: string;
  31798. handler: Nullable<(e: FocusEvent) => any>;
  31799. }[]): void;
  31800. /**
  31801. * Function used to unregister events from window level
  31802. * @param events defines the events to unregister
  31803. */
  31804. static UnregisterTopRootEvents(events: {
  31805. name: string;
  31806. handler: Nullable<(e: FocusEvent) => any>;
  31807. }[]): void;
  31808. /**
  31809. * @ignore
  31810. */
  31811. static _ScreenshotCanvas: HTMLCanvasElement;
  31812. /**
  31813. * Dumps the current bound framebuffer
  31814. * @param width defines the rendering width
  31815. * @param height defines the rendering height
  31816. * @param engine defines the hosting engine
  31817. * @param successCallback defines the callback triggered once the data are available
  31818. * @param mimeType defines the mime type of the result
  31819. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31820. */
  31821. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31822. /**
  31823. * Converts the canvas data to blob.
  31824. * This acts as a polyfill for browsers not supporting the to blob function.
  31825. * @param canvas Defines the canvas to extract the data from
  31826. * @param successCallback Defines the callback triggered once the data are available
  31827. * @param mimeType Defines the mime type of the result
  31828. */
  31829. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31830. /**
  31831. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31832. * @param successCallback defines the callback triggered once the data are available
  31833. * @param mimeType defines the mime type of the result
  31834. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31835. */
  31836. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31837. /**
  31838. * Downloads a blob in the browser
  31839. * @param blob defines the blob to download
  31840. * @param fileName defines the name of the downloaded file
  31841. */
  31842. static Download(blob: Blob, fileName: string): void;
  31843. /**
  31844. * Captures a screenshot of the current rendering
  31845. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31846. * @param engine defines the rendering engine
  31847. * @param camera defines the source camera
  31848. * @param size This parameter can be set to a single number or to an object with the
  31849. * following (optional) properties: precision, width, height. If a single number is passed,
  31850. * it will be used for both width and height. If an object is passed, the screenshot size
  31851. * will be derived from the parameters. The precision property is a multiplier allowing
  31852. * rendering at a higher or lower resolution
  31853. * @param successCallback defines the callback receives a single parameter which contains the
  31854. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31855. * src parameter of an <img> to display it
  31856. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31857. * Check your browser for supported MIME types
  31858. */
  31859. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31860. /**
  31861. * Generates an image screenshot from the specified camera.
  31862. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31863. * @param engine The engine to use for rendering
  31864. * @param camera The camera to use for rendering
  31865. * @param size This parameter can be set to a single number or to an object with the
  31866. * following (optional) properties: precision, width, height. If a single number is passed,
  31867. * it will be used for both width and height. If an object is passed, the screenshot size
  31868. * will be derived from the parameters. The precision property is a multiplier allowing
  31869. * rendering at a higher or lower resolution
  31870. * @param successCallback The callback receives a single parameter which contains the
  31871. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31872. * src parameter of an <img> to display it
  31873. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31874. * Check your browser for supported MIME types
  31875. * @param samples Texture samples (default: 1)
  31876. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31877. * @param fileName A name for for the downloaded file.
  31878. */
  31879. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31880. /**
  31881. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31882. * Be aware Math.random() could cause collisions, but:
  31883. * "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"
  31884. * @returns a pseudo random id
  31885. */
  31886. static RandomId(): string;
  31887. /**
  31888. * Test if the given uri is a base64 string
  31889. * @param uri The uri to test
  31890. * @return True if the uri is a base64 string or false otherwise
  31891. */
  31892. static IsBase64(uri: string): boolean;
  31893. /**
  31894. * Decode the given base64 uri.
  31895. * @param uri The uri to decode
  31896. * @return The decoded base64 data.
  31897. */
  31898. static DecodeBase64(uri: string): ArrayBuffer;
  31899. /**
  31900. * Gets the absolute url.
  31901. * @param url the input url
  31902. * @return the absolute url
  31903. */
  31904. static GetAbsoluteUrl(url: string): string;
  31905. /**
  31906. * No log
  31907. */
  31908. static readonly NoneLogLevel: number;
  31909. /**
  31910. * Only message logs
  31911. */
  31912. static readonly MessageLogLevel: number;
  31913. /**
  31914. * Only warning logs
  31915. */
  31916. static readonly WarningLogLevel: number;
  31917. /**
  31918. * Only error logs
  31919. */
  31920. static readonly ErrorLogLevel: number;
  31921. /**
  31922. * All logs
  31923. */
  31924. static readonly AllLogLevel: number;
  31925. /**
  31926. * Gets a value indicating the number of loading errors
  31927. * @ignorenaming
  31928. */
  31929. static readonly errorsCount: number;
  31930. /**
  31931. * Callback called when a new log is added
  31932. */
  31933. static OnNewCacheEntry: (entry: string) => void;
  31934. /**
  31935. * Log a message to the console
  31936. * @param message defines the message to log
  31937. */
  31938. static Log(message: string): void;
  31939. /**
  31940. * Write a warning message to the console
  31941. * @param message defines the message to log
  31942. */
  31943. static Warn(message: string): void;
  31944. /**
  31945. * Write an error message to the console
  31946. * @param message defines the message to log
  31947. */
  31948. static Error(message: string): void;
  31949. /**
  31950. * Gets current log cache (list of logs)
  31951. */
  31952. static readonly LogCache: string;
  31953. /**
  31954. * Clears the log cache
  31955. */
  31956. static ClearLogCache(): void;
  31957. /**
  31958. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31959. */
  31960. static LogLevels: number;
  31961. /**
  31962. * Checks if the loaded document was accessed via `file:`-Protocol.
  31963. * @returns boolean
  31964. */
  31965. static IsFileURL(): boolean;
  31966. /**
  31967. * Checks if the window object exists
  31968. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31969. */
  31970. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31971. /**
  31972. * No performance log
  31973. */
  31974. static readonly PerformanceNoneLogLevel: number;
  31975. /**
  31976. * Use user marks to log performance
  31977. */
  31978. static readonly PerformanceUserMarkLogLevel: number;
  31979. /**
  31980. * Log performance to the console
  31981. */
  31982. static readonly PerformanceConsoleLogLevel: number;
  31983. private static _performance;
  31984. /**
  31985. * Sets the current performance log level
  31986. */
  31987. static PerformanceLogLevel: number;
  31988. private static _StartPerformanceCounterDisabled;
  31989. private static _EndPerformanceCounterDisabled;
  31990. private static _StartUserMark;
  31991. private static _EndUserMark;
  31992. private static _StartPerformanceConsole;
  31993. private static _EndPerformanceConsole;
  31994. /**
  31995. * Starts a performance counter
  31996. */
  31997. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31998. /**
  31999. * Ends a specific performance coutner
  32000. */
  32001. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32002. /**
  32003. * Gets either window.performance.now() if supported or Date.now() else
  32004. */
  32005. static readonly Now: number;
  32006. /**
  32007. * This method will return the name of the class used to create the instance of the given object.
  32008. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32009. * @param object the object to get the class name from
  32010. * @param isType defines if the object is actually a type
  32011. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32012. */
  32013. static GetClassName(object: any, isType?: boolean): string;
  32014. /**
  32015. * Gets the first element of an array satisfying a given predicate
  32016. * @param array defines the array to browse
  32017. * @param predicate defines the predicate to use
  32018. * @returns null if not found or the element
  32019. */
  32020. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32021. /**
  32022. * This method will return the name of the full name of the class, including its owning module (if any).
  32023. * 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).
  32024. * @param object the object to get the class name from
  32025. * @param isType defines if the object is actually a type
  32026. * @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.
  32027. * @ignorenaming
  32028. */
  32029. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32030. /**
  32031. * Returns a promise that resolves after the given amount of time.
  32032. * @param delay Number of milliseconds to delay
  32033. * @returns Promise that resolves after the given amount of time
  32034. */
  32035. static DelayAsync(delay: number): Promise<void>;
  32036. /**
  32037. * Gets the current gradient from an array of IValueGradient
  32038. * @param ratio defines the current ratio to get
  32039. * @param gradients defines the array of IValueGradient
  32040. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  32041. */
  32042. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  32043. }
  32044. /**
  32045. * This class is used to track a performance counter which is number based.
  32046. * The user has access to many properties which give statistics of different nature.
  32047. *
  32048. * The implementer can track two kinds of Performance Counter: time and count.
  32049. * 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.
  32050. * 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.
  32051. */
  32052. export class PerfCounter {
  32053. /**
  32054. * Gets or sets a global boolean to turn on and off all the counters
  32055. */
  32056. static Enabled: boolean;
  32057. /**
  32058. * Returns the smallest value ever
  32059. */
  32060. readonly min: number;
  32061. /**
  32062. * Returns the biggest value ever
  32063. */
  32064. readonly max: number;
  32065. /**
  32066. * Returns the average value since the performance counter is running
  32067. */
  32068. readonly average: number;
  32069. /**
  32070. * Returns the average value of the last second the counter was monitored
  32071. */
  32072. readonly lastSecAverage: number;
  32073. /**
  32074. * Returns the current value
  32075. */
  32076. readonly current: number;
  32077. /**
  32078. * Gets the accumulated total
  32079. */
  32080. readonly total: number;
  32081. /**
  32082. * Gets the total value count
  32083. */
  32084. readonly count: number;
  32085. /**
  32086. * Creates a new counter
  32087. */
  32088. constructor();
  32089. /**
  32090. * Call this method to start monitoring a new frame.
  32091. * 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.
  32092. */
  32093. fetchNewFrame(): void;
  32094. /**
  32095. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32096. * @param newCount the count value to add to the monitored count
  32097. * @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.
  32098. */
  32099. addCount(newCount: number, fetchResult: boolean): void;
  32100. /**
  32101. * Start monitoring this performance counter
  32102. */
  32103. beginMonitoring(): void;
  32104. /**
  32105. * Compute the time lapsed since the previous beginMonitoring() call.
  32106. * @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
  32107. */
  32108. endMonitoring(newFrame?: boolean): void;
  32109. private _fetchResult;
  32110. private _startMonitoringTime;
  32111. private _min;
  32112. private _max;
  32113. private _average;
  32114. private _current;
  32115. private _totalValueCount;
  32116. private _totalAccumulated;
  32117. private _lastSecAverage;
  32118. private _lastSecAccumulated;
  32119. private _lastSecTime;
  32120. private _lastSecValueCount;
  32121. }
  32122. /**
  32123. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32124. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32125. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32126. * @param name The name of the class, case should be preserved
  32127. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32128. */
  32129. export function className(name: string, module?: string): (target: Object) => void;
  32130. /**
  32131. * An implementation of a loop for asynchronous functions.
  32132. */
  32133. export class AsyncLoop {
  32134. /**
  32135. * Defines the number of iterations for the loop
  32136. */
  32137. iterations: number;
  32138. /**
  32139. * Defines the current index of the loop.
  32140. */
  32141. index: number;
  32142. private _done;
  32143. private _fn;
  32144. private _successCallback;
  32145. /**
  32146. * Constructor.
  32147. * @param iterations the number of iterations.
  32148. * @param func the function to run each iteration
  32149. * @param successCallback the callback that will be called upon succesful execution
  32150. * @param offset starting offset.
  32151. */
  32152. constructor(
  32153. /**
  32154. * Defines the number of iterations for the loop
  32155. */
  32156. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32157. /**
  32158. * Execute the next iteration. Must be called after the last iteration was finished.
  32159. */
  32160. executeNext(): void;
  32161. /**
  32162. * Break the loop and run the success callback.
  32163. */
  32164. breakLoop(): void;
  32165. /**
  32166. * Create and run an async loop.
  32167. * @param iterations the number of iterations.
  32168. * @param fn the function to run each iteration
  32169. * @param successCallback the callback that will be called upon succesful execution
  32170. * @param offset starting offset.
  32171. * @returns the created async loop object
  32172. */
  32173. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32174. /**
  32175. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32176. * @param iterations total number of iterations
  32177. * @param syncedIterations number of synchronous iterations in each async iteration.
  32178. * @param fn the function to call each iteration.
  32179. * @param callback a success call back that will be called when iterating stops.
  32180. * @param breakFunction a break condition (optional)
  32181. * @param timeout timeout settings for the setTimeout function. default - 0.
  32182. * @returns the created async loop object
  32183. */
  32184. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32185. }
  32186. }
  32187. declare module "babylonjs/Collisions/collisionCoordinator" {
  32188. import { Nullable } from "babylonjs/types";
  32189. import { Scene } from "babylonjs/scene";
  32190. import { Vector3 } from "babylonjs/Maths/math";
  32191. import { Collider } from "babylonjs/Collisions/collider";
  32192. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32193. /** @hidden */
  32194. export interface ICollisionCoordinator {
  32195. createCollider(): Collider;
  32196. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32197. init(scene: Scene): void;
  32198. }
  32199. /** @hidden */
  32200. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32201. private _scene;
  32202. private _scaledPosition;
  32203. private _scaledVelocity;
  32204. private _finalPosition;
  32205. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32206. createCollider(): Collider;
  32207. init(scene: Scene): void;
  32208. private _collideWithWorld;
  32209. }
  32210. }
  32211. declare module "babylonjs/Animations/animationGroup" {
  32212. import { Animatable } from "babylonjs/Animations/animatable";
  32213. import { Animation } from "babylonjs/Animations/animation";
  32214. import { Scene, IDisposable } from "babylonjs/scene";
  32215. import { Observable } from "babylonjs/Misc/observable";
  32216. import { Nullable } from "babylonjs/types";
  32217. /**
  32218. * This class defines the direct association between an animation and a target
  32219. */
  32220. export class TargetedAnimation {
  32221. /**
  32222. * Animation to perform
  32223. */
  32224. animation: Animation;
  32225. /**
  32226. * Target to animate
  32227. */
  32228. target: any;
  32229. }
  32230. /**
  32231. * Use this class to create coordinated animations on multiple targets
  32232. */
  32233. export class AnimationGroup implements IDisposable {
  32234. /** The name of the animation group */
  32235. name: string;
  32236. private _scene;
  32237. private _targetedAnimations;
  32238. private _animatables;
  32239. private _from;
  32240. private _to;
  32241. private _isStarted;
  32242. private _isPaused;
  32243. private _speedRatio;
  32244. /**
  32245. * Gets or sets the unique id of the node
  32246. */
  32247. uniqueId: number;
  32248. /**
  32249. * This observable will notify when one animation have ended
  32250. */
  32251. onAnimationEndObservable: Observable<TargetedAnimation>;
  32252. /**
  32253. * Observer raised when one animation loops
  32254. */
  32255. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32256. /**
  32257. * This observable will notify when all animations have ended.
  32258. */
  32259. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32260. /**
  32261. * This observable will notify when all animations have paused.
  32262. */
  32263. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32264. /**
  32265. * This observable will notify when all animations are playing.
  32266. */
  32267. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32268. /**
  32269. * Gets the first frame
  32270. */
  32271. readonly from: number;
  32272. /**
  32273. * Gets the last frame
  32274. */
  32275. readonly to: number;
  32276. /**
  32277. * Define if the animations are started
  32278. */
  32279. readonly isStarted: boolean;
  32280. /**
  32281. * Gets a value indicating that the current group is playing
  32282. */
  32283. readonly isPlaying: boolean;
  32284. /**
  32285. * Gets or sets the speed ratio to use for all animations
  32286. */
  32287. /**
  32288. * Gets or sets the speed ratio to use for all animations
  32289. */
  32290. speedRatio: number;
  32291. /**
  32292. * Gets the targeted animations for this animation group
  32293. */
  32294. readonly targetedAnimations: Array<TargetedAnimation>;
  32295. /**
  32296. * returning the list of animatables controlled by this animation group.
  32297. */
  32298. readonly animatables: Array<Animatable>;
  32299. /**
  32300. * Instantiates a new Animation Group.
  32301. * This helps managing several animations at once.
  32302. * @see http://doc.babylonjs.com/how_to/group
  32303. * @param name Defines the name of the group
  32304. * @param scene Defines the scene the group belongs to
  32305. */
  32306. constructor(
  32307. /** The name of the animation group */
  32308. name: string, scene?: Nullable<Scene>);
  32309. /**
  32310. * Add an animation (with its target) in the group
  32311. * @param animation defines the animation we want to add
  32312. * @param target defines the target of the animation
  32313. * @returns the TargetedAnimation object
  32314. */
  32315. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32316. /**
  32317. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32318. * It can add constant keys at begin or end
  32319. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32320. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32321. * @returns the animation group
  32322. */
  32323. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32324. /**
  32325. * Start all animations on given targets
  32326. * @param loop defines if animations must loop
  32327. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32328. * @param from defines the from key (optional)
  32329. * @param to defines the to key (optional)
  32330. * @returns the current animation group
  32331. */
  32332. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32333. /**
  32334. * Pause all animations
  32335. * @returns the animation group
  32336. */
  32337. pause(): AnimationGroup;
  32338. /**
  32339. * Play all animations to initial state
  32340. * This function will start() the animations if they were not started or will restart() them if they were paused
  32341. * @param loop defines if animations must loop
  32342. * @returns the animation group
  32343. */
  32344. play(loop?: boolean): AnimationGroup;
  32345. /**
  32346. * Reset all animations to initial state
  32347. * @returns the animation group
  32348. */
  32349. reset(): AnimationGroup;
  32350. /**
  32351. * Restart animations from key 0
  32352. * @returns the animation group
  32353. */
  32354. restart(): AnimationGroup;
  32355. /**
  32356. * Stop all animations
  32357. * @returns the animation group
  32358. */
  32359. stop(): AnimationGroup;
  32360. /**
  32361. * Set animation weight for all animatables
  32362. * @param weight defines the weight to use
  32363. * @return the animationGroup
  32364. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32365. */
  32366. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32367. /**
  32368. * Synchronize and normalize all animatables with a source animatable
  32369. * @param root defines the root animatable to synchronize with
  32370. * @return the animationGroup
  32371. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32372. */
  32373. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32374. /**
  32375. * Goes to a specific frame in this animation group
  32376. * @param frame the frame number to go to
  32377. * @return the animationGroup
  32378. */
  32379. goToFrame(frame: number): AnimationGroup;
  32380. /**
  32381. * Dispose all associated resources
  32382. */
  32383. dispose(): void;
  32384. private _checkAnimationGroupEnded;
  32385. /**
  32386. * Clone the current animation group and returns a copy
  32387. * @param newName defines the name of the new group
  32388. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32389. * @returns the new aniamtion group
  32390. */
  32391. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32392. /**
  32393. * Returns a new AnimationGroup object parsed from the source provided.
  32394. * @param parsedAnimationGroup defines the source
  32395. * @param scene defines the scene that will receive the animationGroup
  32396. * @returns a new AnimationGroup
  32397. */
  32398. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32399. /**
  32400. * Returns the string "AnimationGroup"
  32401. * @returns "AnimationGroup"
  32402. */
  32403. getClassName(): string;
  32404. /**
  32405. * Creates a detailled string about the object
  32406. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32407. * @returns a string representing the object
  32408. */
  32409. toString(fullDetails?: boolean): string;
  32410. }
  32411. }
  32412. declare module "babylonjs/scene" {
  32413. import { Nullable } from "babylonjs/types";
  32414. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  32415. import { Observable } from "babylonjs/Misc/observable";
  32416. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  32417. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  32418. import { Geometry } from "babylonjs/Meshes/geometry";
  32419. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32420. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32421. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32422. import { Mesh } from "babylonjs/Meshes/mesh";
  32423. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32424. import { Bone } from "babylonjs/Bones/bone";
  32425. import { Skeleton } from "babylonjs/Bones/skeleton";
  32426. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  32427. import { Camera } from "babylonjs/Cameras/camera";
  32428. import { AbstractScene } from "babylonjs/abstractScene";
  32429. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32430. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32431. import { Material } from "babylonjs/Materials/material";
  32432. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  32433. import { Effect } from "babylonjs/Materials/effect";
  32434. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32435. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32436. import { Light } from "babylonjs/Lights/light";
  32437. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32438. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  32439. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  32440. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  32441. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32442. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  32443. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32444. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  32445. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction } from "babylonjs/sceneComponent";
  32446. import { Engine } from "babylonjs/Engines/engine";
  32447. import { Node } from "babylonjs/node";
  32448. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32449. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32450. import { WebRequest } from "babylonjs/Misc/webRequest";
  32451. import { Ray } from "babylonjs/Culling/ray";
  32452. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32453. import { Animation } from "babylonjs/Animations/animation";
  32454. import { Animatable } from "babylonjs/Animations/animatable";
  32455. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  32456. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32457. import { Collider } from "babylonjs/Collisions/collider";
  32458. /**
  32459. * Define an interface for all classes that will hold resources
  32460. */
  32461. export interface IDisposable {
  32462. /**
  32463. * Releases all held resources
  32464. */
  32465. dispose(): void;
  32466. }
  32467. /** Interface defining initialization parameters for Scene class */
  32468. export interface SceneOptions {
  32469. /**
  32470. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32471. * It will improve performance when the number of geometries becomes important.
  32472. */
  32473. useGeometryUniqueIdsMap?: boolean;
  32474. /**
  32475. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32476. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32477. */
  32478. useMaterialMeshMap?: boolean;
  32479. /**
  32480. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32481. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32482. */
  32483. useClonedMeshhMap?: boolean;
  32484. }
  32485. /**
  32486. * Represents a scene to be rendered by the engine.
  32487. * @see http://doc.babylonjs.com/features/scene
  32488. */
  32489. export class Scene extends AbstractScene implements IAnimatable {
  32490. private static _uniqueIdCounter;
  32491. /** The fog is deactivated */
  32492. static readonly FOGMODE_NONE: number;
  32493. /** The fog density is following an exponential function */
  32494. static readonly FOGMODE_EXP: number;
  32495. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32496. static readonly FOGMODE_EXP2: number;
  32497. /** The fog density is following a linear function. */
  32498. static readonly FOGMODE_LINEAR: number;
  32499. /**
  32500. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32501. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32502. */
  32503. static MinDeltaTime: number;
  32504. /**
  32505. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32506. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32507. */
  32508. static MaxDeltaTime: number;
  32509. /**
  32510. * Factory used to create the default material.
  32511. * @param name The name of the material to create
  32512. * @param scene The scene to create the material for
  32513. * @returns The default material
  32514. */
  32515. static DefaultMaterialFactory(scene: Scene): Material;
  32516. /**
  32517. * Factory used to create the a collision coordinator.
  32518. * @returns The collision coordinator
  32519. */
  32520. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32521. /** @hidden */
  32522. readonly _isScene: boolean;
  32523. /**
  32524. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32525. */
  32526. autoClear: boolean;
  32527. /**
  32528. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32529. */
  32530. autoClearDepthAndStencil: boolean;
  32531. /**
  32532. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32533. */
  32534. clearColor: Color4;
  32535. /**
  32536. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32537. */
  32538. ambientColor: Color3;
  32539. /**
  32540. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32541. * It should only be one of the following (if not the default embedded one):
  32542. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32543. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32544. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32545. * The material properties need to be setup according to the type of texture in use.
  32546. */
  32547. environmentBRDFTexture: BaseTexture;
  32548. /** @hidden */
  32549. protected _environmentTexture: Nullable<BaseTexture>;
  32550. /**
  32551. * Texture used in all pbr material as the reflection texture.
  32552. * As in the majority of the scene they are the same (exception for multi room and so on),
  32553. * this is easier to reference from here than from all the materials.
  32554. */
  32555. /**
  32556. * Texture used in all pbr material as the reflection texture.
  32557. * As in the majority of the scene they are the same (exception for multi room and so on),
  32558. * this is easier to set here than in all the materials.
  32559. */
  32560. environmentTexture: Nullable<BaseTexture>;
  32561. /** @hidden */
  32562. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32563. /**
  32564. * Default image processing configuration used either in the rendering
  32565. * Forward main pass or through the imageProcessingPostProcess if present.
  32566. * As in the majority of the scene they are the same (exception for multi camera),
  32567. * this is easier to reference from here than from all the materials and post process.
  32568. *
  32569. * No setter as we it is a shared configuration, you can set the values instead.
  32570. */
  32571. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32572. private _forceWireframe;
  32573. /**
  32574. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32575. */
  32576. forceWireframe: boolean;
  32577. private _forcePointsCloud;
  32578. /**
  32579. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32580. */
  32581. forcePointsCloud: boolean;
  32582. /**
  32583. * Gets or sets the active clipplane 1
  32584. */
  32585. clipPlane: Nullable<Plane>;
  32586. /**
  32587. * Gets or sets the active clipplane 2
  32588. */
  32589. clipPlane2: Nullable<Plane>;
  32590. /**
  32591. * Gets or sets the active clipplane 3
  32592. */
  32593. clipPlane3: Nullable<Plane>;
  32594. /**
  32595. * Gets or sets the active clipplane 4
  32596. */
  32597. clipPlane4: Nullable<Plane>;
  32598. /**
  32599. * Gets or sets a boolean indicating if animations are enabled
  32600. */
  32601. animationsEnabled: boolean;
  32602. private _animationPropertiesOverride;
  32603. /**
  32604. * Gets or sets the animation properties override
  32605. */
  32606. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32607. /**
  32608. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32609. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32610. */
  32611. useConstantAnimationDeltaTime: boolean;
  32612. /**
  32613. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32614. * Please note that it requires to run a ray cast through the scene on every frame
  32615. */
  32616. constantlyUpdateMeshUnderPointer: boolean;
  32617. /**
  32618. * Defines the HTML cursor to use when hovering over interactive elements
  32619. */
  32620. hoverCursor: string;
  32621. /**
  32622. * Defines the HTML default cursor to use (empty by default)
  32623. */
  32624. defaultCursor: string;
  32625. /**
  32626. * This is used to call preventDefault() on pointer down
  32627. * in order to block unwanted artifacts like system double clicks
  32628. */
  32629. preventDefaultOnPointerDown: boolean;
  32630. /**
  32631. * This is used to call preventDefault() on pointer up
  32632. * in order to block unwanted artifacts like system double clicks
  32633. */
  32634. preventDefaultOnPointerUp: boolean;
  32635. /**
  32636. * Gets or sets user defined metadata
  32637. */
  32638. metadata: any;
  32639. /**
  32640. * For internal use only. Please do not use.
  32641. */
  32642. reservedDataStore: any;
  32643. /**
  32644. * Gets the name of the plugin used to load this scene (null by default)
  32645. */
  32646. loadingPluginName: string;
  32647. /**
  32648. * Use this array to add regular expressions used to disable offline support for specific urls
  32649. */
  32650. disableOfflineSupportExceptionRules: RegExp[];
  32651. /**
  32652. * An event triggered when the scene is disposed.
  32653. */
  32654. onDisposeObservable: Observable<Scene>;
  32655. private _onDisposeObserver;
  32656. /** Sets a function to be executed when this scene is disposed. */
  32657. onDispose: () => void;
  32658. /**
  32659. * An event triggered before rendering the scene (right after animations and physics)
  32660. */
  32661. onBeforeRenderObservable: Observable<Scene>;
  32662. private _onBeforeRenderObserver;
  32663. /** Sets a function to be executed before rendering this scene */
  32664. beforeRender: Nullable<() => void>;
  32665. /**
  32666. * An event triggered after rendering the scene
  32667. */
  32668. onAfterRenderObservable: Observable<Scene>;
  32669. private _onAfterRenderObserver;
  32670. /** Sets a function to be executed after rendering this scene */
  32671. afterRender: Nullable<() => void>;
  32672. /**
  32673. * An event triggered before animating the scene
  32674. */
  32675. onBeforeAnimationsObservable: Observable<Scene>;
  32676. /**
  32677. * An event triggered after animations processing
  32678. */
  32679. onAfterAnimationsObservable: Observable<Scene>;
  32680. /**
  32681. * An event triggered before draw calls are ready to be sent
  32682. */
  32683. onBeforeDrawPhaseObservable: Observable<Scene>;
  32684. /**
  32685. * An event triggered after draw calls have been sent
  32686. */
  32687. onAfterDrawPhaseObservable: Observable<Scene>;
  32688. /**
  32689. * An event triggered when the scene is ready
  32690. */
  32691. onReadyObservable: Observable<Scene>;
  32692. /**
  32693. * An event triggered before rendering a camera
  32694. */
  32695. onBeforeCameraRenderObservable: Observable<Camera>;
  32696. private _onBeforeCameraRenderObserver;
  32697. /** Sets a function to be executed before rendering a camera*/
  32698. beforeCameraRender: () => void;
  32699. /**
  32700. * An event triggered after rendering a camera
  32701. */
  32702. onAfterCameraRenderObservable: Observable<Camera>;
  32703. private _onAfterCameraRenderObserver;
  32704. /** Sets a function to be executed after rendering a camera*/
  32705. afterCameraRender: () => void;
  32706. /**
  32707. * An event triggered when active meshes evaluation is about to start
  32708. */
  32709. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32710. /**
  32711. * An event triggered when active meshes evaluation is done
  32712. */
  32713. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32714. /**
  32715. * An event triggered when particles rendering is about to start
  32716. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32717. */
  32718. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32719. /**
  32720. * An event triggered when particles rendering is done
  32721. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32722. */
  32723. onAfterParticlesRenderingObservable: Observable<Scene>;
  32724. /**
  32725. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32726. */
  32727. onDataLoadedObservable: Observable<Scene>;
  32728. /**
  32729. * An event triggered when a camera is created
  32730. */
  32731. onNewCameraAddedObservable: Observable<Camera>;
  32732. /**
  32733. * An event triggered when a camera is removed
  32734. */
  32735. onCameraRemovedObservable: Observable<Camera>;
  32736. /**
  32737. * An event triggered when a light is created
  32738. */
  32739. onNewLightAddedObservable: Observable<Light>;
  32740. /**
  32741. * An event triggered when a light is removed
  32742. */
  32743. onLightRemovedObservable: Observable<Light>;
  32744. /**
  32745. * An event triggered when a geometry is created
  32746. */
  32747. onNewGeometryAddedObservable: Observable<Geometry>;
  32748. /**
  32749. * An event triggered when a geometry is removed
  32750. */
  32751. onGeometryRemovedObservable: Observable<Geometry>;
  32752. /**
  32753. * An event triggered when a transform node is created
  32754. */
  32755. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32756. /**
  32757. * An event triggered when a transform node is removed
  32758. */
  32759. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32760. /**
  32761. * An event triggered when a mesh is created
  32762. */
  32763. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32764. /**
  32765. * An event triggered when a mesh is removed
  32766. */
  32767. onMeshRemovedObservable: Observable<AbstractMesh>;
  32768. /**
  32769. * An event triggered when a skeleton is created
  32770. */
  32771. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32772. /**
  32773. * An event triggered when a skeleton is removed
  32774. */
  32775. onSkeletonRemovedObservable: Observable<Skeleton>;
  32776. /**
  32777. * An event triggered when a material is created
  32778. */
  32779. onNewMaterialAddedObservable: Observable<Material>;
  32780. /**
  32781. * An event triggered when a material is removed
  32782. */
  32783. onMaterialRemovedObservable: Observable<Material>;
  32784. /**
  32785. * An event triggered when a texture is created
  32786. */
  32787. onNewTextureAddedObservable: Observable<BaseTexture>;
  32788. /**
  32789. * An event triggered when a texture is removed
  32790. */
  32791. onTextureRemovedObservable: Observable<BaseTexture>;
  32792. /**
  32793. * An event triggered when render targets are about to be rendered
  32794. * Can happen multiple times per frame.
  32795. */
  32796. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32797. /**
  32798. * An event triggered when render targets were rendered.
  32799. * Can happen multiple times per frame.
  32800. */
  32801. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32802. /**
  32803. * An event triggered before calculating deterministic simulation step
  32804. */
  32805. onBeforeStepObservable: Observable<Scene>;
  32806. /**
  32807. * An event triggered after calculating deterministic simulation step
  32808. */
  32809. onAfterStepObservable: Observable<Scene>;
  32810. /**
  32811. * An event triggered when the activeCamera property is updated
  32812. */
  32813. onActiveCameraChanged: Observable<Scene>;
  32814. /**
  32815. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32816. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32817. * 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)
  32818. */
  32819. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32820. /**
  32821. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32822. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32823. * 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)
  32824. */
  32825. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32826. /**
  32827. * This Observable will when a mesh has been imported into the scene.
  32828. */
  32829. onMeshImportedObservable: Observable<AbstractMesh>;
  32830. /**
  32831. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32832. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32833. */
  32834. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32835. /** @hidden */
  32836. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32837. /**
  32838. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32839. */
  32840. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32841. /**
  32842. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32843. */
  32844. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32845. /**
  32846. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32847. */
  32848. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32849. private _onPointerMove;
  32850. private _onPointerDown;
  32851. private _onPointerUp;
  32852. /** Callback called when a pointer move is detected */
  32853. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32854. /** Callback called when a pointer down is detected */
  32855. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32856. /** Callback called when a pointer up is detected */
  32857. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32858. /** Callback called when a pointer pick is detected */
  32859. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32860. /**
  32861. * 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).
  32862. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32863. */
  32864. onPrePointerObservable: Observable<PointerInfoPre>;
  32865. /**
  32866. * Observable event triggered each time an input event is received from the rendering canvas
  32867. */
  32868. onPointerObservable: Observable<PointerInfo>;
  32869. /**
  32870. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32871. */
  32872. readonly unTranslatedPointer: Vector2;
  32873. /** The distance in pixel that you have to move to prevent some events */
  32874. static DragMovementThreshold: number;
  32875. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32876. static LongPressDelay: number;
  32877. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32878. static DoubleClickDelay: number;
  32879. /** If you need to check double click without raising a single click at first click, enable this flag */
  32880. static ExclusiveDoubleClickMode: boolean;
  32881. private _initClickEvent;
  32882. private _initActionManager;
  32883. private _delayedSimpleClick;
  32884. private _delayedSimpleClickTimeout;
  32885. private _previousDelayedSimpleClickTimeout;
  32886. private _meshPickProceed;
  32887. private _previousButtonPressed;
  32888. private _currentPickResult;
  32889. private _previousPickResult;
  32890. private _totalPointersPressed;
  32891. private _doubleClickOccured;
  32892. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32893. cameraToUseForPointers: Nullable<Camera>;
  32894. private _pointerX;
  32895. private _pointerY;
  32896. private _unTranslatedPointerX;
  32897. private _unTranslatedPointerY;
  32898. private _startingPointerPosition;
  32899. private _previousStartingPointerPosition;
  32900. private _startingPointerTime;
  32901. private _previousStartingPointerTime;
  32902. private _pointerCaptures;
  32903. private _timeAccumulator;
  32904. private _currentStepId;
  32905. private _currentInternalStep;
  32906. /** @hidden */
  32907. _mirroredCameraPosition: Nullable<Vector3>;
  32908. /**
  32909. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32910. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32911. */
  32912. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32913. /**
  32914. * Observable event triggered each time an keyboard event is received from the hosting window
  32915. */
  32916. onKeyboardObservable: Observable<KeyboardInfo>;
  32917. private _onKeyDown;
  32918. private _onKeyUp;
  32919. private _onCanvasFocusObserver;
  32920. private _onCanvasBlurObserver;
  32921. private _useRightHandedSystem;
  32922. /**
  32923. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32924. */
  32925. useRightHandedSystem: boolean;
  32926. /**
  32927. * Sets the step Id used by deterministic lock step
  32928. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32929. * @param newStepId defines the step Id
  32930. */
  32931. setStepId(newStepId: number): void;
  32932. /**
  32933. * Gets the step Id used by deterministic lock step
  32934. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32935. * @returns the step Id
  32936. */
  32937. getStepId(): number;
  32938. /**
  32939. * Gets the internal step used by deterministic lock step
  32940. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32941. * @returns the internal step
  32942. */
  32943. getInternalStep(): number;
  32944. private _fogEnabled;
  32945. /**
  32946. * Gets or sets a boolean indicating if fog is enabled on this scene
  32947. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32948. * (Default is true)
  32949. */
  32950. fogEnabled: boolean;
  32951. private _fogMode;
  32952. /**
  32953. * Gets or sets the fog mode to use
  32954. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32955. * | mode | value |
  32956. * | --- | --- |
  32957. * | FOGMODE_NONE | 0 |
  32958. * | FOGMODE_EXP | 1 |
  32959. * | FOGMODE_EXP2 | 2 |
  32960. * | FOGMODE_LINEAR | 3 |
  32961. */
  32962. fogMode: number;
  32963. /**
  32964. * Gets or sets the fog color to use
  32965. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32966. * (Default is Color3(0.2, 0.2, 0.3))
  32967. */
  32968. fogColor: Color3;
  32969. /**
  32970. * Gets or sets the fog density to use
  32971. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32972. * (Default is 0.1)
  32973. */
  32974. fogDensity: number;
  32975. /**
  32976. * Gets or sets the fog start distance to use
  32977. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32978. * (Default is 0)
  32979. */
  32980. fogStart: number;
  32981. /**
  32982. * Gets or sets the fog end distance to use
  32983. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32984. * (Default is 1000)
  32985. */
  32986. fogEnd: number;
  32987. private _shadowsEnabled;
  32988. /**
  32989. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32990. */
  32991. shadowsEnabled: boolean;
  32992. private _lightsEnabled;
  32993. /**
  32994. * Gets or sets a boolean indicating if lights are enabled on this scene
  32995. */
  32996. lightsEnabled: boolean;
  32997. /** All of the active cameras added to this scene. */
  32998. activeCameras: Camera[];
  32999. /** @hidden */
  33000. _activeCamera: Nullable<Camera>;
  33001. /** Gets or sets the current active camera */
  33002. activeCamera: Nullable<Camera>;
  33003. private _defaultMaterial;
  33004. /** The default material used on meshes when no material is affected */
  33005. /** The default material used on meshes when no material is affected */
  33006. defaultMaterial: Material;
  33007. private _texturesEnabled;
  33008. /**
  33009. * Gets or sets a boolean indicating if textures are enabled on this scene
  33010. */
  33011. texturesEnabled: boolean;
  33012. /**
  33013. * Gets or sets a boolean indicating if particles are enabled on this scene
  33014. */
  33015. particlesEnabled: boolean;
  33016. /**
  33017. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33018. */
  33019. spritesEnabled: boolean;
  33020. private _skeletonsEnabled;
  33021. /**
  33022. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33023. */
  33024. skeletonsEnabled: boolean;
  33025. /**
  33026. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33027. */
  33028. lensFlaresEnabled: boolean;
  33029. /**
  33030. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33031. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33032. */
  33033. collisionsEnabled: boolean;
  33034. private _collisionCoordinator;
  33035. /** @hidden */
  33036. readonly collisionCoordinator: ICollisionCoordinator;
  33037. /**
  33038. * Defines the gravity applied to this scene (used only for collisions)
  33039. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33040. */
  33041. gravity: Vector3;
  33042. /**
  33043. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33044. */
  33045. postProcessesEnabled: boolean;
  33046. /**
  33047. * The list of postprocesses added to the scene
  33048. */
  33049. postProcesses: PostProcess[];
  33050. /**
  33051. * Gets the current postprocess manager
  33052. */
  33053. postProcessManager: PostProcessManager;
  33054. /**
  33055. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33056. */
  33057. renderTargetsEnabled: boolean;
  33058. /**
  33059. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33060. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33061. */
  33062. dumpNextRenderTargets: boolean;
  33063. /**
  33064. * The list of user defined render targets added to the scene
  33065. */
  33066. customRenderTargets: RenderTargetTexture[];
  33067. /**
  33068. * Defines if texture loading must be delayed
  33069. * If true, textures will only be loaded when they need to be rendered
  33070. */
  33071. useDelayedTextureLoading: boolean;
  33072. /**
  33073. * Gets the list of meshes imported to the scene through SceneLoader
  33074. */
  33075. importedMeshesFiles: String[];
  33076. /**
  33077. * Gets or sets a boolean indicating if probes are enabled on this scene
  33078. */
  33079. probesEnabled: boolean;
  33080. /**
  33081. * Gets or sets the current offline provider to use to store scene data
  33082. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33083. */
  33084. offlineProvider: IOfflineProvider;
  33085. /**
  33086. * Gets or sets the action manager associated with the scene
  33087. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33088. */
  33089. actionManager: AbstractActionManager;
  33090. private _meshesForIntersections;
  33091. /**
  33092. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33093. */
  33094. proceduralTexturesEnabled: boolean;
  33095. private _engine;
  33096. private _totalVertices;
  33097. /** @hidden */
  33098. _activeIndices: PerfCounter;
  33099. /** @hidden */
  33100. _activeParticles: PerfCounter;
  33101. /** @hidden */
  33102. _activeBones: PerfCounter;
  33103. private _animationRatio;
  33104. /** @hidden */
  33105. _animationTimeLast: number;
  33106. /** @hidden */
  33107. _animationTime: number;
  33108. /**
  33109. * Gets or sets a general scale for animation speed
  33110. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33111. */
  33112. animationTimeScale: number;
  33113. /** @hidden */
  33114. _cachedMaterial: Nullable<Material>;
  33115. /** @hidden */
  33116. _cachedEffect: Nullable<Effect>;
  33117. /** @hidden */
  33118. _cachedVisibility: Nullable<number>;
  33119. private _renderId;
  33120. private _frameId;
  33121. private _executeWhenReadyTimeoutId;
  33122. private _intermediateRendering;
  33123. private _viewUpdateFlag;
  33124. private _projectionUpdateFlag;
  33125. /** @hidden */
  33126. _toBeDisposed: Nullable<IDisposable>[];
  33127. private _activeRequests;
  33128. /** @hidden */
  33129. _pendingData: any[];
  33130. private _isDisposed;
  33131. /**
  33132. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33133. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33134. */
  33135. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33136. private _activeMeshes;
  33137. private _processedMaterials;
  33138. private _renderTargets;
  33139. /** @hidden */
  33140. _activeParticleSystems: SmartArray<IParticleSystem>;
  33141. private _activeSkeletons;
  33142. private _softwareSkinnedMeshes;
  33143. private _renderingManager;
  33144. /** @hidden */
  33145. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  33146. private _transformMatrix;
  33147. private _sceneUbo;
  33148. /** @hidden */
  33149. _viewMatrix: Matrix;
  33150. private _projectionMatrix;
  33151. private _wheelEventName;
  33152. /** @hidden */
  33153. _forcedViewPosition: Nullable<Vector3>;
  33154. /** @hidden */
  33155. _frustumPlanes: Plane[];
  33156. /**
  33157. * Gets the list of frustum planes (built from the active camera)
  33158. */
  33159. readonly frustumPlanes: Plane[];
  33160. /**
  33161. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33162. * This is useful if there are more lights that the maximum simulteanous authorized
  33163. */
  33164. requireLightSorting: boolean;
  33165. /** @hidden */
  33166. readonly useMaterialMeshMap: boolean;
  33167. /** @hidden */
  33168. readonly useClonedMeshhMap: boolean;
  33169. private _pointerOverMesh;
  33170. private _pickedDownMesh;
  33171. private _pickedUpMesh;
  33172. private _externalData;
  33173. private _uid;
  33174. /**
  33175. * @hidden
  33176. * Backing store of defined scene components.
  33177. */
  33178. _components: ISceneComponent[];
  33179. /**
  33180. * @hidden
  33181. * Backing store of defined scene components.
  33182. */
  33183. _serializableComponents: ISceneSerializableComponent[];
  33184. /**
  33185. * List of components to register on the next registration step.
  33186. */
  33187. private _transientComponents;
  33188. /**
  33189. * Registers the transient components if needed.
  33190. */
  33191. private _registerTransientComponents;
  33192. /**
  33193. * @hidden
  33194. * Add a component to the scene.
  33195. * Note that the ccomponent could be registered on th next frame if this is called after
  33196. * the register component stage.
  33197. * @param component Defines the component to add to the scene
  33198. */
  33199. _addComponent(component: ISceneComponent): void;
  33200. /**
  33201. * @hidden
  33202. * Gets a component from the scene.
  33203. * @param name defines the name of the component to retrieve
  33204. * @returns the component or null if not present
  33205. */
  33206. _getComponent(name: string): Nullable<ISceneComponent>;
  33207. /**
  33208. * @hidden
  33209. * Defines the actions happening before camera updates.
  33210. */
  33211. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33212. /**
  33213. * @hidden
  33214. * Defines the actions happening before clear the canvas.
  33215. */
  33216. _beforeClearStage: Stage<SimpleStageAction>;
  33217. /**
  33218. * @hidden
  33219. * Defines the actions when collecting render targets for the frame.
  33220. */
  33221. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33222. /**
  33223. * @hidden
  33224. * Defines the actions happening for one camera in the frame.
  33225. */
  33226. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33227. /**
  33228. * @hidden
  33229. * Defines the actions happening during the per mesh ready checks.
  33230. */
  33231. _isReadyForMeshStage: Stage<MeshStageAction>;
  33232. /**
  33233. * @hidden
  33234. * Defines the actions happening before evaluate active mesh checks.
  33235. */
  33236. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33237. /**
  33238. * @hidden
  33239. * Defines the actions happening during the evaluate sub mesh checks.
  33240. */
  33241. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33242. /**
  33243. * @hidden
  33244. * Defines the actions happening during the active mesh stage.
  33245. */
  33246. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33247. /**
  33248. * @hidden
  33249. * Defines the actions happening during the per camera render target step.
  33250. */
  33251. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  33252. /**
  33253. * @hidden
  33254. * Defines the actions happening just before the active camera is drawing.
  33255. */
  33256. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33257. /**
  33258. * @hidden
  33259. * Defines the actions happening just before a render target is drawing.
  33260. */
  33261. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33262. /**
  33263. * @hidden
  33264. * Defines the actions happening just before a rendering group is drawing.
  33265. */
  33266. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33267. /**
  33268. * @hidden
  33269. * Defines the actions happening just before a mesh is drawing.
  33270. */
  33271. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33272. /**
  33273. * @hidden
  33274. * Defines the actions happening just after a mesh has been drawn.
  33275. */
  33276. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33277. /**
  33278. * @hidden
  33279. * Defines the actions happening just after a rendering group has been drawn.
  33280. */
  33281. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33282. /**
  33283. * @hidden
  33284. * Defines the actions happening just after the active camera has been drawn.
  33285. */
  33286. _afterCameraDrawStage: Stage<CameraStageAction>;
  33287. /**
  33288. * @hidden
  33289. * Defines the actions happening just after a render target has been drawn.
  33290. */
  33291. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33292. /**
  33293. * @hidden
  33294. * Defines the actions happening just after rendering all cameras and computing intersections.
  33295. */
  33296. _afterRenderStage: Stage<SimpleStageAction>;
  33297. /**
  33298. * @hidden
  33299. * Defines the actions happening when a pointer move event happens.
  33300. */
  33301. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33302. /**
  33303. * @hidden
  33304. * Defines the actions happening when a pointer down event happens.
  33305. */
  33306. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33307. /**
  33308. * @hidden
  33309. * Defines the actions happening when a pointer up event happens.
  33310. */
  33311. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33312. /**
  33313. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33314. */
  33315. private geometriesByUniqueId;
  33316. /**
  33317. * Creates a new Scene
  33318. * @param engine defines the engine to use to render this scene
  33319. * @param options defines the scene options
  33320. */
  33321. constructor(engine: Engine, options?: SceneOptions);
  33322. /**
  33323. * Gets a string idenfifying the name of the class
  33324. * @returns "Scene" string
  33325. */
  33326. getClassName(): string;
  33327. private _defaultMeshCandidates;
  33328. /**
  33329. * @hidden
  33330. */
  33331. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33332. private _defaultSubMeshCandidates;
  33333. /**
  33334. * @hidden
  33335. */
  33336. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33337. /**
  33338. * Sets the default candidate providers for the scene.
  33339. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33340. * and getCollidingSubMeshCandidates to their default function
  33341. */
  33342. setDefaultCandidateProviders(): void;
  33343. /**
  33344. * Gets the mesh that is currently under the pointer
  33345. */
  33346. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33347. /**
  33348. * Gets or sets the current on-screen X position of the pointer
  33349. */
  33350. pointerX: number;
  33351. /**
  33352. * Gets or sets the current on-screen Y position of the pointer
  33353. */
  33354. pointerY: number;
  33355. /**
  33356. * Gets the cached material (ie. the latest rendered one)
  33357. * @returns the cached material
  33358. */
  33359. getCachedMaterial(): Nullable<Material>;
  33360. /**
  33361. * Gets the cached effect (ie. the latest rendered one)
  33362. * @returns the cached effect
  33363. */
  33364. getCachedEffect(): Nullable<Effect>;
  33365. /**
  33366. * Gets the cached visibility state (ie. the latest rendered one)
  33367. * @returns the cached visibility state
  33368. */
  33369. getCachedVisibility(): Nullable<number>;
  33370. /**
  33371. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33372. * @param material defines the current material
  33373. * @param effect defines the current effect
  33374. * @param visibility defines the current visibility state
  33375. * @returns true if one parameter is not cached
  33376. */
  33377. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33378. /**
  33379. * Gets the engine associated with the scene
  33380. * @returns an Engine
  33381. */
  33382. getEngine(): Engine;
  33383. /**
  33384. * Gets the total number of vertices rendered per frame
  33385. * @returns the total number of vertices rendered per frame
  33386. */
  33387. getTotalVertices(): number;
  33388. /**
  33389. * Gets the performance counter for total vertices
  33390. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33391. */
  33392. readonly totalVerticesPerfCounter: PerfCounter;
  33393. /**
  33394. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33395. * @returns the total number of active indices rendered per frame
  33396. */
  33397. getActiveIndices(): number;
  33398. /**
  33399. * Gets the performance counter for active indices
  33400. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33401. */
  33402. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33403. /**
  33404. * Gets the total number of active particles rendered per frame
  33405. * @returns the total number of active particles rendered per frame
  33406. */
  33407. getActiveParticles(): number;
  33408. /**
  33409. * Gets the performance counter for active particles
  33410. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33411. */
  33412. readonly activeParticlesPerfCounter: PerfCounter;
  33413. /**
  33414. * Gets the total number of active bones rendered per frame
  33415. * @returns the total number of active bones rendered per frame
  33416. */
  33417. getActiveBones(): number;
  33418. /**
  33419. * Gets the performance counter for active bones
  33420. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33421. */
  33422. readonly activeBonesPerfCounter: PerfCounter;
  33423. /**
  33424. * Gets the array of active meshes
  33425. * @returns an array of AbstractMesh
  33426. */
  33427. getActiveMeshes(): SmartArray<AbstractMesh>;
  33428. /**
  33429. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33430. * @returns a number
  33431. */
  33432. getAnimationRatio(): number;
  33433. /**
  33434. * Gets an unique Id for the current render phase
  33435. * @returns a number
  33436. */
  33437. getRenderId(): number;
  33438. /**
  33439. * Gets an unique Id for the current frame
  33440. * @returns a number
  33441. */
  33442. getFrameId(): number;
  33443. /** Call this function if you want to manually increment the render Id*/
  33444. incrementRenderId(): void;
  33445. private _updatePointerPosition;
  33446. private _createUbo;
  33447. private _setRayOnPointerInfo;
  33448. /**
  33449. * Use this method to simulate a pointer move on a mesh
  33450. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33451. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33452. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33453. * @returns the current scene
  33454. */
  33455. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33456. private _processPointerMove;
  33457. private _checkPrePointerObservable;
  33458. /**
  33459. * Use this method to simulate a pointer down on a mesh
  33460. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33461. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33462. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33463. * @returns the current scene
  33464. */
  33465. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33466. private _processPointerDown;
  33467. /**
  33468. * Use this method to simulate a pointer up on a mesh
  33469. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33470. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33471. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33472. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33473. * @returns the current scene
  33474. */
  33475. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33476. private _processPointerUp;
  33477. /**
  33478. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33479. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33480. * @returns true if the pointer was captured
  33481. */
  33482. isPointerCaptured(pointerId?: number): boolean;
  33483. /** @hidden */
  33484. _isPointerSwiping(): boolean;
  33485. /**
  33486. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33487. * @param attachUp defines if you want to attach events to pointerup
  33488. * @param attachDown defines if you want to attach events to pointerdown
  33489. * @param attachMove defines if you want to attach events to pointermove
  33490. */
  33491. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33492. /** Detaches all event handlers*/
  33493. detachControl(): void;
  33494. /**
  33495. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33496. * Delay loaded resources are not taking in account
  33497. * @return true if all required resources are ready
  33498. */
  33499. isReady(): boolean;
  33500. /** Resets all cached information relative to material (including effect and visibility) */
  33501. resetCachedMaterial(): void;
  33502. /**
  33503. * Registers a function to be called before every frame render
  33504. * @param func defines the function to register
  33505. */
  33506. registerBeforeRender(func: () => void): void;
  33507. /**
  33508. * Unregisters a function called before every frame render
  33509. * @param func defines the function to unregister
  33510. */
  33511. unregisterBeforeRender(func: () => void): void;
  33512. /**
  33513. * Registers a function to be called after every frame render
  33514. * @param func defines the function to register
  33515. */
  33516. registerAfterRender(func: () => void): void;
  33517. /**
  33518. * Unregisters a function called after every frame render
  33519. * @param func defines the function to unregister
  33520. */
  33521. unregisterAfterRender(func: () => void): void;
  33522. private _executeOnceBeforeRender;
  33523. /**
  33524. * The provided function will run before render once and will be disposed afterwards.
  33525. * A timeout delay can be provided so that the function will be executed in N ms.
  33526. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33527. * @param func The function to be executed.
  33528. * @param timeout optional delay in ms
  33529. */
  33530. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33531. /** @hidden */
  33532. _addPendingData(data: any): void;
  33533. /** @hidden */
  33534. _removePendingData(data: any): void;
  33535. /**
  33536. * Returns the number of items waiting to be loaded
  33537. * @returns the number of items waiting to be loaded
  33538. */
  33539. getWaitingItemsCount(): number;
  33540. /**
  33541. * Returns a boolean indicating if the scene is still loading data
  33542. */
  33543. readonly isLoading: boolean;
  33544. /**
  33545. * Registers a function to be executed when the scene is ready
  33546. * @param {Function} func - the function to be executed
  33547. */
  33548. executeWhenReady(func: () => void): void;
  33549. /**
  33550. * Returns a promise that resolves when the scene is ready
  33551. * @returns A promise that resolves when the scene is ready
  33552. */
  33553. whenReadyAsync(): Promise<void>;
  33554. /** @hidden */
  33555. _checkIsReady(): void;
  33556. /**
  33557. * Gets all animatable attached to the scene
  33558. */
  33559. readonly animatables: Animatable[];
  33560. /**
  33561. * Resets the last animation time frame.
  33562. * Useful to override when animations start running when loading a scene for the first time.
  33563. */
  33564. resetLastAnimationTimeFrame(): void;
  33565. /**
  33566. * Gets the current view matrix
  33567. * @returns a Matrix
  33568. */
  33569. getViewMatrix(): Matrix;
  33570. /**
  33571. * Gets the current projection matrix
  33572. * @returns a Matrix
  33573. */
  33574. getProjectionMatrix(): Matrix;
  33575. /**
  33576. * Gets the current transform matrix
  33577. * @returns a Matrix made of View * Projection
  33578. */
  33579. getTransformMatrix(): Matrix;
  33580. /**
  33581. * Sets the current transform matrix
  33582. * @param viewL defines the View matrix to use
  33583. * @param projectionL defines the Projection matrix to use
  33584. * @param viewR defines the right View matrix to use (if provided)
  33585. * @param projectionR defines the right Projection matrix to use (if provided)
  33586. */
  33587. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33588. /**
  33589. * Gets the uniform buffer used to store scene data
  33590. * @returns a UniformBuffer
  33591. */
  33592. getSceneUniformBuffer(): UniformBuffer;
  33593. /**
  33594. * Gets an unique (relatively to the current scene) Id
  33595. * @returns an unique number for the scene
  33596. */
  33597. getUniqueId(): number;
  33598. /**
  33599. * Add a mesh to the list of scene's meshes
  33600. * @param newMesh defines the mesh to add
  33601. * @param recursive if all child meshes should also be added to the scene
  33602. */
  33603. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33604. /**
  33605. * Remove a mesh for the list of scene's meshes
  33606. * @param toRemove defines the mesh to remove
  33607. * @param recursive if all child meshes should also be removed from the scene
  33608. * @returns the index where the mesh was in the mesh list
  33609. */
  33610. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33611. /**
  33612. * Add a transform node to the list of scene's transform nodes
  33613. * @param newTransformNode defines the transform node to add
  33614. */
  33615. addTransformNode(newTransformNode: TransformNode): void;
  33616. /**
  33617. * Remove a transform node for the list of scene's transform nodes
  33618. * @param toRemove defines the transform node to remove
  33619. * @returns the index where the transform node was in the transform node list
  33620. */
  33621. removeTransformNode(toRemove: TransformNode): number;
  33622. /**
  33623. * Remove a skeleton for the list of scene's skeletons
  33624. * @param toRemove defines the skeleton to remove
  33625. * @returns the index where the skeleton was in the skeleton list
  33626. */
  33627. removeSkeleton(toRemove: Skeleton): number;
  33628. /**
  33629. * Remove a morph target for the list of scene's morph targets
  33630. * @param toRemove defines the morph target to remove
  33631. * @returns the index where the morph target was in the morph target list
  33632. */
  33633. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33634. /**
  33635. * Remove a light for the list of scene's lights
  33636. * @param toRemove defines the light to remove
  33637. * @returns the index where the light was in the light list
  33638. */
  33639. removeLight(toRemove: Light): number;
  33640. /**
  33641. * Remove a camera for the list of scene's cameras
  33642. * @param toRemove defines the camera to remove
  33643. * @returns the index where the camera was in the camera list
  33644. */
  33645. removeCamera(toRemove: Camera): number;
  33646. /**
  33647. * Remove a particle system for the list of scene's particle systems
  33648. * @param toRemove defines the particle system to remove
  33649. * @returns the index where the particle system was in the particle system list
  33650. */
  33651. removeParticleSystem(toRemove: IParticleSystem): number;
  33652. /**
  33653. * Remove a animation for the list of scene's animations
  33654. * @param toRemove defines the animation to remove
  33655. * @returns the index where the animation was in the animation list
  33656. */
  33657. removeAnimation(toRemove: Animation): number;
  33658. /**
  33659. * Removes the given animation group from this scene.
  33660. * @param toRemove The animation group to remove
  33661. * @returns The index of the removed animation group
  33662. */
  33663. removeAnimationGroup(toRemove: AnimationGroup): number;
  33664. /**
  33665. * Removes the given multi-material from this scene.
  33666. * @param toRemove The multi-material to remove
  33667. * @returns The index of the removed multi-material
  33668. */
  33669. removeMultiMaterial(toRemove: MultiMaterial): number;
  33670. /**
  33671. * Removes the given material from this scene.
  33672. * @param toRemove The material to remove
  33673. * @returns The index of the removed material
  33674. */
  33675. removeMaterial(toRemove: Material): number;
  33676. /**
  33677. * Removes the given action manager from this scene.
  33678. * @param toRemove The action manager to remove
  33679. * @returns The index of the removed action manager
  33680. */
  33681. removeActionManager(toRemove: AbstractActionManager): number;
  33682. /**
  33683. * Removes the given texture from this scene.
  33684. * @param toRemove The texture to remove
  33685. * @returns The index of the removed texture
  33686. */
  33687. removeTexture(toRemove: BaseTexture): number;
  33688. /**
  33689. * Adds the given light to this scene
  33690. * @param newLight The light to add
  33691. */
  33692. addLight(newLight: Light): void;
  33693. /**
  33694. * Sorts the list list based on light priorities
  33695. */
  33696. sortLightsByPriority(): void;
  33697. /**
  33698. * Adds the given camera to this scene
  33699. * @param newCamera The camera to add
  33700. */
  33701. addCamera(newCamera: Camera): void;
  33702. /**
  33703. * Adds the given skeleton to this scene
  33704. * @param newSkeleton The skeleton to add
  33705. */
  33706. addSkeleton(newSkeleton: Skeleton): void;
  33707. /**
  33708. * Adds the given particle system to this scene
  33709. * @param newParticleSystem The particle system to add
  33710. */
  33711. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33712. /**
  33713. * Adds the given animation to this scene
  33714. * @param newAnimation The animation to add
  33715. */
  33716. addAnimation(newAnimation: Animation): void;
  33717. /**
  33718. * Adds the given animation group to this scene.
  33719. * @param newAnimationGroup The animation group to add
  33720. */
  33721. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33722. /**
  33723. * Adds the given multi-material to this scene
  33724. * @param newMultiMaterial The multi-material to add
  33725. */
  33726. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33727. /**
  33728. * Adds the given material to this scene
  33729. * @param newMaterial The material to add
  33730. */
  33731. addMaterial(newMaterial: Material): void;
  33732. /**
  33733. * Adds the given morph target to this scene
  33734. * @param newMorphTargetManager The morph target to add
  33735. */
  33736. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33737. /**
  33738. * Adds the given geometry to this scene
  33739. * @param newGeometry The geometry to add
  33740. */
  33741. addGeometry(newGeometry: Geometry): void;
  33742. /**
  33743. * Adds the given action manager to this scene
  33744. * @param newActionManager The action manager to add
  33745. */
  33746. addActionManager(newActionManager: AbstractActionManager): void;
  33747. /**
  33748. * Adds the given texture to this scene.
  33749. * @param newTexture The texture to add
  33750. */
  33751. addTexture(newTexture: BaseTexture): void;
  33752. /**
  33753. * Switch active camera
  33754. * @param newCamera defines the new active camera
  33755. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33756. */
  33757. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33758. /**
  33759. * sets the active camera of the scene using its ID
  33760. * @param id defines the camera's ID
  33761. * @return the new active camera or null if none found.
  33762. */
  33763. setActiveCameraByID(id: string): Nullable<Camera>;
  33764. /**
  33765. * sets the active camera of the scene using its name
  33766. * @param name defines the camera's name
  33767. * @returns the new active camera or null if none found.
  33768. */
  33769. setActiveCameraByName(name: string): Nullable<Camera>;
  33770. /**
  33771. * get an animation group using its name
  33772. * @param name defines the material's name
  33773. * @return the animation group or null if none found.
  33774. */
  33775. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33776. /**
  33777. * Get a material using its unique id
  33778. * @param uniqueId defines the material's unique id
  33779. * @return the material or null if none found.
  33780. */
  33781. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33782. /**
  33783. * get a material using its id
  33784. * @param id defines the material's ID
  33785. * @return the material or null if none found.
  33786. */
  33787. getMaterialByID(id: string): Nullable<Material>;
  33788. /**
  33789. * Gets a material using its name
  33790. * @param name defines the material's name
  33791. * @return the material or null if none found.
  33792. */
  33793. getMaterialByName(name: string): Nullable<Material>;
  33794. /**
  33795. * Gets a camera using its id
  33796. * @param id defines the id to look for
  33797. * @returns the camera or null if not found
  33798. */
  33799. getCameraByID(id: string): Nullable<Camera>;
  33800. /**
  33801. * Gets a camera using its unique id
  33802. * @param uniqueId defines the unique id to look for
  33803. * @returns the camera or null if not found
  33804. */
  33805. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33806. /**
  33807. * Gets a camera using its name
  33808. * @param name defines the camera's name
  33809. * @return the camera or null if none found.
  33810. */
  33811. getCameraByName(name: string): Nullable<Camera>;
  33812. /**
  33813. * Gets a bone using its id
  33814. * @param id defines the bone's id
  33815. * @return the bone or null if not found
  33816. */
  33817. getBoneByID(id: string): Nullable<Bone>;
  33818. /**
  33819. * Gets a bone using its id
  33820. * @param name defines the bone's name
  33821. * @return the bone or null if not found
  33822. */
  33823. getBoneByName(name: string): Nullable<Bone>;
  33824. /**
  33825. * Gets a light node using its name
  33826. * @param name defines the the light's name
  33827. * @return the light or null if none found.
  33828. */
  33829. getLightByName(name: string): Nullable<Light>;
  33830. /**
  33831. * Gets a light node using its id
  33832. * @param id defines the light's id
  33833. * @return the light or null if none found.
  33834. */
  33835. getLightByID(id: string): Nullable<Light>;
  33836. /**
  33837. * Gets a light node using its scene-generated unique ID
  33838. * @param uniqueId defines the light's unique id
  33839. * @return the light or null if none found.
  33840. */
  33841. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33842. /**
  33843. * Gets a particle system by id
  33844. * @param id defines the particle system id
  33845. * @return the corresponding system or null if none found
  33846. */
  33847. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33848. /**
  33849. * Gets a geometry using its ID
  33850. * @param id defines the geometry's id
  33851. * @return the geometry or null if none found.
  33852. */
  33853. getGeometryByID(id: string): Nullable<Geometry>;
  33854. private _getGeometryByUniqueID;
  33855. /**
  33856. * Add a new geometry to this scene
  33857. * @param geometry defines the geometry to be added to the scene.
  33858. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33859. * @return a boolean defining if the geometry was added or not
  33860. */
  33861. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33862. /**
  33863. * Removes an existing geometry
  33864. * @param geometry defines the geometry to be removed from the scene
  33865. * @return a boolean defining if the geometry was removed or not
  33866. */
  33867. removeGeometry(geometry: Geometry): boolean;
  33868. /**
  33869. * Gets the list of geometries attached to the scene
  33870. * @returns an array of Geometry
  33871. */
  33872. getGeometries(): Geometry[];
  33873. /**
  33874. * Gets the first added mesh found of a given ID
  33875. * @param id defines the id to search for
  33876. * @return the mesh found or null if not found at all
  33877. */
  33878. getMeshByID(id: string): Nullable<AbstractMesh>;
  33879. /**
  33880. * Gets a list of meshes using their id
  33881. * @param id defines the id to search for
  33882. * @returns a list of meshes
  33883. */
  33884. getMeshesByID(id: string): Array<AbstractMesh>;
  33885. /**
  33886. * Gets the first added transform node found of a given ID
  33887. * @param id defines the id to search for
  33888. * @return the found transform node or null if not found at all.
  33889. */
  33890. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33891. /**
  33892. * Gets a transform node with its auto-generated unique id
  33893. * @param uniqueId efines the unique id to search for
  33894. * @return the found transform node or null if not found at all.
  33895. */
  33896. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33897. /**
  33898. * Gets a list of transform nodes using their id
  33899. * @param id defines the id to search for
  33900. * @returns a list of transform nodes
  33901. */
  33902. getTransformNodesByID(id: string): Array<TransformNode>;
  33903. /**
  33904. * Gets a mesh with its auto-generated unique id
  33905. * @param uniqueId defines the unique id to search for
  33906. * @return the found mesh or null if not found at all.
  33907. */
  33908. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33909. /**
  33910. * Gets a the last added mesh using a given id
  33911. * @param id defines the id to search for
  33912. * @return the found mesh or null if not found at all.
  33913. */
  33914. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33915. /**
  33916. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33917. * @param id defines the id to search for
  33918. * @return the found node or null if not found at all
  33919. */
  33920. getLastEntryByID(id: string): Nullable<Node>;
  33921. /**
  33922. * Gets a node (Mesh, Camera, Light) using a given id
  33923. * @param id defines the id to search for
  33924. * @return the found node or null if not found at all
  33925. */
  33926. getNodeByID(id: string): Nullable<Node>;
  33927. /**
  33928. * Gets a node (Mesh, Camera, Light) using a given name
  33929. * @param name defines the name to search for
  33930. * @return the found node or null if not found at all.
  33931. */
  33932. getNodeByName(name: string): Nullable<Node>;
  33933. /**
  33934. * Gets a mesh using a given name
  33935. * @param name defines the name to search for
  33936. * @return the found mesh or null if not found at all.
  33937. */
  33938. getMeshByName(name: string): Nullable<AbstractMesh>;
  33939. /**
  33940. * Gets a transform node using a given name
  33941. * @param name defines the name to search for
  33942. * @return the found transform node or null if not found at all.
  33943. */
  33944. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33945. /**
  33946. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33947. * @param id defines the id to search for
  33948. * @return the found skeleton or null if not found at all.
  33949. */
  33950. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33951. /**
  33952. * Gets a skeleton using a given auto generated unique id
  33953. * @param uniqueId defines the unique id to search for
  33954. * @return the found skeleton or null if not found at all.
  33955. */
  33956. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33957. /**
  33958. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33959. * @param id defines the id to search for
  33960. * @return the found skeleton or null if not found at all.
  33961. */
  33962. getSkeletonById(id: string): Nullable<Skeleton>;
  33963. /**
  33964. * Gets a skeleton using a given name
  33965. * @param name defines the name to search for
  33966. * @return the found skeleton or null if not found at all.
  33967. */
  33968. getSkeletonByName(name: string): Nullable<Skeleton>;
  33969. /**
  33970. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33971. * @param id defines the id to search for
  33972. * @return the found morph target manager or null if not found at all.
  33973. */
  33974. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33975. /**
  33976. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33977. * @param id defines the id to search for
  33978. * @return the found morph target or null if not found at all.
  33979. */
  33980. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33981. /**
  33982. * Gets a boolean indicating if the given mesh is active
  33983. * @param mesh defines the mesh to look for
  33984. * @returns true if the mesh is in the active list
  33985. */
  33986. isActiveMesh(mesh: AbstractMesh): boolean;
  33987. /**
  33988. * Return a unique id as a string which can serve as an identifier for the scene
  33989. */
  33990. readonly uid: string;
  33991. /**
  33992. * Add an externaly attached data from its key.
  33993. * This method call will fail and return false, if such key already exists.
  33994. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33995. * @param key the unique key that identifies the data
  33996. * @param data the data object to associate to the key for this Engine instance
  33997. * @return true if no such key were already present and the data was added successfully, false otherwise
  33998. */
  33999. addExternalData<T>(key: string, data: T): boolean;
  34000. /**
  34001. * Get an externaly attached data from its key
  34002. * @param key the unique key that identifies the data
  34003. * @return the associated data, if present (can be null), or undefined if not present
  34004. */
  34005. getExternalData<T>(key: string): Nullable<T>;
  34006. /**
  34007. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34008. * @param key the unique key that identifies the data
  34009. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34010. * @return the associated data, can be null if the factory returned null.
  34011. */
  34012. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34013. /**
  34014. * Remove an externaly attached data from the Engine instance
  34015. * @param key the unique key that identifies the data
  34016. * @return true if the data was successfully removed, false if it doesn't exist
  34017. */
  34018. removeExternalData(key: string): boolean;
  34019. private _evaluateSubMesh;
  34020. /**
  34021. * Clear the processed materials smart array preventing retention point in material dispose.
  34022. */
  34023. freeProcessedMaterials(): void;
  34024. private _preventFreeActiveMeshesAndRenderingGroups;
  34025. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34026. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34027. * when disposing several meshes in a row or a hierarchy of meshes.
  34028. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34029. */
  34030. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34031. /**
  34032. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34033. */
  34034. freeActiveMeshes(): void;
  34035. /**
  34036. * Clear the info related to rendering groups preventing retention points during dispose.
  34037. */
  34038. freeRenderingGroups(): void;
  34039. /** @hidden */
  34040. _isInIntermediateRendering(): boolean;
  34041. /**
  34042. * Lambda returning the list of potentially active meshes.
  34043. */
  34044. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34045. /**
  34046. * Lambda returning the list of potentially active sub meshes.
  34047. */
  34048. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34049. /**
  34050. * Lambda returning the list of potentially intersecting sub meshes.
  34051. */
  34052. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34053. /**
  34054. * Lambda returning the list of potentially colliding sub meshes.
  34055. */
  34056. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34057. private _activeMeshesFrozen;
  34058. /**
  34059. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34060. * @returns the current scene
  34061. */
  34062. freezeActiveMeshes(): Scene;
  34063. /**
  34064. * Use this function to restart evaluating active meshes on every frame
  34065. * @returns the current scene
  34066. */
  34067. unfreezeActiveMeshes(): Scene;
  34068. private _evaluateActiveMeshes;
  34069. private _activeMesh;
  34070. /**
  34071. * Update the transform matrix to update from the current active camera
  34072. * @param force defines a boolean used to force the update even if cache is up to date
  34073. */
  34074. updateTransformMatrix(force?: boolean): void;
  34075. private _bindFrameBuffer;
  34076. /** @hidden */
  34077. _allowPostProcessClearColor: boolean;
  34078. /** @hidden */
  34079. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34080. private _processSubCameras;
  34081. private _checkIntersections;
  34082. /** @hidden */
  34083. _advancePhysicsEngineStep(step: number): void;
  34084. /**
  34085. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34086. */
  34087. getDeterministicFrameTime: () => number;
  34088. /** @hidden */
  34089. _animate(): void;
  34090. /**
  34091. * Render the scene
  34092. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34093. */
  34094. render(updateCameras?: boolean): void;
  34095. /**
  34096. * Freeze all materials
  34097. * A frozen material will not be updatable but should be faster to render
  34098. */
  34099. freezeMaterials(): void;
  34100. /**
  34101. * Unfreeze all materials
  34102. * A frozen material will not be updatable but should be faster to render
  34103. */
  34104. unfreezeMaterials(): void;
  34105. /**
  34106. * Releases all held ressources
  34107. */
  34108. dispose(): void;
  34109. /**
  34110. * Gets if the scene is already disposed
  34111. */
  34112. readonly isDisposed: boolean;
  34113. /**
  34114. * Call this function to reduce memory footprint of the scene.
  34115. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34116. */
  34117. clearCachedVertexData(): void;
  34118. /**
  34119. * This function will remove the local cached buffer data from texture.
  34120. * It will save memory but will prevent the texture from being rebuilt
  34121. */
  34122. cleanCachedTextureBuffer(): void;
  34123. /**
  34124. * Get the world extend vectors with an optional filter
  34125. *
  34126. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34127. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34128. */
  34129. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34130. min: Vector3;
  34131. max: Vector3;
  34132. };
  34133. /**
  34134. * Creates a ray that can be used to pick in the scene
  34135. * @param x defines the x coordinate of the origin (on-screen)
  34136. * @param y defines the y coordinate of the origin (on-screen)
  34137. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34138. * @param camera defines the camera to use for the picking
  34139. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34140. * @returns a Ray
  34141. */
  34142. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34143. /**
  34144. * Creates a ray that can be used to pick in the scene
  34145. * @param x defines the x coordinate of the origin (on-screen)
  34146. * @param y defines the y coordinate of the origin (on-screen)
  34147. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34148. * @param result defines the ray where to store the picking ray
  34149. * @param camera defines the camera to use for the picking
  34150. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34151. * @returns the current scene
  34152. */
  34153. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34154. /**
  34155. * Creates a ray that can be used to pick in the scene
  34156. * @param x defines the x coordinate of the origin (on-screen)
  34157. * @param y defines the y coordinate of the origin (on-screen)
  34158. * @param camera defines the camera to use for the picking
  34159. * @returns a Ray
  34160. */
  34161. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34162. /**
  34163. * Creates a ray that can be used to pick in the scene
  34164. * @param x defines the x coordinate of the origin (on-screen)
  34165. * @param y defines the y coordinate of the origin (on-screen)
  34166. * @param result defines the ray where to store the picking ray
  34167. * @param camera defines the camera to use for the picking
  34168. * @returns the current scene
  34169. */
  34170. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34171. /** Launch a ray to try to pick a mesh in the scene
  34172. * @param x position on screen
  34173. * @param y position on screen
  34174. * @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
  34175. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34176. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34177. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34178. * @returns a PickingInfo
  34179. */
  34180. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  34181. /** Use the given ray to pick a mesh in the scene
  34182. * @param ray The ray to use to pick meshes
  34183. * @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
  34184. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34185. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34186. * @returns a PickingInfo
  34187. */
  34188. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34189. /**
  34190. * Launch a ray to try to pick a mesh in the scene
  34191. * @param x X position on screen
  34192. * @param y Y position on screen
  34193. * @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
  34194. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34195. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34196. * @returns an array of PickingInfo
  34197. */
  34198. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34199. /**
  34200. * Launch a ray to try to pick a mesh in the scene
  34201. * @param ray Ray to use
  34202. * @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
  34203. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34204. * @returns an array of PickingInfo
  34205. */
  34206. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34207. /**
  34208. * Force the value of meshUnderPointer
  34209. * @param mesh defines the mesh to use
  34210. */
  34211. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34212. /**
  34213. * Gets the mesh under the pointer
  34214. * @returns a Mesh or null if no mesh is under the pointer
  34215. */
  34216. getPointerOverMesh(): Nullable<AbstractMesh>;
  34217. /** @hidden */
  34218. _rebuildGeometries(): void;
  34219. /** @hidden */
  34220. _rebuildTextures(): void;
  34221. private _getByTags;
  34222. /**
  34223. * Get a list of meshes by tags
  34224. * @param tagsQuery defines the tags query to use
  34225. * @param forEach defines a predicate used to filter results
  34226. * @returns an array of Mesh
  34227. */
  34228. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34229. /**
  34230. * Get a list of cameras by tags
  34231. * @param tagsQuery defines the tags query to use
  34232. * @param forEach defines a predicate used to filter results
  34233. * @returns an array of Camera
  34234. */
  34235. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34236. /**
  34237. * Get a list of lights by tags
  34238. * @param tagsQuery defines the tags query to use
  34239. * @param forEach defines a predicate used to filter results
  34240. * @returns an array of Light
  34241. */
  34242. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34243. /**
  34244. * Get a list of materials by tags
  34245. * @param tagsQuery defines the tags query to use
  34246. * @param forEach defines a predicate used to filter results
  34247. * @returns an array of Material
  34248. */
  34249. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34250. /**
  34251. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34252. * This allowed control for front to back rendering or reversly depending of the special needs.
  34253. *
  34254. * @param renderingGroupId The rendering group id corresponding to its index
  34255. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34256. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34257. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34258. */
  34259. 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;
  34260. /**
  34261. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34262. *
  34263. * @param renderingGroupId The rendering group id corresponding to its index
  34264. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34265. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34266. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34267. */
  34268. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34269. /**
  34270. * Gets the current auto clear configuration for one rendering group of the rendering
  34271. * manager.
  34272. * @param index the rendering group index to get the information for
  34273. * @returns The auto clear setup for the requested rendering group
  34274. */
  34275. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34276. private _blockMaterialDirtyMechanism;
  34277. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34278. blockMaterialDirtyMechanism: boolean;
  34279. /**
  34280. * Will flag all materials as dirty to trigger new shader compilation
  34281. * @param flag defines the flag used to specify which material part must be marked as dirty
  34282. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34283. */
  34284. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34285. /** @hidden */
  34286. _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;
  34287. /** @hidden */
  34288. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34289. }
  34290. }
  34291. declare module "babylonjs/assetContainer" {
  34292. import { AbstractScene } from "babylonjs/abstractScene";
  34293. import { Scene } from "babylonjs/scene";
  34294. import { Mesh } from "babylonjs/Meshes/mesh";
  34295. /**
  34296. * Set of assets to keep when moving a scene into an asset container.
  34297. */
  34298. export class KeepAssets extends AbstractScene {
  34299. }
  34300. /**
  34301. * Container with a set of assets that can be added or removed from a scene.
  34302. */
  34303. export class AssetContainer extends AbstractScene {
  34304. /**
  34305. * The scene the AssetContainer belongs to.
  34306. */
  34307. scene: Scene;
  34308. /**
  34309. * Instantiates an AssetContainer.
  34310. * @param scene The scene the AssetContainer belongs to.
  34311. */
  34312. constructor(scene: Scene);
  34313. /**
  34314. * Adds all the assets from the container to the scene.
  34315. */
  34316. addAllToScene(): void;
  34317. /**
  34318. * Removes all the assets in the container from the scene
  34319. */
  34320. removeAllFromScene(): void;
  34321. /**
  34322. * Disposes all the assets in the container
  34323. */
  34324. dispose(): void;
  34325. private _moveAssets;
  34326. /**
  34327. * Removes all the assets contained in the scene and adds them to the container.
  34328. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34329. */
  34330. moveAllFromScene(keepAssets?: KeepAssets): void;
  34331. /**
  34332. * 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.
  34333. * @returns the root mesh
  34334. */
  34335. createRootMesh(): Mesh;
  34336. }
  34337. }
  34338. declare module "babylonjs/abstractScene" {
  34339. import { Scene } from "babylonjs/scene";
  34340. import { Nullable } from "babylonjs/types";
  34341. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34342. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34343. import { Geometry } from "babylonjs/Meshes/geometry";
  34344. import { Skeleton } from "babylonjs/Bones/skeleton";
  34345. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34346. import { AssetContainer } from "babylonjs/assetContainer";
  34347. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34348. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34349. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34350. import { Material } from "babylonjs/Materials/material";
  34351. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34352. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34353. import { Camera } from "babylonjs/Cameras/camera";
  34354. import { Light } from "babylonjs/Lights/light";
  34355. import { Node } from "babylonjs/node";
  34356. import { Animation } from "babylonjs/Animations/animation";
  34357. /**
  34358. * Defines how the parser contract is defined.
  34359. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34360. */
  34361. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34362. /**
  34363. * Defines how the individual parser contract is defined.
  34364. * These parser can parse an individual asset
  34365. */
  34366. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34367. /**
  34368. * Base class of the scene acting as a container for the different elements composing a scene.
  34369. * This class is dynamically extended by the different components of the scene increasing
  34370. * flexibility and reducing coupling
  34371. */
  34372. export abstract class AbstractScene {
  34373. /**
  34374. * Stores the list of available parsers in the application.
  34375. */
  34376. private static _BabylonFileParsers;
  34377. /**
  34378. * Stores the list of available individual parsers in the application.
  34379. */
  34380. private static _IndividualBabylonFileParsers;
  34381. /**
  34382. * Adds a parser in the list of available ones
  34383. * @param name Defines the name of the parser
  34384. * @param parser Defines the parser to add
  34385. */
  34386. static AddParser(name: string, parser: BabylonFileParser): void;
  34387. /**
  34388. * Gets a general parser from the list of avaialble ones
  34389. * @param name Defines the name of the parser
  34390. * @returns the requested parser or null
  34391. */
  34392. static GetParser(name: string): Nullable<BabylonFileParser>;
  34393. /**
  34394. * Adds n individual parser in the list of available ones
  34395. * @param name Defines the name of the parser
  34396. * @param parser Defines the parser to add
  34397. */
  34398. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34399. /**
  34400. * Gets an individual parser from the list of avaialble ones
  34401. * @param name Defines the name of the parser
  34402. * @returns the requested parser or null
  34403. */
  34404. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34405. /**
  34406. * Parser json data and populate both a scene and its associated container object
  34407. * @param jsonData Defines the data to parse
  34408. * @param scene Defines the scene to parse the data for
  34409. * @param container Defines the container attached to the parsing sequence
  34410. * @param rootUrl Defines the root url of the data
  34411. */
  34412. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34413. /**
  34414. * Gets the list of root nodes (ie. nodes with no parent)
  34415. */
  34416. rootNodes: Node[];
  34417. /** All of the cameras added to this scene
  34418. * @see http://doc.babylonjs.com/babylon101/cameras
  34419. */
  34420. cameras: Camera[];
  34421. /**
  34422. * All of the lights added to this scene
  34423. * @see http://doc.babylonjs.com/babylon101/lights
  34424. */
  34425. lights: Light[];
  34426. /**
  34427. * All of the (abstract) meshes added to this scene
  34428. */
  34429. meshes: AbstractMesh[];
  34430. /**
  34431. * The list of skeletons added to the scene
  34432. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34433. */
  34434. skeletons: Skeleton[];
  34435. /**
  34436. * All of the particle systems added to this scene
  34437. * @see http://doc.babylonjs.com/babylon101/particles
  34438. */
  34439. particleSystems: IParticleSystem[];
  34440. /**
  34441. * Gets a list of Animations associated with the scene
  34442. */
  34443. animations: Animation[];
  34444. /**
  34445. * All of the animation groups added to this scene
  34446. * @see http://doc.babylonjs.com/how_to/group
  34447. */
  34448. animationGroups: AnimationGroup[];
  34449. /**
  34450. * All of the multi-materials added to this scene
  34451. * @see http://doc.babylonjs.com/how_to/multi_materials
  34452. */
  34453. multiMaterials: MultiMaterial[];
  34454. /**
  34455. * All of the materials added to this scene
  34456. * In the context of a Scene, it is not supposed to be modified manually.
  34457. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34458. * Note also that the order of the Material wihin the array is not significant and might change.
  34459. * @see http://doc.babylonjs.com/babylon101/materials
  34460. */
  34461. materials: Material[];
  34462. /**
  34463. * The list of morph target managers added to the scene
  34464. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34465. */
  34466. morphTargetManagers: MorphTargetManager[];
  34467. /**
  34468. * The list of geometries used in the scene.
  34469. */
  34470. geometries: Geometry[];
  34471. /**
  34472. * All of the tranform nodes added to this scene
  34473. * In the context of a Scene, it is not supposed to be modified manually.
  34474. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34475. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34476. * @see http://doc.babylonjs.com/how_to/transformnode
  34477. */
  34478. transformNodes: TransformNode[];
  34479. /**
  34480. * ActionManagers available on the scene.
  34481. */
  34482. actionManagers: AbstractActionManager[];
  34483. /**
  34484. * Textures to keep.
  34485. */
  34486. textures: BaseTexture[];
  34487. /**
  34488. * Environment texture for the scene
  34489. */
  34490. environmentTexture: Nullable<BaseTexture>;
  34491. }
  34492. }
  34493. declare module "babylonjs/Audio/sound" {
  34494. import { Observable } from "babylonjs/Misc/observable";
  34495. import { Vector3 } from "babylonjs/Maths/math";
  34496. import { Nullable } from "babylonjs/types";
  34497. import { Scene } from "babylonjs/scene";
  34498. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34499. /**
  34500. * Defines a sound that can be played in the application.
  34501. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34502. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34503. */
  34504. export class Sound {
  34505. /**
  34506. * The name of the sound in the scene.
  34507. */
  34508. name: string;
  34509. /**
  34510. * Does the sound autoplay once loaded.
  34511. */
  34512. autoplay: boolean;
  34513. /**
  34514. * Does the sound loop after it finishes playing once.
  34515. */
  34516. loop: boolean;
  34517. /**
  34518. * Does the sound use a custom attenuation curve to simulate the falloff
  34519. * happening when the source gets further away from the camera.
  34520. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34521. */
  34522. useCustomAttenuation: boolean;
  34523. /**
  34524. * The sound track id this sound belongs to.
  34525. */
  34526. soundTrackId: number;
  34527. /**
  34528. * Is this sound currently played.
  34529. */
  34530. isPlaying: boolean;
  34531. /**
  34532. * Is this sound currently paused.
  34533. */
  34534. isPaused: boolean;
  34535. /**
  34536. * Does this sound enables spatial sound.
  34537. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34538. */
  34539. spatialSound: boolean;
  34540. /**
  34541. * Define the reference distance the sound should be heard perfectly.
  34542. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34543. */
  34544. refDistance: number;
  34545. /**
  34546. * Define the roll off factor of spatial sounds.
  34547. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34548. */
  34549. rolloffFactor: number;
  34550. /**
  34551. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34552. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34553. */
  34554. maxDistance: number;
  34555. /**
  34556. * Define the distance attenuation model the sound will follow.
  34557. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34558. */
  34559. distanceModel: string;
  34560. /**
  34561. * @hidden
  34562. * Back Compat
  34563. **/
  34564. onended: () => any;
  34565. /**
  34566. * Observable event when the current playing sound finishes.
  34567. */
  34568. onEndedObservable: Observable<Sound>;
  34569. private _panningModel;
  34570. private _playbackRate;
  34571. private _streaming;
  34572. private _startTime;
  34573. private _startOffset;
  34574. private _position;
  34575. /** @hidden */
  34576. _positionInEmitterSpace: boolean;
  34577. private _localDirection;
  34578. private _volume;
  34579. private _isReadyToPlay;
  34580. private _isDirectional;
  34581. private _readyToPlayCallback;
  34582. private _audioBuffer;
  34583. private _soundSource;
  34584. private _streamingSource;
  34585. private _soundPanner;
  34586. private _soundGain;
  34587. private _inputAudioNode;
  34588. private _outputAudioNode;
  34589. private _coneInnerAngle;
  34590. private _coneOuterAngle;
  34591. private _coneOuterGain;
  34592. private _scene;
  34593. private _connectedTransformNode;
  34594. private _customAttenuationFunction;
  34595. private _registerFunc;
  34596. private _isOutputConnected;
  34597. private _htmlAudioElement;
  34598. private _urlType;
  34599. /** @hidden */
  34600. static _SceneComponentInitialization: (scene: Scene) => void;
  34601. /**
  34602. * Create a sound and attach it to a scene
  34603. * @param name Name of your sound
  34604. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34605. * @param scene defines the scene the sound belongs to
  34606. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34607. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34608. */
  34609. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  34610. /**
  34611. * Release the sound and its associated resources
  34612. */
  34613. dispose(): void;
  34614. /**
  34615. * Gets if the sounds is ready to be played or not.
  34616. * @returns true if ready, otherwise false
  34617. */
  34618. isReady(): boolean;
  34619. private _soundLoaded;
  34620. /**
  34621. * Sets the data of the sound from an audiobuffer
  34622. * @param audioBuffer The audioBuffer containing the data
  34623. */
  34624. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34625. /**
  34626. * Updates the current sounds options such as maxdistance, loop...
  34627. * @param options A JSON object containing values named as the object properties
  34628. */
  34629. updateOptions(options: any): void;
  34630. private _createSpatialParameters;
  34631. private _updateSpatialParameters;
  34632. /**
  34633. * Switch the panning model to HRTF:
  34634. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34635. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34636. */
  34637. switchPanningModelToHRTF(): void;
  34638. /**
  34639. * Switch the panning model to Equal Power:
  34640. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34641. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34642. */
  34643. switchPanningModelToEqualPower(): void;
  34644. private _switchPanningModel;
  34645. /**
  34646. * Connect this sound to a sound track audio node like gain...
  34647. * @param soundTrackAudioNode the sound track audio node to connect to
  34648. */
  34649. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34650. /**
  34651. * Transform this sound into a directional source
  34652. * @param coneInnerAngle Size of the inner cone in degree
  34653. * @param coneOuterAngle Size of the outer cone in degree
  34654. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34655. */
  34656. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34657. /**
  34658. * Gets or sets the inner angle for the directional cone.
  34659. */
  34660. /**
  34661. * Gets or sets the inner angle for the directional cone.
  34662. */
  34663. directionalConeInnerAngle: number;
  34664. /**
  34665. * Gets or sets the outer angle for the directional cone.
  34666. */
  34667. /**
  34668. * Gets or sets the outer angle for the directional cone.
  34669. */
  34670. directionalConeOuterAngle: number;
  34671. /**
  34672. * Sets the position of the emitter if spatial sound is enabled
  34673. * @param newPosition Defines the new posisiton
  34674. */
  34675. setPosition(newPosition: Vector3): void;
  34676. /**
  34677. * Sets the local direction of the emitter if spatial sound is enabled
  34678. * @param newLocalDirection Defines the new local direction
  34679. */
  34680. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34681. private _updateDirection;
  34682. /** @hidden */
  34683. updateDistanceFromListener(): void;
  34684. /**
  34685. * Sets a new custom attenuation function for the sound.
  34686. * @param callback Defines the function used for the attenuation
  34687. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34688. */
  34689. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34690. /**
  34691. * Play the sound
  34692. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34693. * @param offset (optional) Start the sound setting it at a specific time
  34694. */
  34695. play(time?: number, offset?: number): void;
  34696. private _onended;
  34697. /**
  34698. * Stop the sound
  34699. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34700. */
  34701. stop(time?: number): void;
  34702. /**
  34703. * Put the sound in pause
  34704. */
  34705. pause(): void;
  34706. /**
  34707. * Sets a dedicated volume for this sounds
  34708. * @param newVolume Define the new volume of the sound
  34709. * @param time Define in how long the sound should be at this value
  34710. */
  34711. setVolume(newVolume: number, time?: number): void;
  34712. /**
  34713. * Set the sound play back rate
  34714. * @param newPlaybackRate Define the playback rate the sound should be played at
  34715. */
  34716. setPlaybackRate(newPlaybackRate: number): void;
  34717. /**
  34718. * Gets the volume of the sound.
  34719. * @returns the volume of the sound
  34720. */
  34721. getVolume(): number;
  34722. /**
  34723. * Attach the sound to a dedicated mesh
  34724. * @param transformNode The transform node to connect the sound with
  34725. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34726. */
  34727. attachToMesh(transformNode: TransformNode): void;
  34728. /**
  34729. * Detach the sound from the previously attached mesh
  34730. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34731. */
  34732. detachFromMesh(): void;
  34733. private _onRegisterAfterWorldMatrixUpdate;
  34734. /**
  34735. * Clone the current sound in the scene.
  34736. * @returns the new sound clone
  34737. */
  34738. clone(): Nullable<Sound>;
  34739. /**
  34740. * Gets the current underlying audio buffer containing the data
  34741. * @returns the audio buffer
  34742. */
  34743. getAudioBuffer(): Nullable<AudioBuffer>;
  34744. /**
  34745. * Serializes the Sound in a JSON representation
  34746. * @returns the JSON representation of the sound
  34747. */
  34748. serialize(): any;
  34749. /**
  34750. * Parse a JSON representation of a sound to innstantiate in a given scene
  34751. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34752. * @param scene Define the scene the new parsed sound should be created in
  34753. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34754. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34755. * @returns the newly parsed sound
  34756. */
  34757. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34758. }
  34759. }
  34760. declare module "babylonjs/Actions/directAudioActions" {
  34761. import { Action } from "babylonjs/Actions/action";
  34762. import { Condition } from "babylonjs/Actions/condition";
  34763. import { Sound } from "babylonjs/Audio/sound";
  34764. /**
  34765. * This defines an action helpful to play a defined sound on a triggered action.
  34766. */
  34767. export class PlaySoundAction extends Action {
  34768. private _sound;
  34769. /**
  34770. * Instantiate the action
  34771. * @param triggerOptions defines the trigger options
  34772. * @param sound defines the sound to play
  34773. * @param condition defines the trigger related conditions
  34774. */
  34775. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34776. /** @hidden */
  34777. _prepare(): void;
  34778. /**
  34779. * Execute the action and play the sound.
  34780. */
  34781. execute(): void;
  34782. /**
  34783. * Serializes the actions and its related information.
  34784. * @param parent defines the object to serialize in
  34785. * @returns the serialized object
  34786. */
  34787. serialize(parent: any): any;
  34788. }
  34789. /**
  34790. * This defines an action helpful to stop a defined sound on a triggered action.
  34791. */
  34792. export class StopSoundAction extends Action {
  34793. private _sound;
  34794. /**
  34795. * Instantiate the action
  34796. * @param triggerOptions defines the trigger options
  34797. * @param sound defines the sound to stop
  34798. * @param condition defines the trigger related conditions
  34799. */
  34800. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34801. /** @hidden */
  34802. _prepare(): void;
  34803. /**
  34804. * Execute the action and stop the sound.
  34805. */
  34806. execute(): void;
  34807. /**
  34808. * Serializes the actions and its related information.
  34809. * @param parent defines the object to serialize in
  34810. * @returns the serialized object
  34811. */
  34812. serialize(parent: any): any;
  34813. }
  34814. }
  34815. declare module "babylonjs/Actions/interpolateValueAction" {
  34816. import { Action } from "babylonjs/Actions/action";
  34817. import { Condition } from "babylonjs/Actions/condition";
  34818. import { Observable } from "babylonjs/Misc/observable";
  34819. /**
  34820. * This defines an action responsible to change the value of a property
  34821. * by interpolating between its current value and the newly set one once triggered.
  34822. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34823. */
  34824. export class InterpolateValueAction extends Action {
  34825. /**
  34826. * Defines the path of the property where the value should be interpolated
  34827. */
  34828. propertyPath: string;
  34829. /**
  34830. * Defines the target value at the end of the interpolation.
  34831. */
  34832. value: any;
  34833. /**
  34834. * Defines the time it will take for the property to interpolate to the value.
  34835. */
  34836. duration: number;
  34837. /**
  34838. * Defines if the other scene animations should be stopped when the action has been triggered
  34839. */
  34840. stopOtherAnimations?: boolean;
  34841. /**
  34842. * Defines a callback raised once the interpolation animation has been done.
  34843. */
  34844. onInterpolationDone?: () => void;
  34845. /**
  34846. * Observable triggered once the interpolation animation has been done.
  34847. */
  34848. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34849. private _target;
  34850. private _effectiveTarget;
  34851. private _property;
  34852. /**
  34853. * Instantiate the action
  34854. * @param triggerOptions defines the trigger options
  34855. * @param target defines the object containing the value to interpolate
  34856. * @param propertyPath defines the path to the property in the target object
  34857. * @param value defines the target value at the end of the interpolation
  34858. * @param duration deines the time it will take for the property to interpolate to the value.
  34859. * @param condition defines the trigger related conditions
  34860. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34861. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34862. */
  34863. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34864. /** @hidden */
  34865. _prepare(): void;
  34866. /**
  34867. * Execute the action starts the value interpolation.
  34868. */
  34869. execute(): void;
  34870. /**
  34871. * Serializes the actions and its related information.
  34872. * @param parent defines the object to serialize in
  34873. * @returns the serialized object
  34874. */
  34875. serialize(parent: any): any;
  34876. }
  34877. }
  34878. declare module "babylonjs/Actions/index" {
  34879. export * from "babylonjs/Actions/action";
  34880. export * from "babylonjs/Actions/actionEvent";
  34881. export * from "babylonjs/Actions/actionManager";
  34882. export * from "babylonjs/Actions/condition";
  34883. export * from "babylonjs/Actions/directActions";
  34884. export * from "babylonjs/Actions/directAudioActions";
  34885. export * from "babylonjs/Actions/interpolateValueAction";
  34886. }
  34887. declare module "babylonjs/Animations/index" {
  34888. export * from "babylonjs/Animations/animatable";
  34889. export * from "babylonjs/Animations/animation";
  34890. export * from "babylonjs/Animations/animationGroup";
  34891. export * from "babylonjs/Animations/animationPropertiesOverride";
  34892. export * from "babylonjs/Animations/easing";
  34893. export * from "babylonjs/Animations/runtimeAnimation";
  34894. export * from "babylonjs/Animations/animationEvent";
  34895. export * from "babylonjs/Animations/animationGroup";
  34896. export * from "babylonjs/Animations/animationKey";
  34897. export * from "babylonjs/Animations/animationRange";
  34898. }
  34899. declare module "babylonjs/Audio/soundTrack" {
  34900. import { Sound } from "babylonjs/Audio/sound";
  34901. import { Analyser } from "babylonjs/Audio/analyser";
  34902. import { Scene } from "babylonjs/scene";
  34903. /**
  34904. * Options allowed during the creation of a sound track.
  34905. */
  34906. export interface ISoundTrackOptions {
  34907. /**
  34908. * The volume the sound track should take during creation
  34909. */
  34910. volume?: number;
  34911. /**
  34912. * Define if the sound track is the main sound track of the scene
  34913. */
  34914. mainTrack?: boolean;
  34915. }
  34916. /**
  34917. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34918. * It will be also used in a future release to apply effects on a specific track.
  34919. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34920. */
  34921. export class SoundTrack {
  34922. /**
  34923. * The unique identifier of the sound track in the scene.
  34924. */
  34925. id: number;
  34926. /**
  34927. * The list of sounds included in the sound track.
  34928. */
  34929. soundCollection: Array<Sound>;
  34930. private _outputAudioNode;
  34931. private _scene;
  34932. private _isMainTrack;
  34933. private _connectedAnalyser;
  34934. private _options;
  34935. private _isInitialized;
  34936. /**
  34937. * Creates a new sound track.
  34938. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34939. * @param scene Define the scene the sound track belongs to
  34940. * @param options
  34941. */
  34942. constructor(scene: Scene, options?: ISoundTrackOptions);
  34943. private _initializeSoundTrackAudioGraph;
  34944. /**
  34945. * Release the sound track and its associated resources
  34946. */
  34947. dispose(): void;
  34948. /**
  34949. * Adds a sound to this sound track
  34950. * @param sound define the cound to add
  34951. * @ignoreNaming
  34952. */
  34953. AddSound(sound: Sound): void;
  34954. /**
  34955. * Removes a sound to this sound track
  34956. * @param sound define the cound to remove
  34957. * @ignoreNaming
  34958. */
  34959. RemoveSound(sound: Sound): void;
  34960. /**
  34961. * Set a global volume for the full sound track.
  34962. * @param newVolume Define the new volume of the sound track
  34963. */
  34964. setVolume(newVolume: number): void;
  34965. /**
  34966. * Switch the panning model to HRTF:
  34967. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34968. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34969. */
  34970. switchPanningModelToHRTF(): void;
  34971. /**
  34972. * Switch the panning model to Equal Power:
  34973. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34974. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34975. */
  34976. switchPanningModelToEqualPower(): void;
  34977. /**
  34978. * Connect the sound track to an audio analyser allowing some amazing
  34979. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34980. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34981. * @param analyser The analyser to connect to the engine
  34982. */
  34983. connectToAnalyser(analyser: Analyser): void;
  34984. }
  34985. }
  34986. declare module "babylonjs/Audio/audioSceneComponent" {
  34987. import { Sound } from "babylonjs/Audio/sound";
  34988. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  34989. import { Nullable } from "babylonjs/types";
  34990. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  34991. import { Scene } from "babylonjs/scene";
  34992. import { AbstractScene } from "babylonjs/abstractScene";
  34993. module "babylonjs/abstractScene" {
  34994. interface AbstractScene {
  34995. /**
  34996. * The list of sounds used in the scene.
  34997. */
  34998. sounds: Nullable<Array<Sound>>;
  34999. }
  35000. }
  35001. module "babylonjs/scene" {
  35002. interface Scene {
  35003. /**
  35004. * @hidden
  35005. * Backing field
  35006. */
  35007. _mainSoundTrack: SoundTrack;
  35008. /**
  35009. * The main sound track played by the scene.
  35010. * It cotains your primary collection of sounds.
  35011. */
  35012. mainSoundTrack: SoundTrack;
  35013. /**
  35014. * The list of sound tracks added to the scene
  35015. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35016. */
  35017. soundTracks: Nullable<Array<SoundTrack>>;
  35018. /**
  35019. * Gets a sound using a given name
  35020. * @param name defines the name to search for
  35021. * @return the found sound or null if not found at all.
  35022. */
  35023. getSoundByName(name: string): Nullable<Sound>;
  35024. /**
  35025. * Gets or sets if audio support is enabled
  35026. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35027. */
  35028. audioEnabled: boolean;
  35029. /**
  35030. * Gets or sets if audio will be output to headphones
  35031. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35032. */
  35033. headphone: boolean;
  35034. }
  35035. }
  35036. /**
  35037. * Defines the sound scene component responsible to manage any sounds
  35038. * in a given scene.
  35039. */
  35040. export class AudioSceneComponent implements ISceneSerializableComponent {
  35041. /**
  35042. * The component name helpfull to identify the component in the list of scene components.
  35043. */
  35044. readonly name: string;
  35045. /**
  35046. * The scene the component belongs to.
  35047. */
  35048. scene: Scene;
  35049. private _audioEnabled;
  35050. /**
  35051. * Gets whether audio is enabled or not.
  35052. * Please use related enable/disable method to switch state.
  35053. */
  35054. readonly audioEnabled: boolean;
  35055. private _headphone;
  35056. /**
  35057. * Gets whether audio is outputing to headphone or not.
  35058. * Please use the according Switch methods to change output.
  35059. */
  35060. readonly headphone: boolean;
  35061. /**
  35062. * Creates a new instance of the component for the given scene
  35063. * @param scene Defines the scene to register the component in
  35064. */
  35065. constructor(scene: Scene);
  35066. /**
  35067. * Registers the component in a given scene
  35068. */
  35069. register(): void;
  35070. /**
  35071. * Rebuilds the elements related to this component in case of
  35072. * context lost for instance.
  35073. */
  35074. rebuild(): void;
  35075. /**
  35076. * Serializes the component data to the specified json object
  35077. * @param serializationObject The object to serialize to
  35078. */
  35079. serialize(serializationObject: any): void;
  35080. /**
  35081. * Adds all the element from the container to the scene
  35082. * @param container the container holding the elements
  35083. */
  35084. addFromContainer(container: AbstractScene): void;
  35085. /**
  35086. * Removes all the elements in the container from the scene
  35087. * @param container contains the elements to remove
  35088. * @param dispose if the removed element should be disposed (default: false)
  35089. */
  35090. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35091. /**
  35092. * Disposes the component and the associated ressources.
  35093. */
  35094. dispose(): void;
  35095. /**
  35096. * Disables audio in the associated scene.
  35097. */
  35098. disableAudio(): void;
  35099. /**
  35100. * Enables audio in the associated scene.
  35101. */
  35102. enableAudio(): void;
  35103. /**
  35104. * Switch audio to headphone output.
  35105. */
  35106. switchAudioModeForHeadphones(): void;
  35107. /**
  35108. * Switch audio to normal speakers.
  35109. */
  35110. switchAudioModeForNormalSpeakers(): void;
  35111. private _afterRender;
  35112. }
  35113. }
  35114. declare module "babylonjs/Audio/weightedsound" {
  35115. import { Sound } from "babylonjs/Audio/sound";
  35116. /**
  35117. * Wraps one or more Sound objects and selects one with random weight for playback.
  35118. */
  35119. export class WeightedSound {
  35120. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35121. loop: boolean;
  35122. private _coneInnerAngle;
  35123. private _coneOuterAngle;
  35124. private _volume;
  35125. /** A Sound is currently playing. */
  35126. isPlaying: boolean;
  35127. /** A Sound is currently paused. */
  35128. isPaused: boolean;
  35129. private _sounds;
  35130. private _weights;
  35131. private _currentIndex?;
  35132. /**
  35133. * Creates a new WeightedSound from the list of sounds given.
  35134. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35135. * @param sounds Array of Sounds that will be selected from.
  35136. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35137. */
  35138. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35139. /**
  35140. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35141. */
  35142. /**
  35143. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35144. */
  35145. directionalConeInnerAngle: number;
  35146. /**
  35147. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35148. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35149. */
  35150. /**
  35151. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35152. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35153. */
  35154. directionalConeOuterAngle: number;
  35155. /**
  35156. * Playback volume.
  35157. */
  35158. /**
  35159. * Playback volume.
  35160. */
  35161. volume: number;
  35162. private _onended;
  35163. /**
  35164. * Suspend playback
  35165. */
  35166. pause(): void;
  35167. /**
  35168. * Stop playback
  35169. */
  35170. stop(): void;
  35171. /**
  35172. * Start playback.
  35173. * @param startOffset Position the clip head at a specific time in seconds.
  35174. */
  35175. play(startOffset?: number): void;
  35176. }
  35177. }
  35178. declare module "babylonjs/Audio/index" {
  35179. export * from "babylonjs/Audio/analyser";
  35180. export * from "babylonjs/Audio/audioEngine";
  35181. export * from "babylonjs/Audio/audioSceneComponent";
  35182. export * from "babylonjs/Audio/sound";
  35183. export * from "babylonjs/Audio/soundTrack";
  35184. export * from "babylonjs/Audio/weightedsound";
  35185. }
  35186. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  35187. import { Behavior } from "babylonjs/Behaviors/behavior";
  35188. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35189. import { BackEase } from "babylonjs/Animations/easing";
  35190. /**
  35191. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35192. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35193. */
  35194. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35195. /**
  35196. * Gets the name of the behavior.
  35197. */
  35198. readonly name: string;
  35199. /**
  35200. * The easing function used by animations
  35201. */
  35202. static EasingFunction: BackEase;
  35203. /**
  35204. * The easing mode used by animations
  35205. */
  35206. static EasingMode: number;
  35207. /**
  35208. * The duration of the animation, in milliseconds
  35209. */
  35210. transitionDuration: number;
  35211. /**
  35212. * Length of the distance animated by the transition when lower radius is reached
  35213. */
  35214. lowerRadiusTransitionRange: number;
  35215. /**
  35216. * Length of the distance animated by the transition when upper radius is reached
  35217. */
  35218. upperRadiusTransitionRange: number;
  35219. private _autoTransitionRange;
  35220. /**
  35221. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35222. */
  35223. /**
  35224. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35225. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35226. */
  35227. autoTransitionRange: boolean;
  35228. private _attachedCamera;
  35229. private _onAfterCheckInputsObserver;
  35230. private _onMeshTargetChangedObserver;
  35231. /**
  35232. * Initializes the behavior.
  35233. */
  35234. init(): void;
  35235. /**
  35236. * Attaches the behavior to its arc rotate camera.
  35237. * @param camera Defines the camera to attach the behavior to
  35238. */
  35239. attach(camera: ArcRotateCamera): void;
  35240. /**
  35241. * Detaches the behavior from its current arc rotate camera.
  35242. */
  35243. detach(): void;
  35244. private _radiusIsAnimating;
  35245. private _radiusBounceTransition;
  35246. private _animatables;
  35247. private _cachedWheelPrecision;
  35248. /**
  35249. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35250. * @param radiusLimit The limit to check against.
  35251. * @return Bool to indicate if at limit.
  35252. */
  35253. private _isRadiusAtLimit;
  35254. /**
  35255. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35256. * @param radiusDelta The delta by which to animate to. Can be negative.
  35257. */
  35258. private _applyBoundRadiusAnimation;
  35259. /**
  35260. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35261. */
  35262. protected _clearAnimationLocks(): void;
  35263. /**
  35264. * Stops and removes all animations that have been applied to the camera
  35265. */
  35266. stopAllAnimations(): void;
  35267. }
  35268. }
  35269. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  35270. import { Behavior } from "babylonjs/Behaviors/behavior";
  35271. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35272. import { ExponentialEase } from "babylonjs/Animations/easing";
  35273. import { Nullable } from "babylonjs/types";
  35274. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35275. import { Vector3 } from "babylonjs/Maths/math";
  35276. /**
  35277. * 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.
  35278. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35279. */
  35280. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35281. /**
  35282. * Gets the name of the behavior.
  35283. */
  35284. readonly name: string;
  35285. private _mode;
  35286. private _radiusScale;
  35287. private _positionScale;
  35288. private _defaultElevation;
  35289. private _elevationReturnTime;
  35290. private _elevationReturnWaitTime;
  35291. private _zoomStopsAnimation;
  35292. private _framingTime;
  35293. /**
  35294. * The easing function used by animations
  35295. */
  35296. static EasingFunction: ExponentialEase;
  35297. /**
  35298. * The easing mode used by animations
  35299. */
  35300. static EasingMode: number;
  35301. /**
  35302. * Sets the current mode used by the behavior
  35303. */
  35304. /**
  35305. * Gets current mode used by the behavior.
  35306. */
  35307. mode: number;
  35308. /**
  35309. * Sets the scale applied to the radius (1 by default)
  35310. */
  35311. /**
  35312. * Gets the scale applied to the radius
  35313. */
  35314. radiusScale: number;
  35315. /**
  35316. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35317. */
  35318. /**
  35319. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35320. */
  35321. positionScale: number;
  35322. /**
  35323. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35324. * behaviour is triggered, in radians.
  35325. */
  35326. /**
  35327. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35328. * behaviour is triggered, in radians.
  35329. */
  35330. defaultElevation: number;
  35331. /**
  35332. * Sets the time (in milliseconds) taken to return to the default beta position.
  35333. * Negative value indicates camera should not return to default.
  35334. */
  35335. /**
  35336. * Gets the time (in milliseconds) taken to return to the default beta position.
  35337. * Negative value indicates camera should not return to default.
  35338. */
  35339. elevationReturnTime: number;
  35340. /**
  35341. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35342. */
  35343. /**
  35344. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35345. */
  35346. elevationReturnWaitTime: number;
  35347. /**
  35348. * Sets the flag that indicates if user zooming should stop animation.
  35349. */
  35350. /**
  35351. * Gets the flag that indicates if user zooming should stop animation.
  35352. */
  35353. zoomStopsAnimation: boolean;
  35354. /**
  35355. * Sets the transition time when framing the mesh, in milliseconds
  35356. */
  35357. /**
  35358. * Gets the transition time when framing the mesh, in milliseconds
  35359. */
  35360. framingTime: number;
  35361. /**
  35362. * Define if the behavior should automatically change the configured
  35363. * camera limits and sensibilities.
  35364. */
  35365. autoCorrectCameraLimitsAndSensibility: boolean;
  35366. private _onPrePointerObservableObserver;
  35367. private _onAfterCheckInputsObserver;
  35368. private _onMeshTargetChangedObserver;
  35369. private _attachedCamera;
  35370. private _isPointerDown;
  35371. private _lastInteractionTime;
  35372. /**
  35373. * Initializes the behavior.
  35374. */
  35375. init(): void;
  35376. /**
  35377. * Attaches the behavior to its arc rotate camera.
  35378. * @param camera Defines the camera to attach the behavior to
  35379. */
  35380. attach(camera: ArcRotateCamera): void;
  35381. /**
  35382. * Detaches the behavior from its current arc rotate camera.
  35383. */
  35384. detach(): void;
  35385. private _animatables;
  35386. private _betaIsAnimating;
  35387. private _betaTransition;
  35388. private _radiusTransition;
  35389. private _vectorTransition;
  35390. /**
  35391. * Targets the given mesh and updates zoom level accordingly.
  35392. * @param mesh The mesh to target.
  35393. * @param radius Optional. If a cached radius position already exists, overrides default.
  35394. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35395. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35396. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35397. */
  35398. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35399. /**
  35400. * Targets the given mesh with its children and updates zoom level accordingly.
  35401. * @param mesh The mesh to target.
  35402. * @param radius Optional. If a cached radius position already exists, overrides default.
  35403. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35404. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35405. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35406. */
  35407. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35408. /**
  35409. * Targets the given meshes with their children and updates zoom level accordingly.
  35410. * @param meshes The mesh to target.
  35411. * @param radius Optional. If a cached radius position already exists, overrides default.
  35412. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35413. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35414. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35415. */
  35416. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35417. /**
  35418. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35419. * @param minimumWorld Determines the smaller position of the bounding box extend
  35420. * @param maximumWorld Determines the bigger position of the bounding box extend
  35421. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35422. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35423. */
  35424. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35425. /**
  35426. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35427. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35428. * frustum width.
  35429. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35430. * to fully enclose the mesh in the viewing frustum.
  35431. */
  35432. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35433. /**
  35434. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35435. * is automatically returned to its default position (expected to be above ground plane).
  35436. */
  35437. private _maintainCameraAboveGround;
  35438. /**
  35439. * Returns the frustum slope based on the canvas ratio and camera FOV
  35440. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35441. */
  35442. private _getFrustumSlope;
  35443. /**
  35444. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35445. */
  35446. private _clearAnimationLocks;
  35447. /**
  35448. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35449. */
  35450. private _applyUserInteraction;
  35451. /**
  35452. * Stops and removes all animations that have been applied to the camera
  35453. */
  35454. stopAllAnimations(): void;
  35455. /**
  35456. * Gets a value indicating if the user is moving the camera
  35457. */
  35458. readonly isUserIsMoving: boolean;
  35459. /**
  35460. * The camera can move all the way towards the mesh.
  35461. */
  35462. static IgnoreBoundsSizeMode: number;
  35463. /**
  35464. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35465. */
  35466. static FitFrustumSidesMode: number;
  35467. }
  35468. }
  35469. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  35470. import { Nullable } from "babylonjs/types";
  35471. import { Camera } from "babylonjs/Cameras/camera";
  35472. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35473. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35474. /**
  35475. * Base class for Camera Pointer Inputs.
  35476. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35477. * for example usage.
  35478. */
  35479. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35480. /**
  35481. * Defines the camera the input is attached to.
  35482. */
  35483. abstract camera: Camera;
  35484. /**
  35485. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35486. */
  35487. protected _altKey: boolean;
  35488. protected _ctrlKey: boolean;
  35489. protected _metaKey: boolean;
  35490. protected _shiftKey: boolean;
  35491. /**
  35492. * Which mouse buttons were pressed at time of last mouse event.
  35493. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35494. */
  35495. protected _buttonsPressed: number;
  35496. /**
  35497. * Defines the buttons associated with the input to handle camera move.
  35498. */
  35499. buttons: number[];
  35500. /**
  35501. * Attach the input controls to a specific dom element to get the input from.
  35502. * @param element Defines the element the controls should be listened from
  35503. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35504. */
  35505. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35506. /**
  35507. * Detach the current controls from the specified dom element.
  35508. * @param element Defines the element to stop listening the inputs from
  35509. */
  35510. detachControl(element: Nullable<HTMLElement>): void;
  35511. /**
  35512. * Gets the class name of the current input.
  35513. * @returns the class name
  35514. */
  35515. getClassName(): string;
  35516. /**
  35517. * Get the friendly name associated with the input class.
  35518. * @returns the input friendly name
  35519. */
  35520. getSimpleName(): string;
  35521. /**
  35522. * Called on pointer POINTERDOUBLETAP event.
  35523. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35524. */
  35525. protected onDoubleTap(type: string): void;
  35526. /**
  35527. * Called on pointer POINTERMOVE event if only a single touch is active.
  35528. * Override this method to provide functionality.
  35529. */
  35530. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35531. /**
  35532. * Called on pointer POINTERMOVE event if multiple touches are active.
  35533. * Override this method to provide functionality.
  35534. */
  35535. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35536. /**
  35537. * Called on JS contextmenu event.
  35538. * Override this method to provide functionality.
  35539. */
  35540. protected onContextMenu(evt: PointerEvent): void;
  35541. /**
  35542. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35543. * press.
  35544. * Override this method to provide functionality.
  35545. */
  35546. protected onButtonDown(evt: PointerEvent): void;
  35547. /**
  35548. * Called each time a new POINTERUP event occurs. Ie, for each button
  35549. * release.
  35550. * Override this method to provide functionality.
  35551. */
  35552. protected onButtonUp(evt: PointerEvent): void;
  35553. /**
  35554. * Called when window becomes inactive.
  35555. * Override this method to provide functionality.
  35556. */
  35557. protected onLostFocus(): void;
  35558. private _pointerInput;
  35559. private _observer;
  35560. private _onLostFocus;
  35561. private pointA;
  35562. private pointB;
  35563. }
  35564. }
  35565. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  35566. import { Nullable } from "babylonjs/types";
  35567. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35568. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  35569. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35570. /**
  35571. * Manage the pointers inputs to control an arc rotate camera.
  35572. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35573. */
  35574. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35575. /**
  35576. * Defines the camera the input is attached to.
  35577. */
  35578. camera: ArcRotateCamera;
  35579. /**
  35580. * Gets the class name of the current input.
  35581. * @returns the class name
  35582. */
  35583. getClassName(): string;
  35584. /**
  35585. * Defines the buttons associated with the input to handle camera move.
  35586. */
  35587. buttons: number[];
  35588. /**
  35589. * Defines the pointer angular sensibility along the X axis or how fast is
  35590. * the camera rotating.
  35591. */
  35592. angularSensibilityX: number;
  35593. /**
  35594. * Defines the pointer angular sensibility along the Y axis or how fast is
  35595. * the camera rotating.
  35596. */
  35597. angularSensibilityY: number;
  35598. /**
  35599. * Defines the pointer pinch precision or how fast is the camera zooming.
  35600. */
  35601. pinchPrecision: number;
  35602. /**
  35603. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35604. * from 0.
  35605. * It defines the percentage of current camera.radius to use as delta when
  35606. * pinch zoom is used.
  35607. */
  35608. pinchDeltaPercentage: number;
  35609. /**
  35610. * Defines the pointer panning sensibility or how fast is the camera moving.
  35611. */
  35612. panningSensibility: number;
  35613. /**
  35614. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35615. */
  35616. multiTouchPanning: boolean;
  35617. /**
  35618. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35619. * zoom (pinch) through multitouch.
  35620. */
  35621. multiTouchPanAndZoom: boolean;
  35622. /**
  35623. * Revers pinch action direction.
  35624. */
  35625. pinchInwards: boolean;
  35626. private _isPanClick;
  35627. private _twoFingerActivityCount;
  35628. private _isPinching;
  35629. /**
  35630. * Called on pointer POINTERMOVE event if only a single touch is active.
  35631. */
  35632. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35633. /**
  35634. * Called on pointer POINTERDOUBLETAP event.
  35635. */
  35636. protected onDoubleTap(type: string): void;
  35637. /**
  35638. * Called on pointer POINTERMOVE event if multiple touches are active.
  35639. */
  35640. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35641. /**
  35642. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35643. * press.
  35644. */
  35645. protected onButtonDown(evt: PointerEvent): void;
  35646. /**
  35647. * Called each time a new POINTERUP event occurs. Ie, for each button
  35648. * release.
  35649. */
  35650. protected onButtonUp(evt: PointerEvent): void;
  35651. /**
  35652. * Called when window becomes inactive.
  35653. */
  35654. protected onLostFocus(): void;
  35655. }
  35656. }
  35657. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  35658. import { Nullable } from "babylonjs/types";
  35659. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35660. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35661. /**
  35662. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35663. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35664. */
  35665. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35666. /**
  35667. * Defines the camera the input is attached to.
  35668. */
  35669. camera: ArcRotateCamera;
  35670. /**
  35671. * Defines the list of key codes associated with the up action (increase alpha)
  35672. */
  35673. keysUp: number[];
  35674. /**
  35675. * Defines the list of key codes associated with the down action (decrease alpha)
  35676. */
  35677. keysDown: number[];
  35678. /**
  35679. * Defines the list of key codes associated with the left action (increase beta)
  35680. */
  35681. keysLeft: number[];
  35682. /**
  35683. * Defines the list of key codes associated with the right action (decrease beta)
  35684. */
  35685. keysRight: number[];
  35686. /**
  35687. * Defines the list of key codes associated with the reset action.
  35688. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35689. */
  35690. keysReset: number[];
  35691. /**
  35692. * Defines the panning sensibility of the inputs.
  35693. * (How fast is the camera paning)
  35694. */
  35695. panningSensibility: number;
  35696. /**
  35697. * Defines the zooming sensibility of the inputs.
  35698. * (How fast is the camera zooming)
  35699. */
  35700. zoomingSensibility: number;
  35701. /**
  35702. * Defines wether maintaining the alt key down switch the movement mode from
  35703. * orientation to zoom.
  35704. */
  35705. useAltToZoom: boolean;
  35706. /**
  35707. * Rotation speed of the camera
  35708. */
  35709. angularSpeed: number;
  35710. private _keys;
  35711. private _ctrlPressed;
  35712. private _altPressed;
  35713. private _onCanvasBlurObserver;
  35714. private _onKeyboardObserver;
  35715. private _engine;
  35716. private _scene;
  35717. /**
  35718. * Attach the input controls to a specific dom element to get the input from.
  35719. * @param element Defines the element the controls should be listened from
  35720. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35721. */
  35722. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35723. /**
  35724. * Detach the current controls from the specified dom element.
  35725. * @param element Defines the element to stop listening the inputs from
  35726. */
  35727. detachControl(element: Nullable<HTMLElement>): void;
  35728. /**
  35729. * Update the current camera state depending on the inputs that have been used this frame.
  35730. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35731. */
  35732. checkInputs(): void;
  35733. /**
  35734. * Gets the class name of the current intput.
  35735. * @returns the class name
  35736. */
  35737. getClassName(): string;
  35738. /**
  35739. * Get the friendly name associated with the input class.
  35740. * @returns the input friendly name
  35741. */
  35742. getSimpleName(): string;
  35743. }
  35744. }
  35745. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  35746. import { Nullable } from "babylonjs/types";
  35747. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35748. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35749. /**
  35750. * Manage the mouse wheel inputs to control an arc rotate camera.
  35751. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35752. */
  35753. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35754. /**
  35755. * Defines the camera the input is attached to.
  35756. */
  35757. camera: ArcRotateCamera;
  35758. /**
  35759. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35760. */
  35761. wheelPrecision: number;
  35762. /**
  35763. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35764. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35765. */
  35766. wheelDeltaPercentage: number;
  35767. private _wheel;
  35768. private _observer;
  35769. /**
  35770. * Attach the input controls to a specific dom element to get the input from.
  35771. * @param element Defines the element the controls should be listened from
  35772. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35773. */
  35774. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35775. /**
  35776. * Detach the current controls from the specified dom element.
  35777. * @param element Defines the element to stop listening the inputs from
  35778. */
  35779. detachControl(element: Nullable<HTMLElement>): void;
  35780. /**
  35781. * Gets the class name of the current intput.
  35782. * @returns the class name
  35783. */
  35784. getClassName(): string;
  35785. /**
  35786. * Get the friendly name associated with the input class.
  35787. * @returns the input friendly name
  35788. */
  35789. getSimpleName(): string;
  35790. }
  35791. }
  35792. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  35793. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35794. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  35795. /**
  35796. * Default Inputs manager for the ArcRotateCamera.
  35797. * It groups all the default supported inputs for ease of use.
  35798. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35799. */
  35800. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35801. /**
  35802. * Instantiates a new ArcRotateCameraInputsManager.
  35803. * @param camera Defines the camera the inputs belong to
  35804. */
  35805. constructor(camera: ArcRotateCamera);
  35806. /**
  35807. * Add mouse wheel input support to the input manager.
  35808. * @returns the current input manager
  35809. */
  35810. addMouseWheel(): ArcRotateCameraInputsManager;
  35811. /**
  35812. * Add pointers input support to the input manager.
  35813. * @returns the current input manager
  35814. */
  35815. addPointers(): ArcRotateCameraInputsManager;
  35816. /**
  35817. * Add keyboard input support to the input manager.
  35818. * @returns the current input manager
  35819. */
  35820. addKeyboard(): ArcRotateCameraInputsManager;
  35821. }
  35822. }
  35823. declare module "babylonjs/Cameras/arcRotateCamera" {
  35824. import { Observable } from "babylonjs/Misc/observable";
  35825. import { Nullable } from "babylonjs/types";
  35826. import { Scene } from "babylonjs/scene";
  35827. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  35828. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35829. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35830. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35831. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  35832. import { Camera } from "babylonjs/Cameras/camera";
  35833. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  35834. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  35835. import { Collider } from "babylonjs/Collisions/collider";
  35836. /**
  35837. * This represents an orbital type of camera.
  35838. *
  35839. * 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.
  35840. * 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.
  35841. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35842. */
  35843. export class ArcRotateCamera extends TargetCamera {
  35844. /**
  35845. * Defines the rotation angle of the camera along the longitudinal axis.
  35846. */
  35847. alpha: number;
  35848. /**
  35849. * Defines the rotation angle of the camera along the latitudinal axis.
  35850. */
  35851. beta: number;
  35852. /**
  35853. * Defines the radius of the camera from it s target point.
  35854. */
  35855. radius: number;
  35856. protected _target: Vector3;
  35857. protected _targetHost: Nullable<AbstractMesh>;
  35858. /**
  35859. * Defines the target point of the camera.
  35860. * The camera looks towards it form the radius distance.
  35861. */
  35862. target: Vector3;
  35863. /**
  35864. * Define the current local position of the camera in the scene
  35865. */
  35866. position: Vector3;
  35867. protected _upVector: Vector3;
  35868. protected _upToYMatrix: Matrix;
  35869. protected _YToUpMatrix: Matrix;
  35870. /**
  35871. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  35872. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  35873. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  35874. */
  35875. upVector: Vector3;
  35876. /**
  35877. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  35878. */
  35879. setMatUp(): void;
  35880. /**
  35881. * Current inertia value on the longitudinal axis.
  35882. * The bigger this number the longer it will take for the camera to stop.
  35883. */
  35884. inertialAlphaOffset: number;
  35885. /**
  35886. * Current inertia value on the latitudinal axis.
  35887. * The bigger this number the longer it will take for the camera to stop.
  35888. */
  35889. inertialBetaOffset: number;
  35890. /**
  35891. * Current inertia value on the radius axis.
  35892. * The bigger this number the longer it will take for the camera to stop.
  35893. */
  35894. inertialRadiusOffset: number;
  35895. /**
  35896. * Minimum allowed angle on the longitudinal axis.
  35897. * This can help limiting how the Camera is able to move in the scene.
  35898. */
  35899. lowerAlphaLimit: Nullable<number>;
  35900. /**
  35901. * Maximum allowed angle on the longitudinal axis.
  35902. * This can help limiting how the Camera is able to move in the scene.
  35903. */
  35904. upperAlphaLimit: Nullable<number>;
  35905. /**
  35906. * Minimum allowed angle on the latitudinal axis.
  35907. * This can help limiting how the Camera is able to move in the scene.
  35908. */
  35909. lowerBetaLimit: number;
  35910. /**
  35911. * Maximum allowed angle on the latitudinal axis.
  35912. * This can help limiting how the Camera is able to move in the scene.
  35913. */
  35914. upperBetaLimit: number;
  35915. /**
  35916. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35917. * This can help limiting how the Camera is able to move in the scene.
  35918. */
  35919. lowerRadiusLimit: Nullable<number>;
  35920. /**
  35921. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35922. * This can help limiting how the Camera is able to move in the scene.
  35923. */
  35924. upperRadiusLimit: Nullable<number>;
  35925. /**
  35926. * Defines the current inertia value used during panning of the camera along the X axis.
  35927. */
  35928. inertialPanningX: number;
  35929. /**
  35930. * Defines the current inertia value used during panning of the camera along the Y axis.
  35931. */
  35932. inertialPanningY: number;
  35933. /**
  35934. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35935. * Basically if your fingers moves away from more than this distance you will be considered
  35936. * in pinch mode.
  35937. */
  35938. pinchToPanMaxDistance: number;
  35939. /**
  35940. * Defines the maximum distance the camera can pan.
  35941. * This could help keeping the cammera always in your scene.
  35942. */
  35943. panningDistanceLimit: Nullable<number>;
  35944. /**
  35945. * Defines the target of the camera before paning.
  35946. */
  35947. panningOriginTarget: Vector3;
  35948. /**
  35949. * Defines the value of the inertia used during panning.
  35950. * 0 would mean stop inertia and one would mean no decelleration at all.
  35951. */
  35952. panningInertia: number;
  35953. /**
  35954. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35955. */
  35956. angularSensibilityX: number;
  35957. /**
  35958. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35959. */
  35960. angularSensibilityY: number;
  35961. /**
  35962. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35963. */
  35964. pinchPrecision: number;
  35965. /**
  35966. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35967. * It will be used instead of pinchDeltaPrecision if different from 0.
  35968. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35969. */
  35970. pinchDeltaPercentage: number;
  35971. /**
  35972. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35973. */
  35974. panningSensibility: number;
  35975. /**
  35976. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35977. */
  35978. keysUp: number[];
  35979. /**
  35980. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35981. */
  35982. keysDown: number[];
  35983. /**
  35984. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35985. */
  35986. keysLeft: number[];
  35987. /**
  35988. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35989. */
  35990. keysRight: number[];
  35991. /**
  35992. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35993. */
  35994. wheelPrecision: number;
  35995. /**
  35996. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35997. * It will be used instead of pinchDeltaPrecision if different from 0.
  35998. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35999. */
  36000. wheelDeltaPercentage: number;
  36001. /**
  36002. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36003. */
  36004. zoomOnFactor: number;
  36005. /**
  36006. * Defines a screen offset for the camera position.
  36007. */
  36008. targetScreenOffset: Vector2;
  36009. /**
  36010. * Allows the camera to be completely reversed.
  36011. * If false the camera can not arrive upside down.
  36012. */
  36013. allowUpsideDown: boolean;
  36014. /**
  36015. * Define if double tap/click is used to restore the previously saved state of the camera.
  36016. */
  36017. useInputToRestoreState: boolean;
  36018. /** @hidden */
  36019. _viewMatrix: Matrix;
  36020. /** @hidden */
  36021. _useCtrlForPanning: boolean;
  36022. /** @hidden */
  36023. _panningMouseButton: number;
  36024. /**
  36025. * Defines the input associated to the camera.
  36026. */
  36027. inputs: ArcRotateCameraInputsManager;
  36028. /** @hidden */
  36029. _reset: () => void;
  36030. /**
  36031. * Defines the allowed panning axis.
  36032. */
  36033. panningAxis: Vector3;
  36034. protected _localDirection: Vector3;
  36035. protected _transformedDirection: Vector3;
  36036. private _bouncingBehavior;
  36037. /**
  36038. * Gets the bouncing behavior of the camera if it has been enabled.
  36039. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36040. */
  36041. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36042. /**
  36043. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36044. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36045. */
  36046. useBouncingBehavior: boolean;
  36047. private _framingBehavior;
  36048. /**
  36049. * Gets the framing behavior of the camera if it has been enabled.
  36050. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36051. */
  36052. readonly framingBehavior: Nullable<FramingBehavior>;
  36053. /**
  36054. * Defines if the framing behavior of the camera is enabled on the camera.
  36055. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36056. */
  36057. useFramingBehavior: boolean;
  36058. private _autoRotationBehavior;
  36059. /**
  36060. * Gets the auto rotation behavior of the camera if it has been enabled.
  36061. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36062. */
  36063. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36064. /**
  36065. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36066. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36067. */
  36068. useAutoRotationBehavior: boolean;
  36069. /**
  36070. * Observable triggered when the mesh target has been changed on the camera.
  36071. */
  36072. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36073. /**
  36074. * Event raised when the camera is colliding with a mesh.
  36075. */
  36076. onCollide: (collidedMesh: AbstractMesh) => void;
  36077. /**
  36078. * Defines whether the camera should check collision with the objects oh the scene.
  36079. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36080. */
  36081. checkCollisions: boolean;
  36082. /**
  36083. * Defines the collision radius of the camera.
  36084. * This simulates a sphere around the camera.
  36085. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36086. */
  36087. collisionRadius: Vector3;
  36088. protected _collider: Collider;
  36089. protected _previousPosition: Vector3;
  36090. protected _collisionVelocity: Vector3;
  36091. protected _newPosition: Vector3;
  36092. protected _previousAlpha: number;
  36093. protected _previousBeta: number;
  36094. protected _previousRadius: number;
  36095. protected _collisionTriggered: boolean;
  36096. protected _targetBoundingCenter: Nullable<Vector3>;
  36097. private _computationVector;
  36098. /**
  36099. * Instantiates a new ArcRotateCamera in a given scene
  36100. * @param name Defines the name of the camera
  36101. * @param alpha Defines the camera rotation along the logitudinal axis
  36102. * @param beta Defines the camera rotation along the latitudinal axis
  36103. * @param radius Defines the camera distance from its target
  36104. * @param target Defines the camera target
  36105. * @param scene Defines the scene the camera belongs to
  36106. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36107. */
  36108. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36109. /** @hidden */
  36110. _initCache(): void;
  36111. /** @hidden */
  36112. _updateCache(ignoreParentClass?: boolean): void;
  36113. protected _getTargetPosition(): Vector3;
  36114. private _storedAlpha;
  36115. private _storedBeta;
  36116. private _storedRadius;
  36117. private _storedTarget;
  36118. /**
  36119. * Stores the current state of the camera (alpha, beta, radius and target)
  36120. * @returns the camera itself
  36121. */
  36122. storeState(): Camera;
  36123. /**
  36124. * @hidden
  36125. * Restored camera state. You must call storeState() first
  36126. */
  36127. _restoreStateValues(): boolean;
  36128. /** @hidden */
  36129. _isSynchronizedViewMatrix(): boolean;
  36130. /**
  36131. * Attached controls to the current camera.
  36132. * @param element Defines the element the controls should be listened from
  36133. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36134. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36135. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36136. */
  36137. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36138. /**
  36139. * Detach the current controls from the camera.
  36140. * The camera will stop reacting to inputs.
  36141. * @param element Defines the element to stop listening the inputs from
  36142. */
  36143. detachControl(element: HTMLElement): void;
  36144. /** @hidden */
  36145. _checkInputs(): void;
  36146. protected _checkLimits(): void;
  36147. /**
  36148. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36149. */
  36150. rebuildAnglesAndRadius(): void;
  36151. /**
  36152. * Use a position to define the current camera related information like aplha, beta and radius
  36153. * @param position Defines the position to set the camera at
  36154. */
  36155. setPosition(position: Vector3): void;
  36156. /**
  36157. * Defines the target the camera should look at.
  36158. * This will automatically adapt alpha beta and radius to fit within the new target.
  36159. * @param target Defines the new target as a Vector or a mesh
  36160. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36161. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36162. */
  36163. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36164. /** @hidden */
  36165. _getViewMatrix(): Matrix;
  36166. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36167. /**
  36168. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36169. * @param meshes Defines the mesh to zoom on
  36170. * @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)
  36171. */
  36172. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36173. /**
  36174. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36175. * The target will be changed but the radius
  36176. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36177. * @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)
  36178. */
  36179. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36180. min: Vector3;
  36181. max: Vector3;
  36182. distance: number;
  36183. }, doNotUpdateMaxZ?: boolean): void;
  36184. /**
  36185. * @override
  36186. * Override Camera.createRigCamera
  36187. */
  36188. createRigCamera(name: string, cameraIndex: number): Camera;
  36189. /**
  36190. * @hidden
  36191. * @override
  36192. * Override Camera._updateRigCameras
  36193. */
  36194. _updateRigCameras(): void;
  36195. /**
  36196. * Destroy the camera and release the current resources hold by it.
  36197. */
  36198. dispose(): void;
  36199. /**
  36200. * Gets the current object class name.
  36201. * @return the class name
  36202. */
  36203. getClassName(): string;
  36204. }
  36205. }
  36206. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  36207. import { Behavior } from "babylonjs/Behaviors/behavior";
  36208. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36209. /**
  36210. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36211. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36212. */
  36213. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36214. /**
  36215. * Gets the name of the behavior.
  36216. */
  36217. readonly name: string;
  36218. private _zoomStopsAnimation;
  36219. private _idleRotationSpeed;
  36220. private _idleRotationWaitTime;
  36221. private _idleRotationSpinupTime;
  36222. /**
  36223. * Sets the flag that indicates if user zooming should stop animation.
  36224. */
  36225. /**
  36226. * Gets the flag that indicates if user zooming should stop animation.
  36227. */
  36228. zoomStopsAnimation: boolean;
  36229. /**
  36230. * Sets the default speed at which the camera rotates around the model.
  36231. */
  36232. /**
  36233. * Gets the default speed at which the camera rotates around the model.
  36234. */
  36235. idleRotationSpeed: number;
  36236. /**
  36237. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36238. */
  36239. /**
  36240. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36241. */
  36242. idleRotationWaitTime: number;
  36243. /**
  36244. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36245. */
  36246. /**
  36247. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36248. */
  36249. idleRotationSpinupTime: number;
  36250. /**
  36251. * Gets a value indicating if the camera is currently rotating because of this behavior
  36252. */
  36253. readonly rotationInProgress: boolean;
  36254. private _onPrePointerObservableObserver;
  36255. private _onAfterCheckInputsObserver;
  36256. private _attachedCamera;
  36257. private _isPointerDown;
  36258. private _lastFrameTime;
  36259. private _lastInteractionTime;
  36260. private _cameraRotationSpeed;
  36261. /**
  36262. * Initializes the behavior.
  36263. */
  36264. init(): void;
  36265. /**
  36266. * Attaches the behavior to its arc rotate camera.
  36267. * @param camera Defines the camera to attach the behavior to
  36268. */
  36269. attach(camera: ArcRotateCamera): void;
  36270. /**
  36271. * Detaches the behavior from its current arc rotate camera.
  36272. */
  36273. detach(): void;
  36274. /**
  36275. * Returns true if user is scrolling.
  36276. * @return true if user is scrolling.
  36277. */
  36278. private _userIsZooming;
  36279. private _lastFrameRadius;
  36280. private _shouldAnimationStopForInteraction;
  36281. /**
  36282. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36283. */
  36284. private _applyUserInteraction;
  36285. private _userIsMoving;
  36286. }
  36287. }
  36288. declare module "babylonjs/Behaviors/Cameras/index" {
  36289. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36290. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36291. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  36292. }
  36293. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  36294. import { Mesh } from "babylonjs/Meshes/mesh";
  36295. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36296. import { Behavior } from "babylonjs/Behaviors/behavior";
  36297. /**
  36298. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36299. */
  36300. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36301. private ui;
  36302. /**
  36303. * The name of the behavior
  36304. */
  36305. name: string;
  36306. /**
  36307. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36308. */
  36309. distanceAwayFromFace: number;
  36310. /**
  36311. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36312. */
  36313. distanceAwayFromBottomOfFace: number;
  36314. private _faceVectors;
  36315. private _target;
  36316. private _scene;
  36317. private _onRenderObserver;
  36318. private _tmpMatrix;
  36319. private _tmpVector;
  36320. /**
  36321. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36322. * @param ui The transform node that should be attched to the mesh
  36323. */
  36324. constructor(ui: TransformNode);
  36325. /**
  36326. * Initializes the behavior
  36327. */
  36328. init(): void;
  36329. private _closestFace;
  36330. private _zeroVector;
  36331. private _lookAtTmpMatrix;
  36332. private _lookAtToRef;
  36333. /**
  36334. * Attaches the AttachToBoxBehavior to the passed in mesh
  36335. * @param target The mesh that the specified node will be attached to
  36336. */
  36337. attach(target: Mesh): void;
  36338. /**
  36339. * Detaches the behavior from the mesh
  36340. */
  36341. detach(): void;
  36342. }
  36343. }
  36344. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  36345. import { Behavior } from "babylonjs/Behaviors/behavior";
  36346. import { Mesh } from "babylonjs/Meshes/mesh";
  36347. /**
  36348. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36349. */
  36350. export class FadeInOutBehavior implements Behavior<Mesh> {
  36351. /**
  36352. * Time in milliseconds to delay before fading in (Default: 0)
  36353. */
  36354. delay: number;
  36355. /**
  36356. * Time in milliseconds for the mesh to fade in (Default: 300)
  36357. */
  36358. fadeInTime: number;
  36359. private _millisecondsPerFrame;
  36360. private _hovered;
  36361. private _hoverValue;
  36362. private _ownerNode;
  36363. /**
  36364. * Instatiates the FadeInOutBehavior
  36365. */
  36366. constructor();
  36367. /**
  36368. * The name of the behavior
  36369. */
  36370. readonly name: string;
  36371. /**
  36372. * Initializes the behavior
  36373. */
  36374. init(): void;
  36375. /**
  36376. * Attaches the fade behavior on the passed in mesh
  36377. * @param ownerNode The mesh that will be faded in/out once attached
  36378. */
  36379. attach(ownerNode: Mesh): void;
  36380. /**
  36381. * Detaches the behavior from the mesh
  36382. */
  36383. detach(): void;
  36384. /**
  36385. * Triggers the mesh to begin fading in or out
  36386. * @param value if the object should fade in or out (true to fade in)
  36387. */
  36388. fadeIn(value: boolean): void;
  36389. private _update;
  36390. private _setAllVisibility;
  36391. }
  36392. }
  36393. declare module "babylonjs/Misc/pivotTools" {
  36394. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36395. /**
  36396. * Class containing a set of static utilities functions for managing Pivots
  36397. * @hidden
  36398. */
  36399. export class PivotTools {
  36400. private static _PivotCached;
  36401. private static _OldPivotPoint;
  36402. private static _PivotTranslation;
  36403. private static _PivotTmpVector;
  36404. /** @hidden */
  36405. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36406. /** @hidden */
  36407. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36408. }
  36409. }
  36410. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  36411. import { Scene } from "babylonjs/scene";
  36412. import { Vector4, Plane } from "babylonjs/Maths/math";
  36413. import { Mesh } from "babylonjs/Meshes/mesh";
  36414. import { Nullable } from "babylonjs/types";
  36415. /**
  36416. * Class containing static functions to help procedurally build meshes
  36417. */
  36418. export class PlaneBuilder {
  36419. /**
  36420. * Creates a plane mesh
  36421. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36422. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36423. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36424. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36425. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  36426. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36427. * @param name defines the name of the mesh
  36428. * @param options defines the options used to create the mesh
  36429. * @param scene defines the hosting scene
  36430. * @returns the plane mesh
  36431. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36432. */
  36433. static CreatePlane(name: string, options: {
  36434. size?: number;
  36435. width?: number;
  36436. height?: number;
  36437. sideOrientation?: number;
  36438. frontUVs?: Vector4;
  36439. backUVs?: Vector4;
  36440. updatable?: boolean;
  36441. sourcePlane?: Plane;
  36442. }, scene?: Nullable<Scene>): Mesh;
  36443. }
  36444. }
  36445. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  36446. import { Behavior } from "babylonjs/Behaviors/behavior";
  36447. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36448. import { Observable } from "babylonjs/Misc/observable";
  36449. import { Vector3 } from "babylonjs/Maths/math";
  36450. import { Ray } from "babylonjs/Culling/ray";
  36451. import "babylonjs/Meshes/Builders/planeBuilder";
  36452. /**
  36453. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36454. */
  36455. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36456. private static _AnyMouseID;
  36457. private _attachedNode;
  36458. private _dragPlane;
  36459. private _scene;
  36460. private _pointerObserver;
  36461. private _beforeRenderObserver;
  36462. private static _planeScene;
  36463. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36464. /**
  36465. * 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)
  36466. */
  36467. maxDragAngle: number;
  36468. /**
  36469. * @hidden
  36470. */
  36471. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36472. /**
  36473. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36474. */
  36475. currentDraggingPointerID: number;
  36476. /**
  36477. * The last position where the pointer hit the drag plane in world space
  36478. */
  36479. lastDragPosition: Vector3;
  36480. /**
  36481. * If the behavior is currently in a dragging state
  36482. */
  36483. dragging: boolean;
  36484. /**
  36485. * 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)
  36486. */
  36487. dragDeltaRatio: number;
  36488. /**
  36489. * If the drag plane orientation should be updated during the dragging (Default: true)
  36490. */
  36491. updateDragPlane: boolean;
  36492. private _debugMode;
  36493. private _moving;
  36494. /**
  36495. * Fires each time the attached mesh is dragged with the pointer
  36496. * * delta between last drag position and current drag position in world space
  36497. * * dragDistance along the drag axis
  36498. * * dragPlaneNormal normal of the current drag plane used during the drag
  36499. * * dragPlanePoint in world space where the drag intersects the drag plane
  36500. */
  36501. onDragObservable: Observable<{
  36502. delta: Vector3;
  36503. dragPlanePoint: Vector3;
  36504. dragPlaneNormal: Vector3;
  36505. dragDistance: number;
  36506. pointerId: number;
  36507. }>;
  36508. /**
  36509. * Fires each time a drag begins (eg. mouse down on mesh)
  36510. */
  36511. onDragStartObservable: Observable<{
  36512. dragPlanePoint: Vector3;
  36513. pointerId: number;
  36514. }>;
  36515. /**
  36516. * Fires each time a drag ends (eg. mouse release after drag)
  36517. */
  36518. onDragEndObservable: Observable<{
  36519. dragPlanePoint: Vector3;
  36520. pointerId: number;
  36521. }>;
  36522. /**
  36523. * If the attached mesh should be moved when dragged
  36524. */
  36525. moveAttached: boolean;
  36526. /**
  36527. * If the drag behavior will react to drag events (Default: true)
  36528. */
  36529. enabled: boolean;
  36530. /**
  36531. * If camera controls should be detached during the drag
  36532. */
  36533. detachCameraControls: boolean;
  36534. /**
  36535. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36536. */
  36537. useObjectOrienationForDragging: boolean;
  36538. private _options;
  36539. /**
  36540. * Creates a pointer drag behavior that can be attached to a mesh
  36541. * @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)
  36542. */
  36543. constructor(options?: {
  36544. dragAxis?: Vector3;
  36545. dragPlaneNormal?: Vector3;
  36546. });
  36547. /**
  36548. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36549. */
  36550. validateDrag: (targetPosition: Vector3) => boolean;
  36551. /**
  36552. * The name of the behavior
  36553. */
  36554. readonly name: string;
  36555. /**
  36556. * Initializes the behavior
  36557. */
  36558. init(): void;
  36559. private _tmpVector;
  36560. private _alternatePickedPoint;
  36561. private _worldDragAxis;
  36562. private _targetPosition;
  36563. private _attachedElement;
  36564. /**
  36565. * Attaches the drag behavior the passed in mesh
  36566. * @param ownerNode The mesh that will be dragged around once attached
  36567. */
  36568. attach(ownerNode: AbstractMesh): void;
  36569. /**
  36570. * Force relase the drag action by code.
  36571. */
  36572. releaseDrag(): void;
  36573. private _startDragRay;
  36574. private _lastPointerRay;
  36575. /**
  36576. * Simulates the start of a pointer drag event on the behavior
  36577. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36578. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36579. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36580. */
  36581. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36582. private _startDrag;
  36583. private _dragDelta;
  36584. private _moveDrag;
  36585. private _pickWithRayOnDragPlane;
  36586. private _pointA;
  36587. private _pointB;
  36588. private _pointC;
  36589. private _lineA;
  36590. private _lineB;
  36591. private _localAxis;
  36592. private _lookAt;
  36593. private _updateDragPlanePosition;
  36594. /**
  36595. * Detaches the behavior from the mesh
  36596. */
  36597. detach(): void;
  36598. }
  36599. }
  36600. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  36601. import { Mesh } from "babylonjs/Meshes/mesh";
  36602. import { Behavior } from "babylonjs/Behaviors/behavior";
  36603. /**
  36604. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36605. */
  36606. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36607. private _dragBehaviorA;
  36608. private _dragBehaviorB;
  36609. private _startDistance;
  36610. private _initialScale;
  36611. private _targetScale;
  36612. private _ownerNode;
  36613. private _sceneRenderObserver;
  36614. /**
  36615. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36616. */
  36617. constructor();
  36618. /**
  36619. * The name of the behavior
  36620. */
  36621. readonly name: string;
  36622. /**
  36623. * Initializes the behavior
  36624. */
  36625. init(): void;
  36626. private _getCurrentDistance;
  36627. /**
  36628. * Attaches the scale behavior the passed in mesh
  36629. * @param ownerNode The mesh that will be scaled around once attached
  36630. */
  36631. attach(ownerNode: Mesh): void;
  36632. /**
  36633. * Detaches the behavior from the mesh
  36634. */
  36635. detach(): void;
  36636. }
  36637. }
  36638. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  36639. import { Behavior } from "babylonjs/Behaviors/behavior";
  36640. import { Mesh } from "babylonjs/Meshes/mesh";
  36641. import { Observable } from "babylonjs/Misc/observable";
  36642. /**
  36643. * 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
  36644. */
  36645. export class SixDofDragBehavior implements Behavior<Mesh> {
  36646. private static _virtualScene;
  36647. private _ownerNode;
  36648. private _sceneRenderObserver;
  36649. private _scene;
  36650. private _targetPosition;
  36651. private _virtualOriginMesh;
  36652. private _virtualDragMesh;
  36653. private _pointerObserver;
  36654. private _moving;
  36655. private _startingOrientation;
  36656. /**
  36657. * 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)
  36658. */
  36659. private zDragFactor;
  36660. /**
  36661. * If the object should rotate to face the drag origin
  36662. */
  36663. rotateDraggedObject: boolean;
  36664. /**
  36665. * If the behavior is currently in a dragging state
  36666. */
  36667. dragging: boolean;
  36668. /**
  36669. * 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)
  36670. */
  36671. dragDeltaRatio: number;
  36672. /**
  36673. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36674. */
  36675. currentDraggingPointerID: number;
  36676. /**
  36677. * If camera controls should be detached during the drag
  36678. */
  36679. detachCameraControls: boolean;
  36680. /**
  36681. * Fires each time a drag starts
  36682. */
  36683. onDragStartObservable: Observable<{}>;
  36684. /**
  36685. * Fires each time a drag ends (eg. mouse release after drag)
  36686. */
  36687. onDragEndObservable: Observable<{}>;
  36688. /**
  36689. * 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
  36690. */
  36691. constructor();
  36692. /**
  36693. * The name of the behavior
  36694. */
  36695. readonly name: string;
  36696. /**
  36697. * Initializes the behavior
  36698. */
  36699. init(): void;
  36700. /**
  36701. * Attaches the scale behavior the passed in mesh
  36702. * @param ownerNode The mesh that will be scaled around once attached
  36703. */
  36704. attach(ownerNode: Mesh): void;
  36705. /**
  36706. * Detaches the behavior from the mesh
  36707. */
  36708. detach(): void;
  36709. }
  36710. }
  36711. declare module "babylonjs/Behaviors/Meshes/index" {
  36712. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  36713. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  36714. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  36715. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  36716. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  36717. }
  36718. declare module "babylonjs/Behaviors/index" {
  36719. export * from "babylonjs/Behaviors/behavior";
  36720. export * from "babylonjs/Behaviors/Cameras/index";
  36721. export * from "babylonjs/Behaviors/Meshes/index";
  36722. }
  36723. declare module "babylonjs/Bones/boneIKController" {
  36724. import { Bone } from "babylonjs/Bones/bone";
  36725. import { Vector3 } from "babylonjs/Maths/math";
  36726. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36727. import { Nullable } from "babylonjs/types";
  36728. /**
  36729. * Class used to apply inverse kinematics to bones
  36730. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36731. */
  36732. export class BoneIKController {
  36733. private static _tmpVecs;
  36734. private static _tmpQuat;
  36735. private static _tmpMats;
  36736. /**
  36737. * Gets or sets the target mesh
  36738. */
  36739. targetMesh: AbstractMesh;
  36740. /** Gets or sets the mesh used as pole */
  36741. poleTargetMesh: AbstractMesh;
  36742. /**
  36743. * Gets or sets the bone used as pole
  36744. */
  36745. poleTargetBone: Nullable<Bone>;
  36746. /**
  36747. * Gets or sets the target position
  36748. */
  36749. targetPosition: Vector3;
  36750. /**
  36751. * Gets or sets the pole target position
  36752. */
  36753. poleTargetPosition: Vector3;
  36754. /**
  36755. * Gets or sets the pole target local offset
  36756. */
  36757. poleTargetLocalOffset: Vector3;
  36758. /**
  36759. * Gets or sets the pole angle
  36760. */
  36761. poleAngle: number;
  36762. /**
  36763. * Gets or sets the mesh associated with the controller
  36764. */
  36765. mesh: AbstractMesh;
  36766. /**
  36767. * 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)
  36768. */
  36769. slerpAmount: number;
  36770. private _bone1Quat;
  36771. private _bone1Mat;
  36772. private _bone2Ang;
  36773. private _bone1;
  36774. private _bone2;
  36775. private _bone1Length;
  36776. private _bone2Length;
  36777. private _maxAngle;
  36778. private _maxReach;
  36779. private _rightHandedSystem;
  36780. private _bendAxis;
  36781. private _slerping;
  36782. private _adjustRoll;
  36783. /**
  36784. * Gets or sets maximum allowed angle
  36785. */
  36786. maxAngle: number;
  36787. /**
  36788. * Creates a new BoneIKController
  36789. * @param mesh defines the mesh to control
  36790. * @param bone defines the bone to control
  36791. * @param options defines options to set up the controller
  36792. */
  36793. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36794. targetMesh?: AbstractMesh;
  36795. poleTargetMesh?: AbstractMesh;
  36796. poleTargetBone?: Bone;
  36797. poleTargetLocalOffset?: Vector3;
  36798. poleAngle?: number;
  36799. bendAxis?: Vector3;
  36800. maxAngle?: number;
  36801. slerpAmount?: number;
  36802. });
  36803. private _setMaxAngle;
  36804. /**
  36805. * Force the controller to update the bones
  36806. */
  36807. update(): void;
  36808. }
  36809. }
  36810. declare module "babylonjs/Bones/boneLookController" {
  36811. import { Vector3, Space } from "babylonjs/Maths/math";
  36812. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36813. import { Bone } from "babylonjs/Bones/bone";
  36814. /**
  36815. * Class used to make a bone look toward a point in space
  36816. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36817. */
  36818. export class BoneLookController {
  36819. private static _tmpVecs;
  36820. private static _tmpQuat;
  36821. private static _tmpMats;
  36822. /**
  36823. * The target Vector3 that the bone will look at
  36824. */
  36825. target: Vector3;
  36826. /**
  36827. * The mesh that the bone is attached to
  36828. */
  36829. mesh: AbstractMesh;
  36830. /**
  36831. * The bone that will be looking to the target
  36832. */
  36833. bone: Bone;
  36834. /**
  36835. * The up axis of the coordinate system that is used when the bone is rotated
  36836. */
  36837. upAxis: Vector3;
  36838. /**
  36839. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36840. */
  36841. upAxisSpace: Space;
  36842. /**
  36843. * Used to make an adjustment to the yaw of the bone
  36844. */
  36845. adjustYaw: number;
  36846. /**
  36847. * Used to make an adjustment to the pitch of the bone
  36848. */
  36849. adjustPitch: number;
  36850. /**
  36851. * Used to make an adjustment to the roll of the bone
  36852. */
  36853. adjustRoll: number;
  36854. /**
  36855. * 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)
  36856. */
  36857. slerpAmount: number;
  36858. private _minYaw;
  36859. private _maxYaw;
  36860. private _minPitch;
  36861. private _maxPitch;
  36862. private _minYawSin;
  36863. private _minYawCos;
  36864. private _maxYawSin;
  36865. private _maxYawCos;
  36866. private _midYawConstraint;
  36867. private _minPitchTan;
  36868. private _maxPitchTan;
  36869. private _boneQuat;
  36870. private _slerping;
  36871. private _transformYawPitch;
  36872. private _transformYawPitchInv;
  36873. private _firstFrameSkipped;
  36874. private _yawRange;
  36875. private _fowardAxis;
  36876. /**
  36877. * Gets or sets the minimum yaw angle that the bone can look to
  36878. */
  36879. minYaw: number;
  36880. /**
  36881. * Gets or sets the maximum yaw angle that the bone can look to
  36882. */
  36883. maxYaw: number;
  36884. /**
  36885. * Gets or sets the minimum pitch angle that the bone can look to
  36886. */
  36887. minPitch: number;
  36888. /**
  36889. * Gets or sets the maximum pitch angle that the bone can look to
  36890. */
  36891. maxPitch: number;
  36892. /**
  36893. * Create a BoneLookController
  36894. * @param mesh the mesh that the bone belongs to
  36895. * @param bone the bone that will be looking to the target
  36896. * @param target the target Vector3 to look at
  36897. * @param options optional settings:
  36898. * * maxYaw: the maximum angle the bone will yaw to
  36899. * * minYaw: the minimum angle the bone will yaw to
  36900. * * maxPitch: the maximum angle the bone will pitch to
  36901. * * minPitch: the minimum angle the bone will yaw to
  36902. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36903. * * upAxis: the up axis of the coordinate system
  36904. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36905. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36906. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36907. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36908. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36909. * * adjustRoll: used to make an adjustment to the roll of the bone
  36910. **/
  36911. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36912. maxYaw?: number;
  36913. minYaw?: number;
  36914. maxPitch?: number;
  36915. minPitch?: number;
  36916. slerpAmount?: number;
  36917. upAxis?: Vector3;
  36918. upAxisSpace?: Space;
  36919. yawAxis?: Vector3;
  36920. pitchAxis?: Vector3;
  36921. adjustYaw?: number;
  36922. adjustPitch?: number;
  36923. adjustRoll?: number;
  36924. });
  36925. /**
  36926. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36927. */
  36928. update(): void;
  36929. private _getAngleDiff;
  36930. private _getAngleBetween;
  36931. private _isAngleBetween;
  36932. }
  36933. }
  36934. declare module "babylonjs/Bones/index" {
  36935. export * from "babylonjs/Bones/bone";
  36936. export * from "babylonjs/Bones/boneIKController";
  36937. export * from "babylonjs/Bones/boneLookController";
  36938. export * from "babylonjs/Bones/skeleton";
  36939. }
  36940. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  36941. import { Nullable } from "babylonjs/types";
  36942. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36943. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36944. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  36945. /**
  36946. * Manage the gamepad inputs to control an arc rotate camera.
  36947. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36948. */
  36949. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36950. /**
  36951. * Defines the camera the input is attached to.
  36952. */
  36953. camera: ArcRotateCamera;
  36954. /**
  36955. * Defines the gamepad the input is gathering event from.
  36956. */
  36957. gamepad: Nullable<Gamepad>;
  36958. /**
  36959. * Defines the gamepad rotation sensiblity.
  36960. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36961. */
  36962. gamepadRotationSensibility: number;
  36963. /**
  36964. * Defines the gamepad move sensiblity.
  36965. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36966. */
  36967. gamepadMoveSensibility: number;
  36968. private _onGamepadConnectedObserver;
  36969. private _onGamepadDisconnectedObserver;
  36970. /**
  36971. * Attach the input controls to a specific dom element to get the input from.
  36972. * @param element Defines the element the controls should be listened from
  36973. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36974. */
  36975. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36976. /**
  36977. * Detach the current controls from the specified dom element.
  36978. * @param element Defines the element to stop listening the inputs from
  36979. */
  36980. detachControl(element: Nullable<HTMLElement>): void;
  36981. /**
  36982. * Update the current camera state depending on the inputs that have been used this frame.
  36983. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36984. */
  36985. checkInputs(): void;
  36986. /**
  36987. * Gets the class name of the current intput.
  36988. * @returns the class name
  36989. */
  36990. getClassName(): string;
  36991. /**
  36992. * Get the friendly name associated with the input class.
  36993. * @returns the input friendly name
  36994. */
  36995. getSimpleName(): string;
  36996. }
  36997. }
  36998. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  36999. import { Nullable } from "babylonjs/types";
  37000. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37001. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37002. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37003. interface ArcRotateCameraInputsManager {
  37004. /**
  37005. * Add orientation input support to the input manager.
  37006. * @returns the current input manager
  37007. */
  37008. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37009. }
  37010. }
  37011. /**
  37012. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37013. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37014. */
  37015. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37016. /**
  37017. * Defines the camera the input is attached to.
  37018. */
  37019. camera: ArcRotateCamera;
  37020. /**
  37021. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37022. */
  37023. alphaCorrection: number;
  37024. /**
  37025. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37026. */
  37027. gammaCorrection: number;
  37028. private _alpha;
  37029. private _gamma;
  37030. private _dirty;
  37031. private _deviceOrientationHandler;
  37032. /**
  37033. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37034. */
  37035. constructor();
  37036. /**
  37037. * Attach the input controls to a specific dom element to get the input from.
  37038. * @param element Defines the element the controls should be listened from
  37039. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37040. */
  37041. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37042. /** @hidden */
  37043. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37044. /**
  37045. * Update the current camera state depending on the inputs that have been used this frame.
  37046. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37047. */
  37048. checkInputs(): void;
  37049. /**
  37050. * Detach the current controls from the specified dom element.
  37051. * @param element Defines the element to stop listening the inputs from
  37052. */
  37053. detachControl(element: Nullable<HTMLElement>): void;
  37054. /**
  37055. * Gets the class name of the current intput.
  37056. * @returns the class name
  37057. */
  37058. getClassName(): string;
  37059. /**
  37060. * Get the friendly name associated with the input class.
  37061. * @returns the input friendly name
  37062. */
  37063. getSimpleName(): string;
  37064. }
  37065. }
  37066. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  37067. import { Nullable } from "babylonjs/types";
  37068. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37069. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37070. /**
  37071. * Listen to mouse events to control the camera.
  37072. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37073. */
  37074. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37075. /**
  37076. * Defines the camera the input is attached to.
  37077. */
  37078. camera: FlyCamera;
  37079. /**
  37080. * Defines if touch is enabled. (Default is true.)
  37081. */
  37082. touchEnabled: boolean;
  37083. /**
  37084. * Defines the buttons associated with the input to handle camera rotation.
  37085. */
  37086. buttons: number[];
  37087. /**
  37088. * Assign buttons for Yaw control.
  37089. */
  37090. buttonsYaw: number[];
  37091. /**
  37092. * Assign buttons for Pitch control.
  37093. */
  37094. buttonsPitch: number[];
  37095. /**
  37096. * Assign buttons for Roll control.
  37097. */
  37098. buttonsRoll: number[];
  37099. /**
  37100. * Detect if any button is being pressed while mouse is moved.
  37101. * -1 = Mouse locked.
  37102. * 0 = Left button.
  37103. * 1 = Middle Button.
  37104. * 2 = Right Button.
  37105. */
  37106. activeButton: number;
  37107. /**
  37108. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37109. * Higher values reduce its sensitivity.
  37110. */
  37111. angularSensibility: number;
  37112. private _mousemoveCallback;
  37113. private _observer;
  37114. private _rollObserver;
  37115. private previousPosition;
  37116. private noPreventDefault;
  37117. private element;
  37118. /**
  37119. * Listen to mouse events to control the camera.
  37120. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37121. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37122. */
  37123. constructor(touchEnabled?: boolean);
  37124. /**
  37125. * Attach the mouse control to the HTML DOM element.
  37126. * @param element Defines the element that listens to the input events.
  37127. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37128. */
  37129. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37130. /**
  37131. * Detach the current controls from the specified dom element.
  37132. * @param element Defines the element to stop listening the inputs from
  37133. */
  37134. detachControl(element: Nullable<HTMLElement>): void;
  37135. /**
  37136. * Gets the class name of the current input.
  37137. * @returns the class name.
  37138. */
  37139. getClassName(): string;
  37140. /**
  37141. * Get the friendly name associated with the input class.
  37142. * @returns the input's friendly name.
  37143. */
  37144. getSimpleName(): string;
  37145. private _pointerInput;
  37146. private _onMouseMove;
  37147. /**
  37148. * Rotate camera by mouse offset.
  37149. */
  37150. private rotateCamera;
  37151. }
  37152. }
  37153. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  37154. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37155. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37156. /**
  37157. * Default Inputs manager for the FlyCamera.
  37158. * It groups all the default supported inputs for ease of use.
  37159. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37160. */
  37161. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37162. /**
  37163. * Instantiates a new FlyCameraInputsManager.
  37164. * @param camera Defines the camera the inputs belong to.
  37165. */
  37166. constructor(camera: FlyCamera);
  37167. /**
  37168. * Add keyboard input support to the input manager.
  37169. * @returns the new FlyCameraKeyboardMoveInput().
  37170. */
  37171. addKeyboard(): FlyCameraInputsManager;
  37172. /**
  37173. * Add mouse input support to the input manager.
  37174. * @param touchEnabled Enable touch screen support.
  37175. * @returns the new FlyCameraMouseInput().
  37176. */
  37177. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37178. }
  37179. }
  37180. declare module "babylonjs/Cameras/flyCamera" {
  37181. import { Scene } from "babylonjs/scene";
  37182. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  37183. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37184. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37185. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  37186. /**
  37187. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37188. * such as in a 3D Space Shooter or a Flight Simulator.
  37189. */
  37190. export class FlyCamera extends TargetCamera {
  37191. /**
  37192. * Define the collision ellipsoid of the camera.
  37193. * This is helpful for simulating a camera body, like a player's body.
  37194. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37195. */
  37196. ellipsoid: Vector3;
  37197. /**
  37198. * Define an offset for the position of the ellipsoid around the camera.
  37199. * This can be helpful if the camera is attached away from the player's body center,
  37200. * such as at its head.
  37201. */
  37202. ellipsoidOffset: Vector3;
  37203. /**
  37204. * Enable or disable collisions of the camera with the rest of the scene objects.
  37205. */
  37206. checkCollisions: boolean;
  37207. /**
  37208. * Enable or disable gravity on the camera.
  37209. */
  37210. applyGravity: boolean;
  37211. /**
  37212. * Define the current direction the camera is moving to.
  37213. */
  37214. cameraDirection: Vector3;
  37215. /**
  37216. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37217. * This overrides and empties cameraRotation.
  37218. */
  37219. rotationQuaternion: Quaternion;
  37220. /**
  37221. * Track Roll to maintain the wanted Rolling when looking around.
  37222. */
  37223. _trackRoll: number;
  37224. /**
  37225. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37226. */
  37227. rollCorrect: number;
  37228. /**
  37229. * Mimic a banked turn, Rolling the camera when Yawing.
  37230. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37231. */
  37232. bankedTurn: boolean;
  37233. /**
  37234. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37235. */
  37236. bankedTurnLimit: number;
  37237. /**
  37238. * Value of 0 disables the banked Roll.
  37239. * Value of 1 is equal to the Yaw angle in radians.
  37240. */
  37241. bankedTurnMultiplier: number;
  37242. /**
  37243. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37244. */
  37245. inputs: FlyCameraInputsManager;
  37246. /**
  37247. * Gets the input sensibility for mouse input.
  37248. * Higher values reduce sensitivity.
  37249. */
  37250. /**
  37251. * Sets the input sensibility for a mouse input.
  37252. * Higher values reduce sensitivity.
  37253. */
  37254. angularSensibility: number;
  37255. /**
  37256. * Get the keys for camera movement forward.
  37257. */
  37258. /**
  37259. * Set the keys for camera movement forward.
  37260. */
  37261. keysForward: number[];
  37262. /**
  37263. * Get the keys for camera movement backward.
  37264. */
  37265. keysBackward: number[];
  37266. /**
  37267. * Get the keys for camera movement up.
  37268. */
  37269. /**
  37270. * Set the keys for camera movement up.
  37271. */
  37272. keysUp: number[];
  37273. /**
  37274. * Get the keys for camera movement down.
  37275. */
  37276. /**
  37277. * Set the keys for camera movement down.
  37278. */
  37279. keysDown: number[];
  37280. /**
  37281. * Get the keys for camera movement left.
  37282. */
  37283. /**
  37284. * Set the keys for camera movement left.
  37285. */
  37286. keysLeft: number[];
  37287. /**
  37288. * Set the keys for camera movement right.
  37289. */
  37290. /**
  37291. * Set the keys for camera movement right.
  37292. */
  37293. keysRight: number[];
  37294. /**
  37295. * Event raised when the camera collides with a mesh in the scene.
  37296. */
  37297. onCollide: (collidedMesh: AbstractMesh) => void;
  37298. private _collider;
  37299. private _needMoveForGravity;
  37300. private _oldPosition;
  37301. private _diffPosition;
  37302. private _newPosition;
  37303. /** @hidden */
  37304. _localDirection: Vector3;
  37305. /** @hidden */
  37306. _transformedDirection: Vector3;
  37307. /**
  37308. * Instantiates a FlyCamera.
  37309. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37310. * such as in a 3D Space Shooter or a Flight Simulator.
  37311. * @param name Define the name of the camera in the scene.
  37312. * @param position Define the starting position of the camera in the scene.
  37313. * @param scene Define the scene the camera belongs to.
  37314. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37315. */
  37316. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37317. /**
  37318. * Attach a control to the HTML DOM element.
  37319. * @param element Defines the element that listens to the input events.
  37320. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37321. */
  37322. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37323. /**
  37324. * Detach a control from the HTML DOM element.
  37325. * The camera will stop reacting to that input.
  37326. * @param element Defines the element that listens to the input events.
  37327. */
  37328. detachControl(element: HTMLElement): void;
  37329. private _collisionMask;
  37330. /**
  37331. * Get the mask that the camera ignores in collision events.
  37332. */
  37333. /**
  37334. * Set the mask that the camera ignores in collision events.
  37335. */
  37336. collisionMask: number;
  37337. /** @hidden */
  37338. _collideWithWorld(displacement: Vector3): void;
  37339. /** @hidden */
  37340. private _onCollisionPositionChange;
  37341. /** @hidden */
  37342. _checkInputs(): void;
  37343. /** @hidden */
  37344. _decideIfNeedsToMove(): boolean;
  37345. /** @hidden */
  37346. _updatePosition(): void;
  37347. /**
  37348. * Restore the Roll to its target value at the rate specified.
  37349. * @param rate - Higher means slower restoring.
  37350. * @hidden
  37351. */
  37352. restoreRoll(rate: number): void;
  37353. /**
  37354. * Destroy the camera and release the current resources held by it.
  37355. */
  37356. dispose(): void;
  37357. /**
  37358. * Get the current object class name.
  37359. * @returns the class name.
  37360. */
  37361. getClassName(): string;
  37362. }
  37363. }
  37364. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  37365. import { Nullable } from "babylonjs/types";
  37366. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37367. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37368. /**
  37369. * Listen to keyboard events to control the camera.
  37370. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37371. */
  37372. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37373. /**
  37374. * Defines the camera the input is attached to.
  37375. */
  37376. camera: FlyCamera;
  37377. /**
  37378. * The list of keyboard keys used to control the forward move of the camera.
  37379. */
  37380. keysForward: number[];
  37381. /**
  37382. * The list of keyboard keys used to control the backward move of the camera.
  37383. */
  37384. keysBackward: number[];
  37385. /**
  37386. * The list of keyboard keys used to control the forward move of the camera.
  37387. */
  37388. keysUp: number[];
  37389. /**
  37390. * The list of keyboard keys used to control the backward move of the camera.
  37391. */
  37392. keysDown: number[];
  37393. /**
  37394. * The list of keyboard keys used to control the right strafe move of the camera.
  37395. */
  37396. keysRight: number[];
  37397. /**
  37398. * The list of keyboard keys used to control the left strafe move of the camera.
  37399. */
  37400. keysLeft: number[];
  37401. private _keys;
  37402. private _onCanvasBlurObserver;
  37403. private _onKeyboardObserver;
  37404. private _engine;
  37405. private _scene;
  37406. /**
  37407. * Attach the input controls to a specific dom element to get the input from.
  37408. * @param element Defines the element the controls should be listened from
  37409. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37410. */
  37411. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37412. /**
  37413. * Detach the current controls from the specified dom element.
  37414. * @param element Defines the element to stop listening the inputs from
  37415. */
  37416. detachControl(element: Nullable<HTMLElement>): void;
  37417. /**
  37418. * Gets the class name of the current intput.
  37419. * @returns the class name
  37420. */
  37421. getClassName(): string;
  37422. /** @hidden */
  37423. _onLostFocus(e: FocusEvent): void;
  37424. /**
  37425. * Get the friendly name associated with the input class.
  37426. * @returns the input friendly name
  37427. */
  37428. getSimpleName(): string;
  37429. /**
  37430. * Update the current camera state depending on the inputs that have been used this frame.
  37431. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37432. */
  37433. checkInputs(): void;
  37434. }
  37435. }
  37436. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  37437. import { Nullable } from "babylonjs/types";
  37438. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37439. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37440. /**
  37441. * Manage the mouse wheel inputs to control a follow camera.
  37442. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37443. */
  37444. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37445. /**
  37446. * Defines the camera the input is attached to.
  37447. */
  37448. camera: FollowCamera;
  37449. /**
  37450. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37451. */
  37452. axisControlRadius: boolean;
  37453. /**
  37454. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37455. */
  37456. axisControlHeight: boolean;
  37457. /**
  37458. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37459. */
  37460. axisControlRotation: boolean;
  37461. /**
  37462. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37463. * relation to mouseWheel events.
  37464. */
  37465. wheelPrecision: number;
  37466. /**
  37467. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37468. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37469. */
  37470. wheelDeltaPercentage: number;
  37471. private _wheel;
  37472. private _observer;
  37473. /**
  37474. * Attach the input controls to a specific dom element to get the input from.
  37475. * @param element Defines the element the controls should be listened from
  37476. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37477. */
  37478. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37479. /**
  37480. * Detach the current controls from the specified dom element.
  37481. * @param element Defines the element to stop listening the inputs from
  37482. */
  37483. detachControl(element: Nullable<HTMLElement>): void;
  37484. /**
  37485. * Gets the class name of the current intput.
  37486. * @returns the class name
  37487. */
  37488. getClassName(): string;
  37489. /**
  37490. * Get the friendly name associated with the input class.
  37491. * @returns the input friendly name
  37492. */
  37493. getSimpleName(): string;
  37494. }
  37495. }
  37496. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  37497. import { Nullable } from "babylonjs/types";
  37498. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37499. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37500. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37501. /**
  37502. * Manage the pointers inputs to control an follow camera.
  37503. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37504. */
  37505. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37506. /**
  37507. * Defines the camera the input is attached to.
  37508. */
  37509. camera: FollowCamera;
  37510. /**
  37511. * Gets the class name of the current input.
  37512. * @returns the class name
  37513. */
  37514. getClassName(): string;
  37515. /**
  37516. * Defines the pointer angular sensibility along the X axis or how fast is
  37517. * the camera rotating.
  37518. * A negative number will reverse the axis direction.
  37519. */
  37520. angularSensibilityX: number;
  37521. /**
  37522. * Defines the pointer angular sensibility along the Y axis or how fast is
  37523. * the camera rotating.
  37524. * A negative number will reverse the axis direction.
  37525. */
  37526. angularSensibilityY: number;
  37527. /**
  37528. * Defines the pointer pinch precision or how fast is the camera zooming.
  37529. * A negative number will reverse the axis direction.
  37530. */
  37531. pinchPrecision: number;
  37532. /**
  37533. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37534. * from 0.
  37535. * It defines the percentage of current camera.radius to use as delta when
  37536. * pinch zoom is used.
  37537. */
  37538. pinchDeltaPercentage: number;
  37539. /**
  37540. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37541. */
  37542. axisXControlRadius: boolean;
  37543. /**
  37544. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37545. */
  37546. axisXControlHeight: boolean;
  37547. /**
  37548. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37549. */
  37550. axisXControlRotation: boolean;
  37551. /**
  37552. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37553. */
  37554. axisYControlRadius: boolean;
  37555. /**
  37556. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37557. */
  37558. axisYControlHeight: boolean;
  37559. /**
  37560. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37561. */
  37562. axisYControlRotation: boolean;
  37563. /**
  37564. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37565. */
  37566. axisPinchControlRadius: boolean;
  37567. /**
  37568. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37569. */
  37570. axisPinchControlHeight: boolean;
  37571. /**
  37572. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37573. */
  37574. axisPinchControlRotation: boolean;
  37575. /**
  37576. * Log error messages if basic misconfiguration has occurred.
  37577. */
  37578. warningEnable: boolean;
  37579. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37580. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37581. private _warningCounter;
  37582. private _warning;
  37583. }
  37584. }
  37585. declare module "babylonjs/Cameras/followCameraInputsManager" {
  37586. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37587. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37588. /**
  37589. * Default Inputs manager for the FollowCamera.
  37590. * It groups all the default supported inputs for ease of use.
  37591. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37592. */
  37593. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37594. /**
  37595. * Instantiates a new FollowCameraInputsManager.
  37596. * @param camera Defines the camera the inputs belong to
  37597. */
  37598. constructor(camera: FollowCamera);
  37599. /**
  37600. * Add keyboard input support to the input manager.
  37601. * @returns the current input manager
  37602. */
  37603. addKeyboard(): FollowCameraInputsManager;
  37604. /**
  37605. * Add mouse wheel input support to the input manager.
  37606. * @returns the current input manager
  37607. */
  37608. addMouseWheel(): FollowCameraInputsManager;
  37609. /**
  37610. * Add pointers input support to the input manager.
  37611. * @returns the current input manager
  37612. */
  37613. addPointers(): FollowCameraInputsManager;
  37614. /**
  37615. * Add orientation input support to the input manager.
  37616. * @returns the current input manager
  37617. */
  37618. addVRDeviceOrientation(): FollowCameraInputsManager;
  37619. }
  37620. }
  37621. declare module "babylonjs/Cameras/followCamera" {
  37622. import { Nullable } from "babylonjs/types";
  37623. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37624. import { Scene } from "babylonjs/scene";
  37625. import { Vector3 } from "babylonjs/Maths/math";
  37626. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37627. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  37628. /**
  37629. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37630. * an arc rotate version arcFollowCamera are available.
  37631. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37632. */
  37633. export class FollowCamera extends TargetCamera {
  37634. /**
  37635. * Distance the follow camera should follow an object at
  37636. */
  37637. radius: number;
  37638. /**
  37639. * Minimum allowed distance of the camera to the axis of rotation
  37640. * (The camera can not get closer).
  37641. * This can help limiting how the Camera is able to move in the scene.
  37642. */
  37643. lowerRadiusLimit: Nullable<number>;
  37644. /**
  37645. * Maximum allowed distance of the camera to the axis of rotation
  37646. * (The camera can not get further).
  37647. * This can help limiting how the Camera is able to move in the scene.
  37648. */
  37649. upperRadiusLimit: Nullable<number>;
  37650. /**
  37651. * Define a rotation offset between the camera and the object it follows
  37652. */
  37653. rotationOffset: number;
  37654. /**
  37655. * Minimum allowed angle to camera position relative to target object.
  37656. * This can help limiting how the Camera is able to move in the scene.
  37657. */
  37658. lowerRotationOffsetLimit: Nullable<number>;
  37659. /**
  37660. * Maximum allowed angle to camera position relative to target object.
  37661. * This can help limiting how the Camera is able to move in the scene.
  37662. */
  37663. upperRotationOffsetLimit: Nullable<number>;
  37664. /**
  37665. * Define a height offset between the camera and the object it follows.
  37666. * It can help following an object from the top (like a car chaing a plane)
  37667. */
  37668. heightOffset: number;
  37669. /**
  37670. * Minimum allowed height of camera position relative to target object.
  37671. * This can help limiting how the Camera is able to move in the scene.
  37672. */
  37673. lowerHeightOffsetLimit: Nullable<number>;
  37674. /**
  37675. * Maximum allowed height of camera position relative to target object.
  37676. * This can help limiting how the Camera is able to move in the scene.
  37677. */
  37678. upperHeightOffsetLimit: Nullable<number>;
  37679. /**
  37680. * Define how fast the camera can accelerate to follow it s target.
  37681. */
  37682. cameraAcceleration: number;
  37683. /**
  37684. * Define the speed limit of the camera following an object.
  37685. */
  37686. maxCameraSpeed: number;
  37687. /**
  37688. * Define the target of the camera.
  37689. */
  37690. lockedTarget: Nullable<AbstractMesh>;
  37691. /**
  37692. * Defines the input associated with the camera.
  37693. */
  37694. inputs: FollowCameraInputsManager;
  37695. /**
  37696. * Instantiates the follow camera.
  37697. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37698. * @param name Define the name of the camera in the scene
  37699. * @param position Define the position of the camera
  37700. * @param scene Define the scene the camera belong to
  37701. * @param lockedTarget Define the target of the camera
  37702. */
  37703. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37704. private _follow;
  37705. /**
  37706. * Attached controls to the current camera.
  37707. * @param element Defines the element the controls should be listened from
  37708. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37709. */
  37710. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37711. /**
  37712. * Detach the current controls from the camera.
  37713. * The camera will stop reacting to inputs.
  37714. * @param element Defines the element to stop listening the inputs from
  37715. */
  37716. detachControl(element: HTMLElement): void;
  37717. /** @hidden */
  37718. _checkInputs(): void;
  37719. private _checkLimits;
  37720. /**
  37721. * Gets the camera class name.
  37722. * @returns the class name
  37723. */
  37724. getClassName(): string;
  37725. }
  37726. /**
  37727. * Arc Rotate version of the follow camera.
  37728. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37729. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37730. */
  37731. export class ArcFollowCamera extends TargetCamera {
  37732. /** The longitudinal angle of the camera */
  37733. alpha: number;
  37734. /** The latitudinal angle of the camera */
  37735. beta: number;
  37736. /** The radius of the camera from its target */
  37737. radius: number;
  37738. /** Define the camera target (the messh it should follow) */
  37739. target: Nullable<AbstractMesh>;
  37740. private _cartesianCoordinates;
  37741. /**
  37742. * Instantiates a new ArcFollowCamera
  37743. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37744. * @param name Define the name of the camera
  37745. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37746. * @param beta Define the rotation angle of the camera around the elevation axis
  37747. * @param radius Define the radius of the camera from its target point
  37748. * @param target Define the target of the camera
  37749. * @param scene Define the scene the camera belongs to
  37750. */
  37751. constructor(name: string,
  37752. /** The longitudinal angle of the camera */
  37753. alpha: number,
  37754. /** The latitudinal angle of the camera */
  37755. beta: number,
  37756. /** The radius of the camera from its target */
  37757. radius: number,
  37758. /** Define the camera target (the messh it should follow) */
  37759. target: Nullable<AbstractMesh>, scene: Scene);
  37760. private _follow;
  37761. /** @hidden */
  37762. _checkInputs(): void;
  37763. /**
  37764. * Returns the class name of the object.
  37765. * It is mostly used internally for serialization purposes.
  37766. */
  37767. getClassName(): string;
  37768. }
  37769. }
  37770. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  37771. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37772. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37773. import { Nullable } from "babylonjs/types";
  37774. /**
  37775. * Manage the keyboard inputs to control the movement of a follow camera.
  37776. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37777. */
  37778. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37779. /**
  37780. * Defines the camera the input is attached to.
  37781. */
  37782. camera: FollowCamera;
  37783. /**
  37784. * Defines the list of key codes associated with the up action (increase heightOffset)
  37785. */
  37786. keysHeightOffsetIncr: number[];
  37787. /**
  37788. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37789. */
  37790. keysHeightOffsetDecr: number[];
  37791. /**
  37792. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37793. */
  37794. keysHeightOffsetModifierAlt: boolean;
  37795. /**
  37796. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37797. */
  37798. keysHeightOffsetModifierCtrl: boolean;
  37799. /**
  37800. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37801. */
  37802. keysHeightOffsetModifierShift: boolean;
  37803. /**
  37804. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37805. */
  37806. keysRotationOffsetIncr: number[];
  37807. /**
  37808. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37809. */
  37810. keysRotationOffsetDecr: number[];
  37811. /**
  37812. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37813. */
  37814. keysRotationOffsetModifierAlt: boolean;
  37815. /**
  37816. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37817. */
  37818. keysRotationOffsetModifierCtrl: boolean;
  37819. /**
  37820. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37821. */
  37822. keysRotationOffsetModifierShift: boolean;
  37823. /**
  37824. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37825. */
  37826. keysRadiusIncr: number[];
  37827. /**
  37828. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37829. */
  37830. keysRadiusDecr: number[];
  37831. /**
  37832. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37833. */
  37834. keysRadiusModifierAlt: boolean;
  37835. /**
  37836. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37837. */
  37838. keysRadiusModifierCtrl: boolean;
  37839. /**
  37840. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37841. */
  37842. keysRadiusModifierShift: boolean;
  37843. /**
  37844. * Defines the rate of change of heightOffset.
  37845. */
  37846. heightSensibility: number;
  37847. /**
  37848. * Defines the rate of change of rotationOffset.
  37849. */
  37850. rotationSensibility: number;
  37851. /**
  37852. * Defines the rate of change of radius.
  37853. */
  37854. radiusSensibility: number;
  37855. private _keys;
  37856. private _ctrlPressed;
  37857. private _altPressed;
  37858. private _shiftPressed;
  37859. private _onCanvasBlurObserver;
  37860. private _onKeyboardObserver;
  37861. private _engine;
  37862. private _scene;
  37863. /**
  37864. * Attach the input controls to a specific dom element to get the input from.
  37865. * @param element Defines the element the controls should be listened from
  37866. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37867. */
  37868. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37869. /**
  37870. * Detach the current controls from the specified dom element.
  37871. * @param element Defines the element to stop listening the inputs from
  37872. */
  37873. detachControl(element: Nullable<HTMLElement>): void;
  37874. /**
  37875. * Update the current camera state depending on the inputs that have been used this frame.
  37876. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37877. */
  37878. checkInputs(): void;
  37879. /**
  37880. * Gets the class name of the current input.
  37881. * @returns the class name
  37882. */
  37883. getClassName(): string;
  37884. /**
  37885. * Get the friendly name associated with the input class.
  37886. * @returns the input friendly name
  37887. */
  37888. getSimpleName(): string;
  37889. /**
  37890. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37891. * allow modification of the heightOffset value.
  37892. */
  37893. private _modifierHeightOffset;
  37894. /**
  37895. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37896. * allow modification of the rotationOffset value.
  37897. */
  37898. private _modifierRotationOffset;
  37899. /**
  37900. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37901. * allow modification of the radius value.
  37902. */
  37903. private _modifierRadius;
  37904. }
  37905. }
  37906. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  37907. import { Nullable } from "babylonjs/types";
  37908. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37909. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37910. import { Observable } from "babylonjs/Misc/observable";
  37911. module "babylonjs/Cameras/freeCameraInputsManager" {
  37912. interface FreeCameraInputsManager {
  37913. /**
  37914. * @hidden
  37915. */
  37916. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  37917. /**
  37918. * Add orientation input support to the input manager.
  37919. * @returns the current input manager
  37920. */
  37921. addDeviceOrientation(): FreeCameraInputsManager;
  37922. }
  37923. }
  37924. /**
  37925. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37926. * Screen rotation is taken into account.
  37927. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37928. */
  37929. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37930. private _camera;
  37931. private _screenOrientationAngle;
  37932. private _constantTranform;
  37933. private _screenQuaternion;
  37934. private _alpha;
  37935. private _beta;
  37936. private _gamma;
  37937. /**
  37938. * @hidden
  37939. */
  37940. _onDeviceOrientationChangedObservable: Observable<void>;
  37941. /**
  37942. * Instantiates a new input
  37943. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37944. */
  37945. constructor();
  37946. /**
  37947. * Define the camera controlled by the input.
  37948. */
  37949. camera: FreeCamera;
  37950. /**
  37951. * Attach the input controls to a specific dom element to get the input from.
  37952. * @param element Defines the element the controls should be listened from
  37953. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37954. */
  37955. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37956. private _orientationChanged;
  37957. private _deviceOrientation;
  37958. /**
  37959. * Detach the current controls from the specified dom element.
  37960. * @param element Defines the element to stop listening the inputs from
  37961. */
  37962. detachControl(element: Nullable<HTMLElement>): void;
  37963. /**
  37964. * Update the current camera state depending on the inputs that have been used this frame.
  37965. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37966. */
  37967. checkInputs(): void;
  37968. /**
  37969. * Gets the class name of the current intput.
  37970. * @returns the class name
  37971. */
  37972. getClassName(): string;
  37973. /**
  37974. * Get the friendly name associated with the input class.
  37975. * @returns the input friendly name
  37976. */
  37977. getSimpleName(): string;
  37978. }
  37979. }
  37980. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  37981. import { Nullable } from "babylonjs/types";
  37982. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37983. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37984. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37985. /**
  37986. * Manage the gamepad inputs to control a free camera.
  37987. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37988. */
  37989. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37990. /**
  37991. * Define the camera the input is attached to.
  37992. */
  37993. camera: FreeCamera;
  37994. /**
  37995. * Define the Gamepad controlling the input
  37996. */
  37997. gamepad: Nullable<Gamepad>;
  37998. /**
  37999. * Defines the gamepad rotation sensiblity.
  38000. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38001. */
  38002. gamepadAngularSensibility: number;
  38003. /**
  38004. * Defines the gamepad move sensiblity.
  38005. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38006. */
  38007. gamepadMoveSensibility: number;
  38008. private _onGamepadConnectedObserver;
  38009. private _onGamepadDisconnectedObserver;
  38010. private _cameraTransform;
  38011. private _deltaTransform;
  38012. private _vector3;
  38013. private _vector2;
  38014. /**
  38015. * Attach the input controls to a specific dom element to get the input from.
  38016. * @param element Defines the element the controls should be listened from
  38017. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38018. */
  38019. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38020. /**
  38021. * Detach the current controls from the specified dom element.
  38022. * @param element Defines the element to stop listening the inputs from
  38023. */
  38024. detachControl(element: Nullable<HTMLElement>): void;
  38025. /**
  38026. * Update the current camera state depending on the inputs that have been used this frame.
  38027. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38028. */
  38029. checkInputs(): void;
  38030. /**
  38031. * Gets the class name of the current intput.
  38032. * @returns the class name
  38033. */
  38034. getClassName(): string;
  38035. /**
  38036. * Get the friendly name associated with the input class.
  38037. * @returns the input friendly name
  38038. */
  38039. getSimpleName(): string;
  38040. }
  38041. }
  38042. declare module "babylonjs/Misc/virtualJoystick" {
  38043. import { Nullable } from "babylonjs/types";
  38044. import { Vector3 } from "babylonjs/Maths/math";
  38045. /**
  38046. * Defines the potential axis of a Joystick
  38047. */
  38048. export enum JoystickAxis {
  38049. /** X axis */
  38050. X = 0,
  38051. /** Y axis */
  38052. Y = 1,
  38053. /** Z axis */
  38054. Z = 2
  38055. }
  38056. /**
  38057. * Class used to define virtual joystick (used in touch mode)
  38058. */
  38059. export class VirtualJoystick {
  38060. /**
  38061. * Gets or sets a boolean indicating that left and right values must be inverted
  38062. */
  38063. reverseLeftRight: boolean;
  38064. /**
  38065. * Gets or sets a boolean indicating that up and down values must be inverted
  38066. */
  38067. reverseUpDown: boolean;
  38068. /**
  38069. * Gets the offset value for the position (ie. the change of the position value)
  38070. */
  38071. deltaPosition: Vector3;
  38072. /**
  38073. * Gets a boolean indicating if the virtual joystick was pressed
  38074. */
  38075. pressed: boolean;
  38076. /**
  38077. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38078. */
  38079. static Canvas: Nullable<HTMLCanvasElement>;
  38080. private static _globalJoystickIndex;
  38081. private static vjCanvasContext;
  38082. private static vjCanvasWidth;
  38083. private static vjCanvasHeight;
  38084. private static halfWidth;
  38085. private _action;
  38086. private _axisTargetedByLeftAndRight;
  38087. private _axisTargetedByUpAndDown;
  38088. private _joystickSensibility;
  38089. private _inversedSensibility;
  38090. private _joystickPointerID;
  38091. private _joystickColor;
  38092. private _joystickPointerPos;
  38093. private _joystickPreviousPointerPos;
  38094. private _joystickPointerStartPos;
  38095. private _deltaJoystickVector;
  38096. private _leftJoystick;
  38097. private _touches;
  38098. private _onPointerDownHandlerRef;
  38099. private _onPointerMoveHandlerRef;
  38100. private _onPointerUpHandlerRef;
  38101. private _onResize;
  38102. /**
  38103. * Creates a new virtual joystick
  38104. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38105. */
  38106. constructor(leftJoystick?: boolean);
  38107. /**
  38108. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38109. * @param newJoystickSensibility defines the new sensibility
  38110. */
  38111. setJoystickSensibility(newJoystickSensibility: number): void;
  38112. private _onPointerDown;
  38113. private _onPointerMove;
  38114. private _onPointerUp;
  38115. /**
  38116. * Change the color of the virtual joystick
  38117. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38118. */
  38119. setJoystickColor(newColor: string): void;
  38120. /**
  38121. * Defines a callback to call when the joystick is touched
  38122. * @param action defines the callback
  38123. */
  38124. setActionOnTouch(action: () => any): void;
  38125. /**
  38126. * Defines which axis you'd like to control for left & right
  38127. * @param axis defines the axis to use
  38128. */
  38129. setAxisForLeftRight(axis: JoystickAxis): void;
  38130. /**
  38131. * Defines which axis you'd like to control for up & down
  38132. * @param axis defines the axis to use
  38133. */
  38134. setAxisForUpDown(axis: JoystickAxis): void;
  38135. private _drawVirtualJoystick;
  38136. /**
  38137. * Release internal HTML canvas
  38138. */
  38139. releaseCanvas(): void;
  38140. }
  38141. }
  38142. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  38143. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  38144. import { Nullable } from "babylonjs/types";
  38145. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38146. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38147. module "babylonjs/Cameras/freeCameraInputsManager" {
  38148. interface FreeCameraInputsManager {
  38149. /**
  38150. * Add virtual joystick input support to the input manager.
  38151. * @returns the current input manager
  38152. */
  38153. addVirtualJoystick(): FreeCameraInputsManager;
  38154. }
  38155. }
  38156. /**
  38157. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38158. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38159. */
  38160. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38161. /**
  38162. * Defines the camera the input is attached to.
  38163. */
  38164. camera: FreeCamera;
  38165. private _leftjoystick;
  38166. private _rightjoystick;
  38167. /**
  38168. * Gets the left stick of the virtual joystick.
  38169. * @returns The virtual Joystick
  38170. */
  38171. getLeftJoystick(): VirtualJoystick;
  38172. /**
  38173. * Gets the right stick of the virtual joystick.
  38174. * @returns The virtual Joystick
  38175. */
  38176. getRightJoystick(): VirtualJoystick;
  38177. /**
  38178. * Update the current camera state depending on the inputs that have been used this frame.
  38179. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38180. */
  38181. checkInputs(): void;
  38182. /**
  38183. * Attach the input controls to a specific dom element to get the input from.
  38184. * @param element Defines the element the controls should be listened from
  38185. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38186. */
  38187. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38188. /**
  38189. * Detach the current controls from the specified dom element.
  38190. * @param element Defines the element to stop listening the inputs from
  38191. */
  38192. detachControl(element: Nullable<HTMLElement>): void;
  38193. /**
  38194. * Gets the class name of the current intput.
  38195. * @returns the class name
  38196. */
  38197. getClassName(): string;
  38198. /**
  38199. * Get the friendly name associated with the input class.
  38200. * @returns the input friendly name
  38201. */
  38202. getSimpleName(): string;
  38203. }
  38204. }
  38205. declare module "babylonjs/Cameras/Inputs/index" {
  38206. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  38207. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  38208. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  38209. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  38210. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38211. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  38212. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  38213. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  38214. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  38215. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  38216. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38217. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  38218. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  38219. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  38220. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  38221. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38222. }
  38223. declare module "babylonjs/Cameras/touchCamera" {
  38224. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38225. import { Scene } from "babylonjs/scene";
  38226. import { Vector3 } from "babylonjs/Maths/math";
  38227. /**
  38228. * This represents a FPS type of camera controlled by touch.
  38229. * This is like a universal camera minus the Gamepad controls.
  38230. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38231. */
  38232. export class TouchCamera extends FreeCamera {
  38233. /**
  38234. * Defines the touch sensibility for rotation.
  38235. * The higher the faster.
  38236. */
  38237. touchAngularSensibility: number;
  38238. /**
  38239. * Defines the touch sensibility for move.
  38240. * The higher the faster.
  38241. */
  38242. touchMoveSensibility: number;
  38243. /**
  38244. * Instantiates a new touch camera.
  38245. * This represents a FPS type of camera controlled by touch.
  38246. * This is like a universal camera minus the Gamepad controls.
  38247. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38248. * @param name Define the name of the camera in the scene
  38249. * @param position Define the start position of the camera in the scene
  38250. * @param scene Define the scene the camera belongs to
  38251. */
  38252. constructor(name: string, position: Vector3, scene: Scene);
  38253. /**
  38254. * Gets the current object class name.
  38255. * @return the class name
  38256. */
  38257. getClassName(): string;
  38258. /** @hidden */
  38259. _setupInputs(): void;
  38260. }
  38261. }
  38262. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  38263. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38264. import { Scene } from "babylonjs/scene";
  38265. import { Vector3, Axis } from "babylonjs/Maths/math";
  38266. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38267. /**
  38268. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38269. * being tilted forward or back and left or right.
  38270. */
  38271. export class DeviceOrientationCamera extends FreeCamera {
  38272. private _initialQuaternion;
  38273. private _quaternionCache;
  38274. private _tmpDragQuaternion;
  38275. /**
  38276. * Creates a new device orientation camera
  38277. * @param name The name of the camera
  38278. * @param position The start position camera
  38279. * @param scene The scene the camera belongs to
  38280. */
  38281. constructor(name: string, position: Vector3, scene: Scene);
  38282. /**
  38283. * Disabled pointer input on first orientation sensor update (Default: true)
  38284. */
  38285. disablePointerInputWhenUsingDeviceOrientation: boolean;
  38286. private _dragFactor;
  38287. /**
  38288. * Enabled turning on the y axis when the orientation sensor is active
  38289. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38290. */
  38291. enableHorizontalDragging(dragFactor?: number): void;
  38292. /**
  38293. * Gets the current instance class name ("DeviceOrientationCamera").
  38294. * This helps avoiding instanceof at run time.
  38295. * @returns the class name
  38296. */
  38297. getClassName(): string;
  38298. /**
  38299. * @hidden
  38300. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38301. */
  38302. _checkInputs(): void;
  38303. /**
  38304. * Reset the camera to its default orientation on the specified axis only.
  38305. * @param axis The axis to reset
  38306. */
  38307. resetToCurrentRotation(axis?: Axis): void;
  38308. }
  38309. }
  38310. declare module "babylonjs/Cameras/universalCamera" {
  38311. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  38312. import { Scene } from "babylonjs/scene";
  38313. import { Vector3 } from "babylonjs/Maths/math";
  38314. /**
  38315. * 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,
  38316. * which still works and will still be found in many Playgrounds.
  38317. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38318. */
  38319. export class UniversalCamera extends TouchCamera {
  38320. /**
  38321. * Defines the gamepad rotation sensiblity.
  38322. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38323. */
  38324. gamepadAngularSensibility: number;
  38325. /**
  38326. * Defines the gamepad move sensiblity.
  38327. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38328. */
  38329. gamepadMoveSensibility: number;
  38330. /**
  38331. * 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,
  38332. * which still works and will still be found in many Playgrounds.
  38333. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38334. * @param name Define the name of the camera in the scene
  38335. * @param position Define the start position of the camera in the scene
  38336. * @param scene Define the scene the camera belongs to
  38337. */
  38338. constructor(name: string, position: Vector3, scene: Scene);
  38339. /**
  38340. * Gets the current object class name.
  38341. * @return the class name
  38342. */
  38343. getClassName(): string;
  38344. }
  38345. }
  38346. declare module "babylonjs/Cameras/gamepadCamera" {
  38347. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38348. import { Scene } from "babylonjs/scene";
  38349. import { Vector3 } from "babylonjs/Maths/math";
  38350. /**
  38351. * This represents a FPS type of camera. This is only here for back compat purpose.
  38352. * Please use the UniversalCamera instead as both are identical.
  38353. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38354. */
  38355. export class GamepadCamera extends UniversalCamera {
  38356. /**
  38357. * Instantiates a new Gamepad Camera
  38358. * This represents a FPS type of camera. This is only here for back compat purpose.
  38359. * Please use the UniversalCamera instead as both are identical.
  38360. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38361. * @param name Define the name of the camera in the scene
  38362. * @param position Define the start position of the camera in the scene
  38363. * @param scene Define the scene the camera belongs to
  38364. */
  38365. constructor(name: string, position: Vector3, scene: Scene);
  38366. /**
  38367. * Gets the current object class name.
  38368. * @return the class name
  38369. */
  38370. getClassName(): string;
  38371. }
  38372. }
  38373. declare module "babylonjs/Shaders/pass.fragment" {
  38374. /** @hidden */
  38375. export var passPixelShader: {
  38376. name: string;
  38377. shader: string;
  38378. };
  38379. }
  38380. declare module "babylonjs/Shaders/passCube.fragment" {
  38381. /** @hidden */
  38382. export var passCubePixelShader: {
  38383. name: string;
  38384. shader: string;
  38385. };
  38386. }
  38387. declare module "babylonjs/PostProcesses/passPostProcess" {
  38388. import { Nullable } from "babylonjs/types";
  38389. import { Camera } from "babylonjs/Cameras/camera";
  38390. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38391. import { Engine } from "babylonjs/Engines/engine";
  38392. import "babylonjs/Shaders/pass.fragment";
  38393. import "babylonjs/Shaders/passCube.fragment";
  38394. /**
  38395. * PassPostProcess which produces an output the same as it's input
  38396. */
  38397. export class PassPostProcess extends PostProcess {
  38398. /**
  38399. * Creates the PassPostProcess
  38400. * @param name The name of the effect.
  38401. * @param options The required width/height ratio to downsize to before computing the render pass.
  38402. * @param camera The camera to apply the render pass to.
  38403. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38404. * @param engine The engine which the post process will be applied. (default: current engine)
  38405. * @param reusable If the post process can be reused on the same frame. (default: false)
  38406. * @param textureType The type of texture to be used when performing the post processing.
  38407. * @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)
  38408. */
  38409. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38410. }
  38411. /**
  38412. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38413. */
  38414. export class PassCubePostProcess extends PostProcess {
  38415. private _face;
  38416. /**
  38417. * Gets or sets the cube face to display.
  38418. * * 0 is +X
  38419. * * 1 is -X
  38420. * * 2 is +Y
  38421. * * 3 is -Y
  38422. * * 4 is +Z
  38423. * * 5 is -Z
  38424. */
  38425. face: number;
  38426. /**
  38427. * Creates the PassCubePostProcess
  38428. * @param name The name of the effect.
  38429. * @param options The required width/height ratio to downsize to before computing the render pass.
  38430. * @param camera The camera to apply the render pass to.
  38431. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38432. * @param engine The engine which the post process will be applied. (default: current engine)
  38433. * @param reusable If the post process can be reused on the same frame. (default: false)
  38434. * @param textureType The type of texture to be used when performing the post processing.
  38435. * @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)
  38436. */
  38437. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38438. }
  38439. }
  38440. declare module "babylonjs/Shaders/anaglyph.fragment" {
  38441. /** @hidden */
  38442. export var anaglyphPixelShader: {
  38443. name: string;
  38444. shader: string;
  38445. };
  38446. }
  38447. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  38448. import { Engine } from "babylonjs/Engines/engine";
  38449. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38450. import { Camera } from "babylonjs/Cameras/camera";
  38451. import "babylonjs/Shaders/anaglyph.fragment";
  38452. /**
  38453. * Postprocess used to generate anaglyphic rendering
  38454. */
  38455. export class AnaglyphPostProcess extends PostProcess {
  38456. private _passedProcess;
  38457. /**
  38458. * Creates a new AnaglyphPostProcess
  38459. * @param name defines postprocess name
  38460. * @param options defines creation options or target ratio scale
  38461. * @param rigCameras defines cameras using this postprocess
  38462. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38463. * @param engine defines hosting engine
  38464. * @param reusable defines if the postprocess will be reused multiple times per frame
  38465. */
  38466. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38467. }
  38468. }
  38469. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  38470. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  38471. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38472. import { Scene } from "babylonjs/scene";
  38473. import { Vector3 } from "babylonjs/Maths/math";
  38474. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38475. /**
  38476. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38477. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38478. */
  38479. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38480. /**
  38481. * Creates a new AnaglyphArcRotateCamera
  38482. * @param name defines camera name
  38483. * @param alpha defines alpha angle (in radians)
  38484. * @param beta defines beta angle (in radians)
  38485. * @param radius defines radius
  38486. * @param target defines camera target
  38487. * @param interaxialDistance defines distance between each color axis
  38488. * @param scene defines the hosting scene
  38489. */
  38490. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38491. /**
  38492. * Gets camera class name
  38493. * @returns AnaglyphArcRotateCamera
  38494. */
  38495. getClassName(): string;
  38496. }
  38497. }
  38498. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  38499. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38500. import { Scene } from "babylonjs/scene";
  38501. import { Vector3 } from "babylonjs/Maths/math";
  38502. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38503. /**
  38504. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38505. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38506. */
  38507. export class AnaglyphFreeCamera extends FreeCamera {
  38508. /**
  38509. * Creates a new AnaglyphFreeCamera
  38510. * @param name defines camera name
  38511. * @param position defines initial position
  38512. * @param interaxialDistance defines distance between each color axis
  38513. * @param scene defines the hosting scene
  38514. */
  38515. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38516. /**
  38517. * Gets camera class name
  38518. * @returns AnaglyphFreeCamera
  38519. */
  38520. getClassName(): string;
  38521. }
  38522. }
  38523. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  38524. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38525. import { Scene } from "babylonjs/scene";
  38526. import { Vector3 } from "babylonjs/Maths/math";
  38527. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38528. /**
  38529. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38530. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38531. */
  38532. export class AnaglyphGamepadCamera extends GamepadCamera {
  38533. /**
  38534. * Creates a new AnaglyphGamepadCamera
  38535. * @param name defines camera name
  38536. * @param position defines initial position
  38537. * @param interaxialDistance defines distance between each color axis
  38538. * @param scene defines the hosting scene
  38539. */
  38540. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38541. /**
  38542. * Gets camera class name
  38543. * @returns AnaglyphGamepadCamera
  38544. */
  38545. getClassName(): string;
  38546. }
  38547. }
  38548. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  38549. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38550. import { Scene } from "babylonjs/scene";
  38551. import { Vector3 } from "babylonjs/Maths/math";
  38552. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38553. /**
  38554. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38555. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38556. */
  38557. export class AnaglyphUniversalCamera extends UniversalCamera {
  38558. /**
  38559. * Creates a new AnaglyphUniversalCamera
  38560. * @param name defines camera name
  38561. * @param position defines initial position
  38562. * @param interaxialDistance defines distance between each color axis
  38563. * @param scene defines the hosting scene
  38564. */
  38565. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38566. /**
  38567. * Gets camera class name
  38568. * @returns AnaglyphUniversalCamera
  38569. */
  38570. getClassName(): string;
  38571. }
  38572. }
  38573. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  38574. /** @hidden */
  38575. export var stereoscopicInterlacePixelShader: {
  38576. name: string;
  38577. shader: string;
  38578. };
  38579. }
  38580. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  38581. import { Camera } from "babylonjs/Cameras/camera";
  38582. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38583. import { Engine } from "babylonjs/Engines/engine";
  38584. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  38585. /**
  38586. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38587. */
  38588. export class StereoscopicInterlacePostProcess extends PostProcess {
  38589. private _stepSize;
  38590. private _passedProcess;
  38591. /**
  38592. * Initializes a StereoscopicInterlacePostProcess
  38593. * @param name The name of the effect.
  38594. * @param rigCameras The rig cameras to be appled to the post process
  38595. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38596. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38597. * @param engine The engine which the post process will be applied. (default: current engine)
  38598. * @param reusable If the post process can be reused on the same frame. (default: false)
  38599. */
  38600. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38601. }
  38602. }
  38603. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  38604. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  38605. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38606. import { Scene } from "babylonjs/scene";
  38607. import { Vector3 } from "babylonjs/Maths/math";
  38608. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38609. /**
  38610. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38611. * @see http://doc.babylonjs.com/features/cameras
  38612. */
  38613. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38614. /**
  38615. * Creates a new StereoscopicArcRotateCamera
  38616. * @param name defines camera name
  38617. * @param alpha defines alpha angle (in radians)
  38618. * @param beta defines beta angle (in radians)
  38619. * @param radius defines radius
  38620. * @param target defines camera target
  38621. * @param interaxialDistance defines distance between each color axis
  38622. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38623. * @param scene defines the hosting scene
  38624. */
  38625. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38626. /**
  38627. * Gets camera class name
  38628. * @returns StereoscopicArcRotateCamera
  38629. */
  38630. getClassName(): string;
  38631. }
  38632. }
  38633. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  38634. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38635. import { Scene } from "babylonjs/scene";
  38636. import { Vector3 } from "babylonjs/Maths/math";
  38637. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38638. /**
  38639. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38640. * @see http://doc.babylonjs.com/features/cameras
  38641. */
  38642. export class StereoscopicFreeCamera extends FreeCamera {
  38643. /**
  38644. * Creates a new StereoscopicFreeCamera
  38645. * @param name defines camera name
  38646. * @param position defines initial position
  38647. * @param interaxialDistance defines distance between each color axis
  38648. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38649. * @param scene defines the hosting scene
  38650. */
  38651. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38652. /**
  38653. * Gets camera class name
  38654. * @returns StereoscopicFreeCamera
  38655. */
  38656. getClassName(): string;
  38657. }
  38658. }
  38659. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  38660. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38661. import { Scene } from "babylonjs/scene";
  38662. import { Vector3 } from "babylonjs/Maths/math";
  38663. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38664. /**
  38665. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38666. * @see http://doc.babylonjs.com/features/cameras
  38667. */
  38668. export class StereoscopicGamepadCamera extends GamepadCamera {
  38669. /**
  38670. * Creates a new StereoscopicGamepadCamera
  38671. * @param name defines camera name
  38672. * @param position defines initial position
  38673. * @param interaxialDistance defines distance between each color axis
  38674. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38675. * @param scene defines the hosting scene
  38676. */
  38677. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38678. /**
  38679. * Gets camera class name
  38680. * @returns StereoscopicGamepadCamera
  38681. */
  38682. getClassName(): string;
  38683. }
  38684. }
  38685. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  38686. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38687. import { Scene } from "babylonjs/scene";
  38688. import { Vector3 } from "babylonjs/Maths/math";
  38689. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38690. /**
  38691. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38692. * @see http://doc.babylonjs.com/features/cameras
  38693. */
  38694. export class StereoscopicUniversalCamera extends UniversalCamera {
  38695. /**
  38696. * Creates a new StereoscopicUniversalCamera
  38697. * @param name defines camera name
  38698. * @param position defines initial position
  38699. * @param interaxialDistance defines distance between each color axis
  38700. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38701. * @param scene defines the hosting scene
  38702. */
  38703. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38704. /**
  38705. * Gets camera class name
  38706. * @returns StereoscopicUniversalCamera
  38707. */
  38708. getClassName(): string;
  38709. }
  38710. }
  38711. declare module "babylonjs/Cameras/Stereoscopic/index" {
  38712. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  38713. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  38714. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  38715. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  38716. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  38717. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  38718. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  38719. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  38720. }
  38721. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  38722. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38723. import { Scene } from "babylonjs/scene";
  38724. import { Vector3 } from "babylonjs/Maths/math";
  38725. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38726. /**
  38727. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38728. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38729. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38730. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38731. */
  38732. export class VirtualJoysticksCamera extends FreeCamera {
  38733. /**
  38734. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38735. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38736. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38737. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38738. * @param name Define the name of the camera in the scene
  38739. * @param position Define the start position of the camera in the scene
  38740. * @param scene Define the scene the camera belongs to
  38741. */
  38742. constructor(name: string, position: Vector3, scene: Scene);
  38743. /**
  38744. * Gets the current object class name.
  38745. * @return the class name
  38746. */
  38747. getClassName(): string;
  38748. }
  38749. }
  38750. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  38751. import { Matrix } from "babylonjs/Maths/math";
  38752. /**
  38753. * This represents all the required metrics to create a VR camera.
  38754. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38755. */
  38756. export class VRCameraMetrics {
  38757. /**
  38758. * Define the horizontal resolution off the screen.
  38759. */
  38760. hResolution: number;
  38761. /**
  38762. * Define the vertical resolution off the screen.
  38763. */
  38764. vResolution: number;
  38765. /**
  38766. * Define the horizontal screen size.
  38767. */
  38768. hScreenSize: number;
  38769. /**
  38770. * Define the vertical screen size.
  38771. */
  38772. vScreenSize: number;
  38773. /**
  38774. * Define the vertical screen center position.
  38775. */
  38776. vScreenCenter: number;
  38777. /**
  38778. * Define the distance of the eyes to the screen.
  38779. */
  38780. eyeToScreenDistance: number;
  38781. /**
  38782. * Define the distance between both lenses
  38783. */
  38784. lensSeparationDistance: number;
  38785. /**
  38786. * Define the distance between both viewer's eyes.
  38787. */
  38788. interpupillaryDistance: number;
  38789. /**
  38790. * Define the distortion factor of the VR postprocess.
  38791. * Please, touch with care.
  38792. */
  38793. distortionK: number[];
  38794. /**
  38795. * Define the chromatic aberration correction factors for the VR post process.
  38796. */
  38797. chromaAbCorrection: number[];
  38798. /**
  38799. * Define the scale factor of the post process.
  38800. * The smaller the better but the slower.
  38801. */
  38802. postProcessScaleFactor: number;
  38803. /**
  38804. * Define an offset for the lens center.
  38805. */
  38806. lensCenterOffset: number;
  38807. /**
  38808. * Define if the current vr camera should compensate the distortion of the lense or not.
  38809. */
  38810. compensateDistortion: boolean;
  38811. /**
  38812. * Defines if multiview should be enabled when rendering (Default: false)
  38813. */
  38814. multiviewEnabled: boolean;
  38815. /**
  38816. * Gets the rendering aspect ratio based on the provided resolutions.
  38817. */
  38818. readonly aspectRatio: number;
  38819. /**
  38820. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38821. */
  38822. readonly aspectRatioFov: number;
  38823. /**
  38824. * @hidden
  38825. */
  38826. readonly leftHMatrix: Matrix;
  38827. /**
  38828. * @hidden
  38829. */
  38830. readonly rightHMatrix: Matrix;
  38831. /**
  38832. * @hidden
  38833. */
  38834. readonly leftPreViewMatrix: Matrix;
  38835. /**
  38836. * @hidden
  38837. */
  38838. readonly rightPreViewMatrix: Matrix;
  38839. /**
  38840. * Get the default VRMetrics based on the most generic setup.
  38841. * @returns the default vr metrics
  38842. */
  38843. static GetDefault(): VRCameraMetrics;
  38844. }
  38845. }
  38846. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  38847. /** @hidden */
  38848. export var vrDistortionCorrectionPixelShader: {
  38849. name: string;
  38850. shader: string;
  38851. };
  38852. }
  38853. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  38854. import { Camera } from "babylonjs/Cameras/camera";
  38855. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38856. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38857. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  38858. /**
  38859. * VRDistortionCorrectionPostProcess used for mobile VR
  38860. */
  38861. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38862. private _isRightEye;
  38863. private _distortionFactors;
  38864. private _postProcessScaleFactor;
  38865. private _lensCenterOffset;
  38866. private _scaleIn;
  38867. private _scaleFactor;
  38868. private _lensCenter;
  38869. /**
  38870. * Initializes the VRDistortionCorrectionPostProcess
  38871. * @param name The name of the effect.
  38872. * @param camera The camera to apply the render pass to.
  38873. * @param isRightEye If this is for the right eye distortion
  38874. * @param vrMetrics All the required metrics for the VR camera
  38875. */
  38876. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38877. }
  38878. }
  38879. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  38880. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  38881. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38882. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38883. import { Scene } from "babylonjs/scene";
  38884. import { Vector3 } from "babylonjs/Maths/math";
  38885. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38886. import "babylonjs/Cameras/RigModes/vrRigMode";
  38887. /**
  38888. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38889. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38890. */
  38891. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38892. /**
  38893. * Creates a new VRDeviceOrientationArcRotateCamera
  38894. * @param name defines camera name
  38895. * @param alpha defines the camera rotation along the logitudinal axis
  38896. * @param beta defines the camera rotation along the latitudinal axis
  38897. * @param radius defines the camera distance from its target
  38898. * @param target defines the camera target
  38899. * @param scene defines the scene the camera belongs to
  38900. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38901. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38902. */
  38903. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38904. /**
  38905. * Gets camera class name
  38906. * @returns VRDeviceOrientationArcRotateCamera
  38907. */
  38908. getClassName(): string;
  38909. }
  38910. }
  38911. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  38912. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  38913. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38914. import { Scene } from "babylonjs/scene";
  38915. import { Vector3 } from "babylonjs/Maths/math";
  38916. import "babylonjs/Cameras/RigModes/vrRigMode";
  38917. /**
  38918. * Camera used to simulate VR rendering (based on FreeCamera)
  38919. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38920. */
  38921. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38922. /**
  38923. * Creates a new VRDeviceOrientationFreeCamera
  38924. * @param name defines camera name
  38925. * @param position defines the start position of the camera
  38926. * @param scene defines the scene the camera belongs to
  38927. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38928. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38929. */
  38930. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38931. /**
  38932. * Gets camera class name
  38933. * @returns VRDeviceOrientationFreeCamera
  38934. */
  38935. getClassName(): string;
  38936. }
  38937. }
  38938. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  38939. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  38940. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38941. import { Scene } from "babylonjs/scene";
  38942. import { Vector3 } from "babylonjs/Maths/math";
  38943. /**
  38944. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38945. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38946. */
  38947. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38948. /**
  38949. * Creates a new VRDeviceOrientationGamepadCamera
  38950. * @param name defines camera name
  38951. * @param position defines the start position of the camera
  38952. * @param scene defines the scene the camera belongs to
  38953. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38954. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38955. */
  38956. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38957. /**
  38958. * Gets camera class name
  38959. * @returns VRDeviceOrientationGamepadCamera
  38960. */
  38961. getClassName(): string;
  38962. }
  38963. }
  38964. declare module "babylonjs/Gamepads/xboxGamepad" {
  38965. import { Observable } from "babylonjs/Misc/observable";
  38966. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38967. /**
  38968. * Defines supported buttons for XBox360 compatible gamepads
  38969. */
  38970. export enum Xbox360Button {
  38971. /** A */
  38972. A = 0,
  38973. /** B */
  38974. B = 1,
  38975. /** X */
  38976. X = 2,
  38977. /** Y */
  38978. Y = 3,
  38979. /** Start */
  38980. Start = 4,
  38981. /** Back */
  38982. Back = 5,
  38983. /** Left button */
  38984. LB = 6,
  38985. /** Right button */
  38986. RB = 7,
  38987. /** Left stick */
  38988. LeftStick = 8,
  38989. /** Right stick */
  38990. RightStick = 9
  38991. }
  38992. /** Defines values for XBox360 DPad */
  38993. export enum Xbox360Dpad {
  38994. /** Up */
  38995. Up = 0,
  38996. /** Down */
  38997. Down = 1,
  38998. /** Left */
  38999. Left = 2,
  39000. /** Right */
  39001. Right = 3
  39002. }
  39003. /**
  39004. * Defines a XBox360 gamepad
  39005. */
  39006. export class Xbox360Pad extends Gamepad {
  39007. private _leftTrigger;
  39008. private _rightTrigger;
  39009. private _onlefttriggerchanged;
  39010. private _onrighttriggerchanged;
  39011. private _onbuttondown;
  39012. private _onbuttonup;
  39013. private _ondpaddown;
  39014. private _ondpadup;
  39015. /** Observable raised when a button is pressed */
  39016. onButtonDownObservable: Observable<Xbox360Button>;
  39017. /** Observable raised when a button is released */
  39018. onButtonUpObservable: Observable<Xbox360Button>;
  39019. /** Observable raised when a pad is pressed */
  39020. onPadDownObservable: Observable<Xbox360Dpad>;
  39021. /** Observable raised when a pad is released */
  39022. onPadUpObservable: Observable<Xbox360Dpad>;
  39023. private _buttonA;
  39024. private _buttonB;
  39025. private _buttonX;
  39026. private _buttonY;
  39027. private _buttonBack;
  39028. private _buttonStart;
  39029. private _buttonLB;
  39030. private _buttonRB;
  39031. private _buttonLeftStick;
  39032. private _buttonRightStick;
  39033. private _dPadUp;
  39034. private _dPadDown;
  39035. private _dPadLeft;
  39036. private _dPadRight;
  39037. private _isXboxOnePad;
  39038. /**
  39039. * Creates a new XBox360 gamepad object
  39040. * @param id defines the id of this gamepad
  39041. * @param index defines its index
  39042. * @param gamepad defines the internal HTML gamepad object
  39043. * @param xboxOne defines if it is a XBox One gamepad
  39044. */
  39045. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39046. /**
  39047. * Defines the callback to call when left trigger is pressed
  39048. * @param callback defines the callback to use
  39049. */
  39050. onlefttriggerchanged(callback: (value: number) => void): void;
  39051. /**
  39052. * Defines the callback to call when right trigger is pressed
  39053. * @param callback defines the callback to use
  39054. */
  39055. onrighttriggerchanged(callback: (value: number) => void): void;
  39056. /**
  39057. * Gets the left trigger value
  39058. */
  39059. /**
  39060. * Sets the left trigger value
  39061. */
  39062. leftTrigger: number;
  39063. /**
  39064. * Gets the right trigger value
  39065. */
  39066. /**
  39067. * Sets the right trigger value
  39068. */
  39069. rightTrigger: number;
  39070. /**
  39071. * Defines the callback to call when a button is pressed
  39072. * @param callback defines the callback to use
  39073. */
  39074. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39075. /**
  39076. * Defines the callback to call when a button is released
  39077. * @param callback defines the callback to use
  39078. */
  39079. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39080. /**
  39081. * Defines the callback to call when a pad is pressed
  39082. * @param callback defines the callback to use
  39083. */
  39084. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39085. /**
  39086. * Defines the callback to call when a pad is released
  39087. * @param callback defines the callback to use
  39088. */
  39089. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39090. private _setButtonValue;
  39091. private _setDPadValue;
  39092. /**
  39093. * Gets the value of the `A` button
  39094. */
  39095. /**
  39096. * Sets the value of the `A` button
  39097. */
  39098. buttonA: number;
  39099. /**
  39100. * Gets the value of the `B` button
  39101. */
  39102. /**
  39103. * Sets the value of the `B` button
  39104. */
  39105. buttonB: number;
  39106. /**
  39107. * Gets the value of the `X` button
  39108. */
  39109. /**
  39110. * Sets the value of the `X` button
  39111. */
  39112. buttonX: number;
  39113. /**
  39114. * Gets the value of the `Y` button
  39115. */
  39116. /**
  39117. * Sets the value of the `Y` button
  39118. */
  39119. buttonY: number;
  39120. /**
  39121. * Gets the value of the `Start` button
  39122. */
  39123. /**
  39124. * Sets the value of the `Start` button
  39125. */
  39126. buttonStart: number;
  39127. /**
  39128. * Gets the value of the `Back` button
  39129. */
  39130. /**
  39131. * Sets the value of the `Back` button
  39132. */
  39133. buttonBack: number;
  39134. /**
  39135. * Gets the value of the `Left` button
  39136. */
  39137. /**
  39138. * Sets the value of the `Left` button
  39139. */
  39140. buttonLB: number;
  39141. /**
  39142. * Gets the value of the `Right` button
  39143. */
  39144. /**
  39145. * Sets the value of the `Right` button
  39146. */
  39147. buttonRB: number;
  39148. /**
  39149. * Gets the value of the Left joystick
  39150. */
  39151. /**
  39152. * Sets the value of the Left joystick
  39153. */
  39154. buttonLeftStick: number;
  39155. /**
  39156. * Gets the value of the Right joystick
  39157. */
  39158. /**
  39159. * Sets the value of the Right joystick
  39160. */
  39161. buttonRightStick: number;
  39162. /**
  39163. * Gets the value of D-pad up
  39164. */
  39165. /**
  39166. * Sets the value of D-pad up
  39167. */
  39168. dPadUp: number;
  39169. /**
  39170. * Gets the value of D-pad down
  39171. */
  39172. /**
  39173. * Sets the value of D-pad down
  39174. */
  39175. dPadDown: number;
  39176. /**
  39177. * Gets the value of D-pad left
  39178. */
  39179. /**
  39180. * Sets the value of D-pad left
  39181. */
  39182. dPadLeft: number;
  39183. /**
  39184. * Gets the value of D-pad right
  39185. */
  39186. /**
  39187. * Sets the value of D-pad right
  39188. */
  39189. dPadRight: number;
  39190. /**
  39191. * Force the gamepad to synchronize with device values
  39192. */
  39193. update(): void;
  39194. /**
  39195. * Disposes the gamepad
  39196. */
  39197. dispose(): void;
  39198. }
  39199. }
  39200. declare module "babylonjs/Materials/pushMaterial" {
  39201. import { Nullable } from "babylonjs/types";
  39202. import { Scene } from "babylonjs/scene";
  39203. import { Matrix } from "babylonjs/Maths/math";
  39204. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39205. import { Mesh } from "babylonjs/Meshes/mesh";
  39206. import { Material } from "babylonjs/Materials/material";
  39207. import { Effect } from "babylonjs/Materials/effect";
  39208. /**
  39209. * Base class of materials working in push mode in babylon JS
  39210. * @hidden
  39211. */
  39212. export class PushMaterial extends Material {
  39213. protected _activeEffect: Effect;
  39214. protected _normalMatrix: Matrix;
  39215. /**
  39216. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39217. * This means that the material can keep using a previous shader while a new one is being compiled.
  39218. * This is mostly used when shader parallel compilation is supported (true by default)
  39219. */
  39220. allowShaderHotSwapping: boolean;
  39221. constructor(name: string, scene: Scene);
  39222. getEffect(): Effect;
  39223. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39224. /**
  39225. * Binds the given world matrix to the active effect
  39226. *
  39227. * @param world the matrix to bind
  39228. */
  39229. bindOnlyWorldMatrix(world: Matrix): void;
  39230. /**
  39231. * Binds the given normal matrix to the active effect
  39232. *
  39233. * @param normalMatrix the matrix to bind
  39234. */
  39235. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39236. bind(world: Matrix, mesh?: Mesh): void;
  39237. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39238. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39239. }
  39240. }
  39241. declare module "babylonjs/Materials/materialFlags" {
  39242. /**
  39243. * This groups all the flags used to control the materials channel.
  39244. */
  39245. export class MaterialFlags {
  39246. private static _DiffuseTextureEnabled;
  39247. /**
  39248. * Are diffuse textures enabled in the application.
  39249. */
  39250. static DiffuseTextureEnabled: boolean;
  39251. private static _AmbientTextureEnabled;
  39252. /**
  39253. * Are ambient textures enabled in the application.
  39254. */
  39255. static AmbientTextureEnabled: boolean;
  39256. private static _OpacityTextureEnabled;
  39257. /**
  39258. * Are opacity textures enabled in the application.
  39259. */
  39260. static OpacityTextureEnabled: boolean;
  39261. private static _ReflectionTextureEnabled;
  39262. /**
  39263. * Are reflection textures enabled in the application.
  39264. */
  39265. static ReflectionTextureEnabled: boolean;
  39266. private static _EmissiveTextureEnabled;
  39267. /**
  39268. * Are emissive textures enabled in the application.
  39269. */
  39270. static EmissiveTextureEnabled: boolean;
  39271. private static _SpecularTextureEnabled;
  39272. /**
  39273. * Are specular textures enabled in the application.
  39274. */
  39275. static SpecularTextureEnabled: boolean;
  39276. private static _BumpTextureEnabled;
  39277. /**
  39278. * Are bump textures enabled in the application.
  39279. */
  39280. static BumpTextureEnabled: boolean;
  39281. private static _LightmapTextureEnabled;
  39282. /**
  39283. * Are lightmap textures enabled in the application.
  39284. */
  39285. static LightmapTextureEnabled: boolean;
  39286. private static _RefractionTextureEnabled;
  39287. /**
  39288. * Are refraction textures enabled in the application.
  39289. */
  39290. static RefractionTextureEnabled: boolean;
  39291. private static _ColorGradingTextureEnabled;
  39292. /**
  39293. * Are color grading textures enabled in the application.
  39294. */
  39295. static ColorGradingTextureEnabled: boolean;
  39296. private static _FresnelEnabled;
  39297. /**
  39298. * Are fresnels enabled in the application.
  39299. */
  39300. static FresnelEnabled: boolean;
  39301. private static _ClearCoatTextureEnabled;
  39302. /**
  39303. * Are clear coat textures enabled in the application.
  39304. */
  39305. static ClearCoatTextureEnabled: boolean;
  39306. private static _ClearCoatBumpTextureEnabled;
  39307. /**
  39308. * Are clear coat bump textures enabled in the application.
  39309. */
  39310. static ClearCoatBumpTextureEnabled: boolean;
  39311. private static _ClearCoatTintTextureEnabled;
  39312. /**
  39313. * Are clear coat tint textures enabled in the application.
  39314. */
  39315. static ClearCoatTintTextureEnabled: boolean;
  39316. private static _SheenTextureEnabled;
  39317. /**
  39318. * Are sheen textures enabled in the application.
  39319. */
  39320. static SheenTextureEnabled: boolean;
  39321. private static _AnisotropicTextureEnabled;
  39322. /**
  39323. * Are anisotropic textures enabled in the application.
  39324. */
  39325. static AnisotropicTextureEnabled: boolean;
  39326. private static _ThicknessTextureEnabled;
  39327. /**
  39328. * Are thickness textures enabled in the application.
  39329. */
  39330. static ThicknessTextureEnabled: boolean;
  39331. }
  39332. }
  39333. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  39334. /** @hidden */
  39335. export var defaultFragmentDeclaration: {
  39336. name: string;
  39337. shader: string;
  39338. };
  39339. }
  39340. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  39341. /** @hidden */
  39342. export var defaultUboDeclaration: {
  39343. name: string;
  39344. shader: string;
  39345. };
  39346. }
  39347. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  39348. /** @hidden */
  39349. export var lightFragmentDeclaration: {
  39350. name: string;
  39351. shader: string;
  39352. };
  39353. }
  39354. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  39355. /** @hidden */
  39356. export var lightUboDeclaration: {
  39357. name: string;
  39358. shader: string;
  39359. };
  39360. }
  39361. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  39362. /** @hidden */
  39363. export var lightsFragmentFunctions: {
  39364. name: string;
  39365. shader: string;
  39366. };
  39367. }
  39368. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  39369. /** @hidden */
  39370. export var shadowsFragmentFunctions: {
  39371. name: string;
  39372. shader: string;
  39373. };
  39374. }
  39375. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  39376. /** @hidden */
  39377. export var fresnelFunction: {
  39378. name: string;
  39379. shader: string;
  39380. };
  39381. }
  39382. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  39383. /** @hidden */
  39384. export var reflectionFunction: {
  39385. name: string;
  39386. shader: string;
  39387. };
  39388. }
  39389. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  39390. /** @hidden */
  39391. export var bumpFragmentFunctions: {
  39392. name: string;
  39393. shader: string;
  39394. };
  39395. }
  39396. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  39397. /** @hidden */
  39398. export var logDepthDeclaration: {
  39399. name: string;
  39400. shader: string;
  39401. };
  39402. }
  39403. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  39404. /** @hidden */
  39405. export var bumpFragment: {
  39406. name: string;
  39407. shader: string;
  39408. };
  39409. }
  39410. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  39411. /** @hidden */
  39412. export var depthPrePass: {
  39413. name: string;
  39414. shader: string;
  39415. };
  39416. }
  39417. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  39418. /** @hidden */
  39419. export var lightFragment: {
  39420. name: string;
  39421. shader: string;
  39422. };
  39423. }
  39424. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  39425. /** @hidden */
  39426. export var logDepthFragment: {
  39427. name: string;
  39428. shader: string;
  39429. };
  39430. }
  39431. declare module "babylonjs/Shaders/default.fragment" {
  39432. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  39433. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39434. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39435. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39436. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39437. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  39438. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  39439. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  39440. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  39441. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39442. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39443. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  39444. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  39445. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39446. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  39447. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  39448. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  39449. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  39450. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  39451. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  39452. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  39453. /** @hidden */
  39454. export var defaultPixelShader: {
  39455. name: string;
  39456. shader: string;
  39457. };
  39458. }
  39459. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  39460. /** @hidden */
  39461. export var defaultVertexDeclaration: {
  39462. name: string;
  39463. shader: string;
  39464. };
  39465. }
  39466. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  39467. /** @hidden */
  39468. export var bumpVertexDeclaration: {
  39469. name: string;
  39470. shader: string;
  39471. };
  39472. }
  39473. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  39474. /** @hidden */
  39475. export var bumpVertex: {
  39476. name: string;
  39477. shader: string;
  39478. };
  39479. }
  39480. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  39481. /** @hidden */
  39482. export var fogVertex: {
  39483. name: string;
  39484. shader: string;
  39485. };
  39486. }
  39487. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  39488. /** @hidden */
  39489. export var shadowsVertex: {
  39490. name: string;
  39491. shader: string;
  39492. };
  39493. }
  39494. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  39495. /** @hidden */
  39496. export var pointCloudVertex: {
  39497. name: string;
  39498. shader: string;
  39499. };
  39500. }
  39501. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  39502. /** @hidden */
  39503. export var logDepthVertex: {
  39504. name: string;
  39505. shader: string;
  39506. };
  39507. }
  39508. declare module "babylonjs/Shaders/default.vertex" {
  39509. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  39510. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39511. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39512. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  39513. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  39514. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  39515. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  39516. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  39517. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39518. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39519. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  39520. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  39521. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39522. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  39523. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  39524. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  39525. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  39526. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  39527. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  39528. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  39529. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  39530. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  39531. /** @hidden */
  39532. export var defaultVertexShader: {
  39533. name: string;
  39534. shader: string;
  39535. };
  39536. }
  39537. declare module "babylonjs/Materials/standardMaterial" {
  39538. import { SmartArray } from "babylonjs/Misc/smartArray";
  39539. import { IAnimatable } from "babylonjs/Misc/tools";
  39540. import { Nullable } from "babylonjs/types";
  39541. import { Scene } from "babylonjs/scene";
  39542. import { Matrix, Color3 } from "babylonjs/Maths/math";
  39543. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39544. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39545. import { Mesh } from "babylonjs/Meshes/mesh";
  39546. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  39547. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39548. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  39549. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  39550. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  39551. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39552. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39553. import "babylonjs/Shaders/default.fragment";
  39554. import "babylonjs/Shaders/default.vertex";
  39555. /** @hidden */
  39556. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39557. MAINUV1: boolean;
  39558. MAINUV2: boolean;
  39559. DIFFUSE: boolean;
  39560. DIFFUSEDIRECTUV: number;
  39561. AMBIENT: boolean;
  39562. AMBIENTDIRECTUV: number;
  39563. OPACITY: boolean;
  39564. OPACITYDIRECTUV: number;
  39565. OPACITYRGB: boolean;
  39566. REFLECTION: boolean;
  39567. EMISSIVE: boolean;
  39568. EMISSIVEDIRECTUV: number;
  39569. SPECULAR: boolean;
  39570. SPECULARDIRECTUV: number;
  39571. BUMP: boolean;
  39572. BUMPDIRECTUV: number;
  39573. PARALLAX: boolean;
  39574. PARALLAXOCCLUSION: boolean;
  39575. SPECULAROVERALPHA: boolean;
  39576. CLIPPLANE: boolean;
  39577. CLIPPLANE2: boolean;
  39578. CLIPPLANE3: boolean;
  39579. CLIPPLANE4: boolean;
  39580. ALPHATEST: boolean;
  39581. DEPTHPREPASS: boolean;
  39582. ALPHAFROMDIFFUSE: boolean;
  39583. POINTSIZE: boolean;
  39584. FOG: boolean;
  39585. SPECULARTERM: boolean;
  39586. DIFFUSEFRESNEL: boolean;
  39587. OPACITYFRESNEL: boolean;
  39588. REFLECTIONFRESNEL: boolean;
  39589. REFRACTIONFRESNEL: boolean;
  39590. EMISSIVEFRESNEL: boolean;
  39591. FRESNEL: boolean;
  39592. NORMAL: boolean;
  39593. UV1: boolean;
  39594. UV2: boolean;
  39595. VERTEXCOLOR: boolean;
  39596. VERTEXALPHA: boolean;
  39597. NUM_BONE_INFLUENCERS: number;
  39598. BonesPerMesh: number;
  39599. BONETEXTURE: boolean;
  39600. INSTANCES: boolean;
  39601. GLOSSINESS: boolean;
  39602. ROUGHNESS: boolean;
  39603. EMISSIVEASILLUMINATION: boolean;
  39604. LINKEMISSIVEWITHDIFFUSE: boolean;
  39605. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39606. LIGHTMAP: boolean;
  39607. LIGHTMAPDIRECTUV: number;
  39608. OBJECTSPACE_NORMALMAP: boolean;
  39609. USELIGHTMAPASSHADOWMAP: boolean;
  39610. REFLECTIONMAP_3D: boolean;
  39611. REFLECTIONMAP_SPHERICAL: boolean;
  39612. REFLECTIONMAP_PLANAR: boolean;
  39613. REFLECTIONMAP_CUBIC: boolean;
  39614. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39615. REFLECTIONMAP_PROJECTION: boolean;
  39616. REFLECTIONMAP_SKYBOX: boolean;
  39617. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39618. REFLECTIONMAP_EXPLICIT: boolean;
  39619. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39620. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39621. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39622. INVERTCUBICMAP: boolean;
  39623. LOGARITHMICDEPTH: boolean;
  39624. REFRACTION: boolean;
  39625. REFRACTIONMAP_3D: boolean;
  39626. REFLECTIONOVERALPHA: boolean;
  39627. TWOSIDEDLIGHTING: boolean;
  39628. SHADOWFLOAT: boolean;
  39629. MORPHTARGETS: boolean;
  39630. MORPHTARGETS_NORMAL: boolean;
  39631. MORPHTARGETS_TANGENT: boolean;
  39632. NUM_MORPH_INFLUENCERS: number;
  39633. NONUNIFORMSCALING: boolean;
  39634. PREMULTIPLYALPHA: boolean;
  39635. IMAGEPROCESSING: boolean;
  39636. VIGNETTE: boolean;
  39637. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39638. VIGNETTEBLENDMODEOPAQUE: boolean;
  39639. TONEMAPPING: boolean;
  39640. TONEMAPPING_ACES: boolean;
  39641. CONTRAST: boolean;
  39642. COLORCURVES: boolean;
  39643. COLORGRADING: boolean;
  39644. COLORGRADING3D: boolean;
  39645. SAMPLER3DGREENDEPTH: boolean;
  39646. SAMPLER3DBGRMAP: boolean;
  39647. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39648. MULTIVIEW: boolean;
  39649. /**
  39650. * If the reflection texture on this material is in linear color space
  39651. * @hidden
  39652. */
  39653. IS_REFLECTION_LINEAR: boolean;
  39654. /**
  39655. * If the refraction texture on this material is in linear color space
  39656. * @hidden
  39657. */
  39658. IS_REFRACTION_LINEAR: boolean;
  39659. EXPOSURE: boolean;
  39660. constructor();
  39661. setReflectionMode(modeToEnable: string): void;
  39662. }
  39663. /**
  39664. * This is the default material used in Babylon. It is the best trade off between quality
  39665. * and performances.
  39666. * @see http://doc.babylonjs.com/babylon101/materials
  39667. */
  39668. export class StandardMaterial extends PushMaterial {
  39669. private _diffuseTexture;
  39670. /**
  39671. * The basic texture of the material as viewed under a light.
  39672. */
  39673. diffuseTexture: Nullable<BaseTexture>;
  39674. private _ambientTexture;
  39675. /**
  39676. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39677. */
  39678. ambientTexture: Nullable<BaseTexture>;
  39679. private _opacityTexture;
  39680. /**
  39681. * Define the transparency of the material from a texture.
  39682. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39683. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39684. */
  39685. opacityTexture: Nullable<BaseTexture>;
  39686. private _reflectionTexture;
  39687. /**
  39688. * Define the texture used to display the reflection.
  39689. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39690. */
  39691. reflectionTexture: Nullable<BaseTexture>;
  39692. private _emissiveTexture;
  39693. /**
  39694. * Define texture of the material as if self lit.
  39695. * This will be mixed in the final result even in the absence of light.
  39696. */
  39697. emissiveTexture: Nullable<BaseTexture>;
  39698. private _specularTexture;
  39699. /**
  39700. * Define how the color and intensity of the highlight given by the light in the material.
  39701. */
  39702. specularTexture: Nullable<BaseTexture>;
  39703. private _bumpTexture;
  39704. /**
  39705. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39706. * 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.
  39707. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39708. */
  39709. bumpTexture: Nullable<BaseTexture>;
  39710. private _lightmapTexture;
  39711. /**
  39712. * Complex lighting can be computationally expensive to compute at runtime.
  39713. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39714. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39715. */
  39716. lightmapTexture: Nullable<BaseTexture>;
  39717. private _refractionTexture;
  39718. /**
  39719. * Define the texture used to display the refraction.
  39720. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39721. */
  39722. refractionTexture: Nullable<BaseTexture>;
  39723. /**
  39724. * The color of the material lit by the environmental background lighting.
  39725. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39726. */
  39727. ambientColor: Color3;
  39728. /**
  39729. * The basic color of the material as viewed under a light.
  39730. */
  39731. diffuseColor: Color3;
  39732. /**
  39733. * Define how the color and intensity of the highlight given by the light in the material.
  39734. */
  39735. specularColor: Color3;
  39736. /**
  39737. * Define the color of the material as if self lit.
  39738. * This will be mixed in the final result even in the absence of light.
  39739. */
  39740. emissiveColor: Color3;
  39741. /**
  39742. * Defines how sharp are the highlights in the material.
  39743. * The bigger the value the sharper giving a more glossy feeling to the result.
  39744. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39745. */
  39746. specularPower: number;
  39747. private _useAlphaFromDiffuseTexture;
  39748. /**
  39749. * Does the transparency come from the diffuse texture alpha channel.
  39750. */
  39751. useAlphaFromDiffuseTexture: boolean;
  39752. private _useEmissiveAsIllumination;
  39753. /**
  39754. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39755. */
  39756. useEmissiveAsIllumination: boolean;
  39757. private _linkEmissiveWithDiffuse;
  39758. /**
  39759. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39760. * the emissive level when the final color is close to one.
  39761. */
  39762. linkEmissiveWithDiffuse: boolean;
  39763. private _useSpecularOverAlpha;
  39764. /**
  39765. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39766. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39767. */
  39768. useSpecularOverAlpha: boolean;
  39769. private _useReflectionOverAlpha;
  39770. /**
  39771. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39772. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39773. */
  39774. useReflectionOverAlpha: boolean;
  39775. private _disableLighting;
  39776. /**
  39777. * Does lights from the scene impacts this material.
  39778. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39779. */
  39780. disableLighting: boolean;
  39781. private _useObjectSpaceNormalMap;
  39782. /**
  39783. * Allows using an object space normal map (instead of tangent space).
  39784. */
  39785. useObjectSpaceNormalMap: boolean;
  39786. private _useParallax;
  39787. /**
  39788. * Is parallax enabled or not.
  39789. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39790. */
  39791. useParallax: boolean;
  39792. private _useParallaxOcclusion;
  39793. /**
  39794. * Is parallax occlusion enabled or not.
  39795. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39796. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39797. */
  39798. useParallaxOcclusion: boolean;
  39799. /**
  39800. * 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.
  39801. */
  39802. parallaxScaleBias: number;
  39803. private _roughness;
  39804. /**
  39805. * Helps to define how blurry the reflections should appears in the material.
  39806. */
  39807. roughness: number;
  39808. /**
  39809. * In case of refraction, define the value of the indice of refraction.
  39810. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39811. */
  39812. indexOfRefraction: number;
  39813. /**
  39814. * Invert the refraction texture alongside the y axis.
  39815. * It can be useful with procedural textures or probe for instance.
  39816. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39817. */
  39818. invertRefractionY: boolean;
  39819. /**
  39820. * Defines the alpha limits in alpha test mode.
  39821. */
  39822. alphaCutOff: number;
  39823. private _useLightmapAsShadowmap;
  39824. /**
  39825. * In case of light mapping, define whether the map contains light or shadow informations.
  39826. */
  39827. useLightmapAsShadowmap: boolean;
  39828. private _diffuseFresnelParameters;
  39829. /**
  39830. * Define the diffuse fresnel parameters of the material.
  39831. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39832. */
  39833. diffuseFresnelParameters: FresnelParameters;
  39834. private _opacityFresnelParameters;
  39835. /**
  39836. * Define the opacity fresnel parameters of the material.
  39837. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39838. */
  39839. opacityFresnelParameters: FresnelParameters;
  39840. private _reflectionFresnelParameters;
  39841. /**
  39842. * Define the reflection fresnel parameters of the material.
  39843. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39844. */
  39845. reflectionFresnelParameters: FresnelParameters;
  39846. private _refractionFresnelParameters;
  39847. /**
  39848. * Define the refraction fresnel parameters of the material.
  39849. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39850. */
  39851. refractionFresnelParameters: FresnelParameters;
  39852. private _emissiveFresnelParameters;
  39853. /**
  39854. * Define the emissive fresnel parameters of the material.
  39855. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39856. */
  39857. emissiveFresnelParameters: FresnelParameters;
  39858. private _useReflectionFresnelFromSpecular;
  39859. /**
  39860. * If true automatically deducts the fresnels values from the material specularity.
  39861. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39862. */
  39863. useReflectionFresnelFromSpecular: boolean;
  39864. private _useGlossinessFromSpecularMapAlpha;
  39865. /**
  39866. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39867. */
  39868. useGlossinessFromSpecularMapAlpha: boolean;
  39869. private _maxSimultaneousLights;
  39870. /**
  39871. * Defines the maximum number of lights that can be used in the material
  39872. */
  39873. maxSimultaneousLights: number;
  39874. private _invertNormalMapX;
  39875. /**
  39876. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39877. */
  39878. invertNormalMapX: boolean;
  39879. private _invertNormalMapY;
  39880. /**
  39881. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39882. */
  39883. invertNormalMapY: boolean;
  39884. private _twoSidedLighting;
  39885. /**
  39886. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39887. */
  39888. twoSidedLighting: boolean;
  39889. /**
  39890. * Default configuration related to image processing available in the standard Material.
  39891. */
  39892. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39893. /**
  39894. * Gets the image processing configuration used either in this material.
  39895. */
  39896. /**
  39897. * Sets the Default image processing configuration used either in the this material.
  39898. *
  39899. * If sets to null, the scene one is in use.
  39900. */
  39901. imageProcessingConfiguration: ImageProcessingConfiguration;
  39902. /**
  39903. * Keep track of the image processing observer to allow dispose and replace.
  39904. */
  39905. private _imageProcessingObserver;
  39906. /**
  39907. * Attaches a new image processing configuration to the Standard Material.
  39908. * @param configuration
  39909. */
  39910. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39911. /**
  39912. * Gets wether the color curves effect is enabled.
  39913. */
  39914. /**
  39915. * Sets wether the color curves effect is enabled.
  39916. */
  39917. cameraColorCurvesEnabled: boolean;
  39918. /**
  39919. * Gets wether the color grading effect is enabled.
  39920. */
  39921. /**
  39922. * Gets wether the color grading effect is enabled.
  39923. */
  39924. cameraColorGradingEnabled: boolean;
  39925. /**
  39926. * Gets wether tonemapping is enabled or not.
  39927. */
  39928. /**
  39929. * Sets wether tonemapping is enabled or not
  39930. */
  39931. cameraToneMappingEnabled: boolean;
  39932. /**
  39933. * The camera exposure used on this material.
  39934. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39935. * This corresponds to a photographic exposure.
  39936. */
  39937. /**
  39938. * The camera exposure used on this material.
  39939. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39940. * This corresponds to a photographic exposure.
  39941. */
  39942. cameraExposure: number;
  39943. /**
  39944. * Gets The camera contrast used on this material.
  39945. */
  39946. /**
  39947. * Sets The camera contrast used on this material.
  39948. */
  39949. cameraContrast: number;
  39950. /**
  39951. * Gets the Color Grading 2D Lookup Texture.
  39952. */
  39953. /**
  39954. * Sets the Color Grading 2D Lookup Texture.
  39955. */
  39956. cameraColorGradingTexture: Nullable<BaseTexture>;
  39957. /**
  39958. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39959. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39960. * 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;
  39961. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39962. */
  39963. /**
  39964. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39965. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39966. * 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;
  39967. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39968. */
  39969. cameraColorCurves: Nullable<ColorCurves>;
  39970. /**
  39971. * Custom callback helping to override the default shader used in the material.
  39972. */
  39973. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39974. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39975. protected _worldViewProjectionMatrix: Matrix;
  39976. protected _globalAmbientColor: Color3;
  39977. protected _useLogarithmicDepth: boolean;
  39978. /**
  39979. * Instantiates a new standard material.
  39980. * This is the default material used in Babylon. It is the best trade off between quality
  39981. * and performances.
  39982. * @see http://doc.babylonjs.com/babylon101/materials
  39983. * @param name Define the name of the material in the scene
  39984. * @param scene Define the scene the material belong to
  39985. */
  39986. constructor(name: string, scene: Scene);
  39987. /**
  39988. * Gets a boolean indicating that current material needs to register RTT
  39989. */
  39990. readonly hasRenderTargetTextures: boolean;
  39991. /**
  39992. * Gets the current class name of the material e.g. "StandardMaterial"
  39993. * Mainly use in serialization.
  39994. * @returns the class name
  39995. */
  39996. getClassName(): string;
  39997. /**
  39998. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39999. * You can try switching to logarithmic depth.
  40000. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40001. */
  40002. useLogarithmicDepth: boolean;
  40003. /**
  40004. * Specifies if the material will require alpha blending
  40005. * @returns a boolean specifying if alpha blending is needed
  40006. */
  40007. needAlphaBlending(): boolean;
  40008. /**
  40009. * Specifies if this material should be rendered in alpha test mode
  40010. * @returns a boolean specifying if an alpha test is needed.
  40011. */
  40012. needAlphaTesting(): boolean;
  40013. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40014. /**
  40015. * Get the texture used for alpha test purpose.
  40016. * @returns the diffuse texture in case of the standard material.
  40017. */
  40018. getAlphaTestTexture(): Nullable<BaseTexture>;
  40019. /**
  40020. * Get if the submesh is ready to be used and all its information available.
  40021. * Child classes can use it to update shaders
  40022. * @param mesh defines the mesh to check
  40023. * @param subMesh defines which submesh to check
  40024. * @param useInstances specifies that instances should be used
  40025. * @returns a boolean indicating that the submesh is ready or not
  40026. */
  40027. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40028. /**
  40029. * Builds the material UBO layouts.
  40030. * Used internally during the effect preparation.
  40031. */
  40032. buildUniformLayout(): void;
  40033. /**
  40034. * Unbinds the material from the mesh
  40035. */
  40036. unbind(): void;
  40037. /**
  40038. * Binds the submesh to this material by preparing the effect and shader to draw
  40039. * @param world defines the world transformation matrix
  40040. * @param mesh defines the mesh containing the submesh
  40041. * @param subMesh defines the submesh to bind the material to
  40042. */
  40043. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40044. /**
  40045. * Get the list of animatables in the material.
  40046. * @returns the list of animatables object used in the material
  40047. */
  40048. getAnimatables(): IAnimatable[];
  40049. /**
  40050. * Gets the active textures from the material
  40051. * @returns an array of textures
  40052. */
  40053. getActiveTextures(): BaseTexture[];
  40054. /**
  40055. * Specifies if the material uses a texture
  40056. * @param texture defines the texture to check against the material
  40057. * @returns a boolean specifying if the material uses the texture
  40058. */
  40059. hasTexture(texture: BaseTexture): boolean;
  40060. /**
  40061. * Disposes the material
  40062. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40063. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40064. */
  40065. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40066. /**
  40067. * Makes a duplicate of the material, and gives it a new name
  40068. * @param name defines the new name for the duplicated material
  40069. * @returns the cloned material
  40070. */
  40071. clone(name: string): StandardMaterial;
  40072. /**
  40073. * Serializes this material in a JSON representation
  40074. * @returns the serialized material object
  40075. */
  40076. serialize(): any;
  40077. /**
  40078. * Creates a standard material from parsed material data
  40079. * @param source defines the JSON representation of the material
  40080. * @param scene defines the hosting scene
  40081. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40082. * @returns a new standard material
  40083. */
  40084. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40085. /**
  40086. * Are diffuse textures enabled in the application.
  40087. */
  40088. static DiffuseTextureEnabled: boolean;
  40089. /**
  40090. * Are ambient textures enabled in the application.
  40091. */
  40092. static AmbientTextureEnabled: boolean;
  40093. /**
  40094. * Are opacity textures enabled in the application.
  40095. */
  40096. static OpacityTextureEnabled: boolean;
  40097. /**
  40098. * Are reflection textures enabled in the application.
  40099. */
  40100. static ReflectionTextureEnabled: boolean;
  40101. /**
  40102. * Are emissive textures enabled in the application.
  40103. */
  40104. static EmissiveTextureEnabled: boolean;
  40105. /**
  40106. * Are specular textures enabled in the application.
  40107. */
  40108. static SpecularTextureEnabled: boolean;
  40109. /**
  40110. * Are bump textures enabled in the application.
  40111. */
  40112. static BumpTextureEnabled: boolean;
  40113. /**
  40114. * Are lightmap textures enabled in the application.
  40115. */
  40116. static LightmapTextureEnabled: boolean;
  40117. /**
  40118. * Are refraction textures enabled in the application.
  40119. */
  40120. static RefractionTextureEnabled: boolean;
  40121. /**
  40122. * Are color grading textures enabled in the application.
  40123. */
  40124. static ColorGradingTextureEnabled: boolean;
  40125. /**
  40126. * Are fresnels enabled in the application.
  40127. */
  40128. static FresnelEnabled: boolean;
  40129. }
  40130. }
  40131. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  40132. import { Scene } from "babylonjs/scene";
  40133. import { Texture } from "babylonjs/Materials/Textures/texture";
  40134. /**
  40135. * A class extending Texture allowing drawing on a texture
  40136. * @see http://doc.babylonjs.com/how_to/dynamictexture
  40137. */
  40138. export class DynamicTexture extends Texture {
  40139. private _generateMipMaps;
  40140. private _canvas;
  40141. private _context;
  40142. private _engine;
  40143. /**
  40144. * Creates a DynamicTexture
  40145. * @param name defines the name of the texture
  40146. * @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
  40147. * @param scene defines the scene where you want the texture
  40148. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  40149. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  40150. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  40151. */
  40152. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  40153. /**
  40154. * Get the current class name of the texture useful for serialization or dynamic coding.
  40155. * @returns "DynamicTexture"
  40156. */
  40157. getClassName(): string;
  40158. /**
  40159. * Gets the current state of canRescale
  40160. */
  40161. readonly canRescale: boolean;
  40162. private _recreate;
  40163. /**
  40164. * Scales the texture
  40165. * @param ratio the scale factor to apply to both width and height
  40166. */
  40167. scale(ratio: number): void;
  40168. /**
  40169. * Resizes the texture
  40170. * @param width the new width
  40171. * @param height the new height
  40172. */
  40173. scaleTo(width: number, height: number): void;
  40174. /**
  40175. * Gets the context of the canvas used by the texture
  40176. * @returns the canvas context of the dynamic texture
  40177. */
  40178. getContext(): CanvasRenderingContext2D;
  40179. /**
  40180. * Clears the texture
  40181. */
  40182. clear(): void;
  40183. /**
  40184. * Updates the texture
  40185. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40186. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  40187. */
  40188. update(invertY?: boolean, premulAlpha?: boolean): void;
  40189. /**
  40190. * Draws text onto the texture
  40191. * @param text defines the text to be drawn
  40192. * @param x defines the placement of the text from the left
  40193. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  40194. * @param font defines the font to be used with font-style, font-size, font-name
  40195. * @param color defines the color used for the text
  40196. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  40197. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40198. * @param update defines whether texture is immediately update (default is true)
  40199. */
  40200. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  40201. /**
  40202. * Clones the texture
  40203. * @returns the clone of the texture.
  40204. */
  40205. clone(): DynamicTexture;
  40206. /**
  40207. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40208. * @returns a serialized dynamic texture object
  40209. */
  40210. serialize(): any;
  40211. /** @hidden */
  40212. _rebuild(): void;
  40213. }
  40214. }
  40215. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  40216. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40217. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40218. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40219. /** @hidden */
  40220. export var imageProcessingPixelShader: {
  40221. name: string;
  40222. shader: string;
  40223. };
  40224. }
  40225. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  40226. import { Nullable } from "babylonjs/types";
  40227. import { Color4 } from "babylonjs/Maths/math";
  40228. import { Camera } from "babylonjs/Cameras/camera";
  40229. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40230. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40231. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40232. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40233. import { Engine } from "babylonjs/Engines/engine";
  40234. import "babylonjs/Shaders/imageProcessing.fragment";
  40235. import "babylonjs/Shaders/postprocess.vertex";
  40236. /**
  40237. * ImageProcessingPostProcess
  40238. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40239. */
  40240. export class ImageProcessingPostProcess extends PostProcess {
  40241. /**
  40242. * Default configuration related to image processing available in the PBR Material.
  40243. */
  40244. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40245. /**
  40246. * Gets the image processing configuration used either in this material.
  40247. */
  40248. /**
  40249. * Sets the Default image processing configuration used either in the this material.
  40250. *
  40251. * If sets to null, the scene one is in use.
  40252. */
  40253. imageProcessingConfiguration: ImageProcessingConfiguration;
  40254. /**
  40255. * Keep track of the image processing observer to allow dispose and replace.
  40256. */
  40257. private _imageProcessingObserver;
  40258. /**
  40259. * Attaches a new image processing configuration to the PBR Material.
  40260. * @param configuration
  40261. */
  40262. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40263. /**
  40264. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40265. */
  40266. /**
  40267. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40268. */
  40269. colorCurves: Nullable<ColorCurves>;
  40270. /**
  40271. * Gets wether the color curves effect is enabled.
  40272. */
  40273. /**
  40274. * Sets wether the color curves effect is enabled.
  40275. */
  40276. colorCurvesEnabled: boolean;
  40277. /**
  40278. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40279. */
  40280. /**
  40281. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40282. */
  40283. colorGradingTexture: Nullable<BaseTexture>;
  40284. /**
  40285. * Gets wether the color grading effect is enabled.
  40286. */
  40287. /**
  40288. * Gets wether the color grading effect is enabled.
  40289. */
  40290. colorGradingEnabled: boolean;
  40291. /**
  40292. * Gets exposure used in the effect.
  40293. */
  40294. /**
  40295. * Sets exposure used in the effect.
  40296. */
  40297. exposure: number;
  40298. /**
  40299. * Gets wether tonemapping is enabled or not.
  40300. */
  40301. /**
  40302. * Sets wether tonemapping is enabled or not
  40303. */
  40304. toneMappingEnabled: boolean;
  40305. /**
  40306. * Gets the type of tone mapping effect.
  40307. */
  40308. /**
  40309. * Sets the type of tone mapping effect.
  40310. */
  40311. toneMappingType: number;
  40312. /**
  40313. * Gets contrast used in the effect.
  40314. */
  40315. /**
  40316. * Sets contrast used in the effect.
  40317. */
  40318. contrast: number;
  40319. /**
  40320. * Gets Vignette stretch size.
  40321. */
  40322. /**
  40323. * Sets Vignette stretch size.
  40324. */
  40325. vignetteStretch: number;
  40326. /**
  40327. * Gets Vignette centre X Offset.
  40328. */
  40329. /**
  40330. * Sets Vignette centre X Offset.
  40331. */
  40332. vignetteCentreX: number;
  40333. /**
  40334. * Gets Vignette centre Y Offset.
  40335. */
  40336. /**
  40337. * Sets Vignette centre Y Offset.
  40338. */
  40339. vignetteCentreY: number;
  40340. /**
  40341. * Gets Vignette weight or intensity of the vignette effect.
  40342. */
  40343. /**
  40344. * Sets Vignette weight or intensity of the vignette effect.
  40345. */
  40346. vignetteWeight: number;
  40347. /**
  40348. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40349. * if vignetteEnabled is set to true.
  40350. */
  40351. /**
  40352. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40353. * if vignetteEnabled is set to true.
  40354. */
  40355. vignetteColor: Color4;
  40356. /**
  40357. * Gets Camera field of view used by the Vignette effect.
  40358. */
  40359. /**
  40360. * Sets Camera field of view used by the Vignette effect.
  40361. */
  40362. vignetteCameraFov: number;
  40363. /**
  40364. * Gets the vignette blend mode allowing different kind of effect.
  40365. */
  40366. /**
  40367. * Sets the vignette blend mode allowing different kind of effect.
  40368. */
  40369. vignetteBlendMode: number;
  40370. /**
  40371. * Gets wether the vignette effect is enabled.
  40372. */
  40373. /**
  40374. * Sets wether the vignette effect is enabled.
  40375. */
  40376. vignetteEnabled: boolean;
  40377. private _fromLinearSpace;
  40378. /**
  40379. * Gets wether the input of the processing is in Gamma or Linear Space.
  40380. */
  40381. /**
  40382. * Sets wether the input of the processing is in Gamma or Linear Space.
  40383. */
  40384. fromLinearSpace: boolean;
  40385. /**
  40386. * Defines cache preventing GC.
  40387. */
  40388. private _defines;
  40389. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40390. /**
  40391. * "ImageProcessingPostProcess"
  40392. * @returns "ImageProcessingPostProcess"
  40393. */
  40394. getClassName(): string;
  40395. protected _updateParameters(): void;
  40396. dispose(camera?: Camera): void;
  40397. }
  40398. }
  40399. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  40400. import { Scene } from "babylonjs/scene";
  40401. import { Color3 } from "babylonjs/Maths/math";
  40402. import { Mesh } from "babylonjs/Meshes/mesh";
  40403. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  40404. import { Nullable } from "babylonjs/types";
  40405. /**
  40406. * Class containing static functions to help procedurally build meshes
  40407. */
  40408. export class GroundBuilder {
  40409. /**
  40410. * Creates a ground mesh
  40411. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40412. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40413. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40414. * @param name defines the name of the mesh
  40415. * @param options defines the options used to create the mesh
  40416. * @param scene defines the hosting scene
  40417. * @returns the ground mesh
  40418. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40419. */
  40420. static CreateGround(name: string, options: {
  40421. width?: number;
  40422. height?: number;
  40423. subdivisions?: number;
  40424. subdivisionsX?: number;
  40425. subdivisionsY?: number;
  40426. updatable?: boolean;
  40427. }, scene: any): Mesh;
  40428. /**
  40429. * Creates a tiled ground mesh
  40430. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40431. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40432. * * 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
  40433. * * 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
  40434. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40435. * @param name defines the name of the mesh
  40436. * @param options defines the options used to create the mesh
  40437. * @param scene defines the hosting scene
  40438. * @returns the tiled ground mesh
  40439. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40440. */
  40441. static CreateTiledGround(name: string, options: {
  40442. xmin: number;
  40443. zmin: number;
  40444. xmax: number;
  40445. zmax: number;
  40446. subdivisions?: {
  40447. w: number;
  40448. h: number;
  40449. };
  40450. precision?: {
  40451. w: number;
  40452. h: number;
  40453. };
  40454. updatable?: boolean;
  40455. }, scene?: Nullable<Scene>): Mesh;
  40456. /**
  40457. * Creates a ground mesh from a height map
  40458. * * The parameter `url` sets the URL of the height map image resource.
  40459. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40460. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40461. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40462. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40463. * * 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.
  40464. * * 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).
  40465. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40466. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40467. * @param name defines the name of the mesh
  40468. * @param url defines the url to the height map
  40469. * @param options defines the options used to create the mesh
  40470. * @param scene defines the hosting scene
  40471. * @returns the ground mesh
  40472. * @see https://doc.babylonjs.com/babylon101/height_map
  40473. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40474. */
  40475. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40476. width?: number;
  40477. height?: number;
  40478. subdivisions?: number;
  40479. minHeight?: number;
  40480. maxHeight?: number;
  40481. colorFilter?: Color3;
  40482. alphaFilter?: number;
  40483. updatable?: boolean;
  40484. onReady?: (mesh: GroundMesh) => void;
  40485. }, scene?: Nullable<Scene>): GroundMesh;
  40486. }
  40487. }
  40488. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  40489. import { Vector4 } from "babylonjs/Maths/math";
  40490. import { Mesh } from "babylonjs/Meshes/mesh";
  40491. /**
  40492. * Class containing static functions to help procedurally build meshes
  40493. */
  40494. export class TorusBuilder {
  40495. /**
  40496. * Creates a torus mesh
  40497. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40498. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40499. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40500. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40501. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40502. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40503. * @param name defines the name of the mesh
  40504. * @param options defines the options used to create the mesh
  40505. * @param scene defines the hosting scene
  40506. * @returns the torus mesh
  40507. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40508. */
  40509. static CreateTorus(name: string, options: {
  40510. diameter?: number;
  40511. thickness?: number;
  40512. tessellation?: number;
  40513. updatable?: boolean;
  40514. sideOrientation?: number;
  40515. frontUVs?: Vector4;
  40516. backUVs?: Vector4;
  40517. }, scene: any): Mesh;
  40518. }
  40519. }
  40520. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  40521. import { Color4, Vector4 } from "babylonjs/Maths/math";
  40522. import { Mesh } from "babylonjs/Meshes/mesh";
  40523. /**
  40524. * Class containing static functions to help procedurally build meshes
  40525. */
  40526. export class CylinderBuilder {
  40527. /**
  40528. * Creates a cylinder or a cone mesh
  40529. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40530. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40531. * * 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.
  40532. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40533. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40534. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40535. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40536. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40537. * * 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).
  40538. * * 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
  40539. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40540. * * 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
  40541. * * 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.
  40542. * * If `enclose` is false, a ring surface is one element.
  40543. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40544. * * 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
  40545. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40546. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40547. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40548. * @param name defines the name of the mesh
  40549. * @param options defines the options used to create the mesh
  40550. * @param scene defines the hosting scene
  40551. * @returns the cylinder mesh
  40552. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40553. */
  40554. static CreateCylinder(name: string, options: {
  40555. height?: number;
  40556. diameterTop?: number;
  40557. diameterBottom?: number;
  40558. diameter?: number;
  40559. tessellation?: number;
  40560. subdivisions?: number;
  40561. arc?: number;
  40562. faceColors?: Color4[];
  40563. faceUV?: Vector4[];
  40564. updatable?: boolean;
  40565. hasRings?: boolean;
  40566. enclose?: boolean;
  40567. sideOrientation?: number;
  40568. frontUVs?: Vector4;
  40569. backUVs?: Vector4;
  40570. }, scene: any): Mesh;
  40571. }
  40572. }
  40573. declare module "babylonjs/Gamepads/gamepadManager" {
  40574. import { Observable } from "babylonjs/Misc/observable";
  40575. import { Nullable } from "babylonjs/types";
  40576. import { Scene } from "babylonjs/scene";
  40577. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40578. /**
  40579. * Manager for handling gamepads
  40580. */
  40581. export class GamepadManager {
  40582. private _scene?;
  40583. private _babylonGamepads;
  40584. private _oneGamepadConnected;
  40585. /** @hidden */
  40586. _isMonitoring: boolean;
  40587. private _gamepadEventSupported;
  40588. private _gamepadSupport;
  40589. /**
  40590. * observable to be triggered when the gamepad controller has been connected
  40591. */
  40592. onGamepadConnectedObservable: Observable<Gamepad>;
  40593. /**
  40594. * observable to be triggered when the gamepad controller has been disconnected
  40595. */
  40596. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40597. private _onGamepadConnectedEvent;
  40598. private _onGamepadDisconnectedEvent;
  40599. /**
  40600. * Initializes the gamepad manager
  40601. * @param _scene BabylonJS scene
  40602. */
  40603. constructor(_scene?: Scene | undefined);
  40604. /**
  40605. * The gamepads in the game pad manager
  40606. */
  40607. readonly gamepads: Gamepad[];
  40608. /**
  40609. * Get the gamepad controllers based on type
  40610. * @param type The type of gamepad controller
  40611. * @returns Nullable gamepad
  40612. */
  40613. getGamepadByType(type?: number): Nullable<Gamepad>;
  40614. /**
  40615. * Disposes the gamepad manager
  40616. */
  40617. dispose(): void;
  40618. private _addNewGamepad;
  40619. private _startMonitoringGamepads;
  40620. private _stopMonitoringGamepads;
  40621. /** @hidden */
  40622. _checkGamepadsStatus(): void;
  40623. private _updateGamepadObjects;
  40624. }
  40625. }
  40626. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40627. import { Nullable } from "babylonjs/types";
  40628. import { Scene } from "babylonjs/scene";
  40629. import { ISceneComponent } from "babylonjs/sceneComponent";
  40630. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40631. module "babylonjs/scene" {
  40632. interface Scene {
  40633. /** @hidden */
  40634. _gamepadManager: Nullable<GamepadManager>;
  40635. /**
  40636. * Gets the gamepad manager associated with the scene
  40637. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40638. */
  40639. gamepadManager: GamepadManager;
  40640. }
  40641. }
  40642. module "babylonjs/Cameras/freeCameraInputsManager" {
  40643. /**
  40644. * Interface representing a free camera inputs manager
  40645. */
  40646. interface FreeCameraInputsManager {
  40647. /**
  40648. * Adds gamepad input support to the FreeCameraInputsManager.
  40649. * @returns the FreeCameraInputsManager
  40650. */
  40651. addGamepad(): FreeCameraInputsManager;
  40652. }
  40653. }
  40654. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40655. /**
  40656. * Interface representing an arc rotate camera inputs manager
  40657. */
  40658. interface ArcRotateCameraInputsManager {
  40659. /**
  40660. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40661. * @returns the camera inputs manager
  40662. */
  40663. addGamepad(): ArcRotateCameraInputsManager;
  40664. }
  40665. }
  40666. /**
  40667. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40668. */
  40669. export class GamepadSystemSceneComponent implements ISceneComponent {
  40670. /**
  40671. * The component name helpfull to identify the component in the list of scene components.
  40672. */
  40673. readonly name: string;
  40674. /**
  40675. * The scene the component belongs to.
  40676. */
  40677. scene: Scene;
  40678. /**
  40679. * Creates a new instance of the component for the given scene
  40680. * @param scene Defines the scene to register the component in
  40681. */
  40682. constructor(scene: Scene);
  40683. /**
  40684. * Registers the component in a given scene
  40685. */
  40686. register(): void;
  40687. /**
  40688. * Rebuilds the elements related to this component in case of
  40689. * context lost for instance.
  40690. */
  40691. rebuild(): void;
  40692. /**
  40693. * Disposes the component and the associated ressources
  40694. */
  40695. dispose(): void;
  40696. private _beforeCameraUpdate;
  40697. }
  40698. }
  40699. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  40700. import { Observable } from "babylonjs/Misc/observable";
  40701. import { Nullable } from "babylonjs/types";
  40702. import { Camera } from "babylonjs/Cameras/camera";
  40703. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40704. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40705. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  40706. import { Scene } from "babylonjs/scene";
  40707. import { Vector3, Color3 } from "babylonjs/Maths/math";
  40708. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  40709. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40710. import { Mesh } from "babylonjs/Meshes/mesh";
  40711. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40712. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40713. import "babylonjs/Meshes/Builders/groundBuilder";
  40714. import "babylonjs/Meshes/Builders/torusBuilder";
  40715. import "babylonjs/Meshes/Builders/cylinderBuilder";
  40716. import "babylonjs/Gamepads/gamepadSceneComponent";
  40717. import "babylonjs/Animations/animatable";
  40718. /**
  40719. * Options to modify the vr teleportation behavior.
  40720. */
  40721. export interface VRTeleportationOptions {
  40722. /**
  40723. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40724. */
  40725. floorMeshName?: string;
  40726. /**
  40727. * A list of meshes to be used as the teleportation floor. (default: empty)
  40728. */
  40729. floorMeshes?: Mesh[];
  40730. }
  40731. /**
  40732. * Options to modify the vr experience helper's behavior.
  40733. */
  40734. export interface VRExperienceHelperOptions extends WebVROptions {
  40735. /**
  40736. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40737. */
  40738. createDeviceOrientationCamera?: boolean;
  40739. /**
  40740. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40741. */
  40742. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40743. /**
  40744. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40745. */
  40746. laserToggle?: boolean;
  40747. /**
  40748. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40749. */
  40750. floorMeshes?: Mesh[];
  40751. /**
  40752. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40753. */
  40754. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40755. }
  40756. /**
  40757. * Event containing information after VR has been entered
  40758. */
  40759. export class OnAfterEnteringVRObservableEvent {
  40760. /**
  40761. * If entering vr was successful
  40762. */
  40763. success: boolean;
  40764. }
  40765. /**
  40766. * Helps to quickly add VR support to an existing scene.
  40767. * See http://doc.babylonjs.com/how_to/webvr_helper
  40768. */
  40769. export class VRExperienceHelper {
  40770. /** Options to modify the vr experience helper's behavior. */
  40771. webVROptions: VRExperienceHelperOptions;
  40772. private _scene;
  40773. private _position;
  40774. private _btnVR;
  40775. private _btnVRDisplayed;
  40776. private _webVRsupported;
  40777. private _webVRready;
  40778. private _webVRrequesting;
  40779. private _webVRpresenting;
  40780. private _hasEnteredVR;
  40781. private _fullscreenVRpresenting;
  40782. private _canvas;
  40783. private _webVRCamera;
  40784. private _vrDeviceOrientationCamera;
  40785. private _deviceOrientationCamera;
  40786. private _existingCamera;
  40787. private _onKeyDown;
  40788. private _onVrDisplayPresentChange;
  40789. private _onVRDisplayChanged;
  40790. private _onVRRequestPresentStart;
  40791. private _onVRRequestPresentComplete;
  40792. /**
  40793. * Observable raised right before entering VR.
  40794. */
  40795. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40796. /**
  40797. * Observable raised when entering VR has completed.
  40798. */
  40799. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40800. /**
  40801. * Observable raised when exiting VR.
  40802. */
  40803. onExitingVRObservable: Observable<VRExperienceHelper>;
  40804. /**
  40805. * Observable raised when controller mesh is loaded.
  40806. */
  40807. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40808. /** Return this.onEnteringVRObservable
  40809. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40810. */
  40811. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40812. /** Return this.onExitingVRObservable
  40813. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40814. */
  40815. readonly onExitingVR: Observable<VRExperienceHelper>;
  40816. /** Return this.onControllerMeshLoadedObservable
  40817. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40818. */
  40819. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40820. private _rayLength;
  40821. private _useCustomVRButton;
  40822. private _teleportationRequested;
  40823. private _teleportActive;
  40824. private _floorMeshName;
  40825. private _floorMeshesCollection;
  40826. private _rotationAllowed;
  40827. private _teleportBackwardsVector;
  40828. private _teleportationTarget;
  40829. private _isDefaultTeleportationTarget;
  40830. private _postProcessMove;
  40831. private _teleportationFillColor;
  40832. private _teleportationBorderColor;
  40833. private _rotationAngle;
  40834. private _haloCenter;
  40835. private _cameraGazer;
  40836. private _padSensibilityUp;
  40837. private _padSensibilityDown;
  40838. private _leftController;
  40839. private _rightController;
  40840. /**
  40841. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40842. */
  40843. onNewMeshSelected: Observable<AbstractMesh>;
  40844. /**
  40845. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40846. */
  40847. onNewMeshPicked: Observable<PickingInfo>;
  40848. private _circleEase;
  40849. /**
  40850. * Observable raised before camera teleportation
  40851. */
  40852. onBeforeCameraTeleport: Observable<Vector3>;
  40853. /**
  40854. * Observable raised after camera teleportation
  40855. */
  40856. onAfterCameraTeleport: Observable<Vector3>;
  40857. /**
  40858. * Observable raised when current selected mesh gets unselected
  40859. */
  40860. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40861. private _raySelectionPredicate;
  40862. /**
  40863. * To be optionaly changed by user to define custom ray selection
  40864. */
  40865. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40866. /**
  40867. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40868. */
  40869. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40870. /**
  40871. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40872. */
  40873. teleportationEnabled: boolean;
  40874. private _defaultHeight;
  40875. private _teleportationInitialized;
  40876. private _interactionsEnabled;
  40877. private _interactionsRequested;
  40878. private _displayGaze;
  40879. private _displayLaserPointer;
  40880. /**
  40881. * The mesh used to display where the user is going to teleport.
  40882. */
  40883. /**
  40884. * Sets the mesh to be used to display where the user is going to teleport.
  40885. */
  40886. teleportationTarget: Mesh;
  40887. /**
  40888. * 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
  40889. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40890. * See http://doc.babylonjs.com/resources/baking_transformations
  40891. */
  40892. gazeTrackerMesh: Mesh;
  40893. /**
  40894. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40895. */
  40896. updateGazeTrackerScale: boolean;
  40897. /**
  40898. * If the gaze trackers color should be updated when selecting meshes
  40899. */
  40900. updateGazeTrackerColor: boolean;
  40901. /**
  40902. * The gaze tracking mesh corresponding to the left controller
  40903. */
  40904. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40905. /**
  40906. * The gaze tracking mesh corresponding to the right controller
  40907. */
  40908. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40909. /**
  40910. * If the ray of the gaze should be displayed.
  40911. */
  40912. /**
  40913. * Sets if the ray of the gaze should be displayed.
  40914. */
  40915. displayGaze: boolean;
  40916. /**
  40917. * If the ray of the LaserPointer should be displayed.
  40918. */
  40919. /**
  40920. * Sets if the ray of the LaserPointer should be displayed.
  40921. */
  40922. displayLaserPointer: boolean;
  40923. /**
  40924. * The deviceOrientationCamera used as the camera when not in VR.
  40925. */
  40926. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40927. /**
  40928. * Based on the current WebVR support, returns the current VR camera used.
  40929. */
  40930. readonly currentVRCamera: Nullable<Camera>;
  40931. /**
  40932. * The webVRCamera which is used when in VR.
  40933. */
  40934. readonly webVRCamera: WebVRFreeCamera;
  40935. /**
  40936. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40937. */
  40938. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40939. private readonly _teleportationRequestInitiated;
  40940. /**
  40941. * Defines wether or not Pointer lock should be requested when switching to
  40942. * full screen.
  40943. */
  40944. requestPointerLockOnFullScreen: boolean;
  40945. /**
  40946. * Instantiates a VRExperienceHelper.
  40947. * Helps to quickly add VR support to an existing scene.
  40948. * @param scene The scene the VRExperienceHelper belongs to.
  40949. * @param webVROptions Options to modify the vr experience helper's behavior.
  40950. */
  40951. constructor(scene: Scene,
  40952. /** Options to modify the vr experience helper's behavior. */
  40953. webVROptions?: VRExperienceHelperOptions);
  40954. private _onDefaultMeshLoaded;
  40955. private _onResize;
  40956. private _onFullscreenChange;
  40957. /**
  40958. * Gets a value indicating if we are currently in VR mode.
  40959. */
  40960. readonly isInVRMode: boolean;
  40961. private onVrDisplayPresentChange;
  40962. private onVRDisplayChanged;
  40963. private moveButtonToBottomRight;
  40964. private displayVRButton;
  40965. private updateButtonVisibility;
  40966. private _cachedAngularSensibility;
  40967. /**
  40968. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40969. * Otherwise, will use the fullscreen API.
  40970. */
  40971. enterVR(): void;
  40972. /**
  40973. * Attempt to exit VR, or fullscreen.
  40974. */
  40975. exitVR(): void;
  40976. /**
  40977. * The position of the vr experience helper.
  40978. */
  40979. /**
  40980. * Sets the position of the vr experience helper.
  40981. */
  40982. position: Vector3;
  40983. /**
  40984. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40985. */
  40986. enableInteractions(): void;
  40987. private readonly _noControllerIsActive;
  40988. private beforeRender;
  40989. private _isTeleportationFloor;
  40990. /**
  40991. * Adds a floor mesh to be used for teleportation.
  40992. * @param floorMesh the mesh to be used for teleportation.
  40993. */
  40994. addFloorMesh(floorMesh: Mesh): void;
  40995. /**
  40996. * Removes a floor mesh from being used for teleportation.
  40997. * @param floorMesh the mesh to be removed.
  40998. */
  40999. removeFloorMesh(floorMesh: Mesh): void;
  41000. /**
  41001. * Enables interactions and teleportation using the VR controllers and gaze.
  41002. * @param vrTeleportationOptions options to modify teleportation behavior.
  41003. */
  41004. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41005. private _onNewGamepadConnected;
  41006. private _tryEnableInteractionOnController;
  41007. private _onNewGamepadDisconnected;
  41008. private _enableInteractionOnController;
  41009. private _checkTeleportWithRay;
  41010. private _checkRotate;
  41011. private _checkTeleportBackwards;
  41012. private _enableTeleportationOnController;
  41013. private _createTeleportationCircles;
  41014. private _displayTeleportationTarget;
  41015. private _hideTeleportationTarget;
  41016. private _rotateCamera;
  41017. private _moveTeleportationSelectorTo;
  41018. private _workingVector;
  41019. private _workingQuaternion;
  41020. private _workingMatrix;
  41021. /**
  41022. * Teleports the users feet to the desired location
  41023. * @param location The location where the user's feet should be placed
  41024. */
  41025. teleportCamera(location: Vector3): void;
  41026. private _convertNormalToDirectionOfRay;
  41027. private _castRayAndSelectObject;
  41028. private _notifySelectedMeshUnselected;
  41029. /**
  41030. * Sets the color of the laser ray from the vr controllers.
  41031. * @param color new color for the ray.
  41032. */
  41033. changeLaserColor(color: Color3): void;
  41034. /**
  41035. * Sets the color of the ray from the vr headsets gaze.
  41036. * @param color new color for the ray.
  41037. */
  41038. changeGazeColor(color: Color3): void;
  41039. /**
  41040. * Exits VR and disposes of the vr experience helper
  41041. */
  41042. dispose(): void;
  41043. /**
  41044. * Gets the name of the VRExperienceHelper class
  41045. * @returns "VRExperienceHelper"
  41046. */
  41047. getClassName(): string;
  41048. }
  41049. }
  41050. declare module "babylonjs/Cameras/VR/index" {
  41051. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  41052. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  41053. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41054. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  41055. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  41056. export * from "babylonjs/Cameras/VR/webVRCamera";
  41057. }
  41058. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  41059. import { Observable } from "babylonjs/Misc/observable";
  41060. import { Nullable } from "babylonjs/types";
  41061. import { IDisposable, Scene } from "babylonjs/scene";
  41062. import { Vector3 } from "babylonjs/Maths/math";
  41063. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41064. import { Ray } from "babylonjs/Culling/ray";
  41065. /**
  41066. * Manages an XRSession
  41067. * @see https://doc.babylonjs.com/how_to/webxr
  41068. */
  41069. export class WebXRSessionManager implements IDisposable {
  41070. private scene;
  41071. /**
  41072. * Fires every time a new xrFrame arrives which can be used to update the camera
  41073. */
  41074. onXRFrameObservable: Observable<any>;
  41075. /**
  41076. * Fires when the xr session is ended either by the device or manually done
  41077. */
  41078. onXRSessionEnded: Observable<any>;
  41079. /** @hidden */
  41080. _xrSession: XRSession;
  41081. /** @hidden */
  41082. _frameOfReference: XRFrameOfReference;
  41083. /** @hidden */
  41084. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41085. /** @hidden */
  41086. _currentXRFrame: Nullable<XRFrame>;
  41087. private _xrNavigator;
  41088. private _xrDevice;
  41089. private _tmpMatrix;
  41090. /**
  41091. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41092. * @param scene The scene which the session should be created for
  41093. */
  41094. constructor(scene: Scene);
  41095. /**
  41096. * Initializes the manager
  41097. * After initialization enterXR can be called to start an XR session
  41098. * @returns Promise which resolves after it is initialized
  41099. */
  41100. initializeAsync(): Promise<void>;
  41101. /**
  41102. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  41103. * @param sessionCreationOptions xr options to create the session with
  41104. * @param frameOfReferenceType option to configure how the xr pose is expressed
  41105. * @returns Promise which resolves after it enters XR
  41106. */
  41107. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  41108. /**
  41109. * Stops the xrSession and restores the renderloop
  41110. * @returns Promise which resolves after it exits XR
  41111. */
  41112. exitXRAsync(): Promise<void>;
  41113. /**
  41114. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41115. * @param ray ray to cast into the environment
  41116. * @returns Promise which resolves with a collision point in the environment if it exists
  41117. */
  41118. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41119. /**
  41120. * Checks if a session would be supported for the creation options specified
  41121. * @param options creation options to check if they are supported
  41122. * @returns true if supported
  41123. */
  41124. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41125. /**
  41126. * @hidden
  41127. * Converts the render layer of xrSession to a render target
  41128. * @param session session to create render target for
  41129. * @param scene scene the new render target should be created for
  41130. */
  41131. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  41132. /**
  41133. * Disposes of the session manager
  41134. */
  41135. dispose(): void;
  41136. }
  41137. }
  41138. declare module "babylonjs/Cameras/XR/webXRCamera" {
  41139. import { Scene } from "babylonjs/scene";
  41140. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41141. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41142. /**
  41143. * WebXR Camera which holds the views for the xrSession
  41144. * @see https://doc.babylonjs.com/how_to/webxr
  41145. */
  41146. export class WebXRCamera extends FreeCamera {
  41147. private static _TmpMatrix;
  41148. /**
  41149. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41150. * @param name the name of the camera
  41151. * @param scene the scene to add the camera to
  41152. */
  41153. constructor(name: string, scene: Scene);
  41154. private _updateNumberOfRigCameras;
  41155. /** @hidden */
  41156. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41157. /**
  41158. * Updates the cameras position from the current pose information of the XR session
  41159. * @param xrSessionManager the session containing pose information
  41160. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41161. */
  41162. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41163. }
  41164. }
  41165. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  41166. import { Nullable } from "babylonjs/types";
  41167. import { Observable } from "babylonjs/Misc/observable";
  41168. import { IDisposable, Scene } from "babylonjs/scene";
  41169. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  41170. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41171. import { Ray } from "babylonjs/Culling/ray";
  41172. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41173. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  41174. /**
  41175. * States of the webXR experience
  41176. */
  41177. export enum WebXRState {
  41178. /**
  41179. * Transitioning to being in XR mode
  41180. */
  41181. ENTERING_XR = 0,
  41182. /**
  41183. * Transitioning to non XR mode
  41184. */
  41185. EXITING_XR = 1,
  41186. /**
  41187. * In XR mode and presenting
  41188. */
  41189. IN_XR = 2,
  41190. /**
  41191. * Not entered XR mode
  41192. */
  41193. NOT_IN_XR = 3
  41194. }
  41195. /**
  41196. * Helper class used to enable XR
  41197. * @see https://doc.babylonjs.com/how_to/webxr
  41198. */
  41199. export class WebXRExperienceHelper implements IDisposable {
  41200. private scene;
  41201. /**
  41202. * 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
  41203. */
  41204. container: AbstractMesh;
  41205. /**
  41206. * Camera used to render xr content
  41207. */
  41208. camera: WebXRCamera;
  41209. /**
  41210. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41211. */
  41212. state: WebXRState;
  41213. private _setState;
  41214. private static _TmpVector;
  41215. /**
  41216. * Fires when the state of the experience helper has changed
  41217. */
  41218. onStateChangedObservable: Observable<WebXRState>;
  41219. /** @hidden */
  41220. _sessionManager: WebXRSessionManager;
  41221. private _nonVRCamera;
  41222. private _originalSceneAutoClear;
  41223. private _supported;
  41224. /**
  41225. * Creates the experience helper
  41226. * @param scene the scene to attach the experience helper to
  41227. * @returns a promise for the experience helper
  41228. */
  41229. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41230. /**
  41231. * Creates a WebXRExperienceHelper
  41232. * @param scene The scene the helper should be created in
  41233. */
  41234. private constructor();
  41235. /**
  41236. * Exits XR mode and returns the scene to its original state
  41237. * @returns promise that resolves after xr mode has exited
  41238. */
  41239. exitXRAsync(): Promise<void>;
  41240. /**
  41241. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41242. * @param sessionCreationOptions options for the XR session
  41243. * @param frameOfReference frame of reference of the XR session
  41244. * @returns promise that resolves after xr mode has entered
  41245. */
  41246. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  41247. /**
  41248. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41249. * @param ray ray to cast into the environment
  41250. * @returns Promise which resolves with a collision point in the environment if it exists
  41251. */
  41252. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41253. /**
  41254. * Updates the global position of the camera by moving the camera's container
  41255. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41256. * @param position The desired global position of the camera
  41257. */
  41258. setPositionOfCameraUsingContainer(position: Vector3): void;
  41259. /**
  41260. * Rotates the xr camera by rotating the camera's container around the camera's position
  41261. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41262. * @param rotation the desired quaternion rotation to apply to the camera
  41263. */
  41264. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41265. /**
  41266. * Checks if the creation options are supported by the xr session
  41267. * @param options creation options
  41268. * @returns true if supported
  41269. */
  41270. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41271. /**
  41272. * Disposes of the experience helper
  41273. */
  41274. dispose(): void;
  41275. }
  41276. }
  41277. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  41278. import { Nullable } from "babylonjs/types";
  41279. import { Observable } from "babylonjs/Misc/observable";
  41280. import { IDisposable, Scene } from "babylonjs/scene";
  41281. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41282. /**
  41283. * Button which can be used to enter a different mode of XR
  41284. */
  41285. export class WebXREnterExitUIButton {
  41286. /** button element */
  41287. element: HTMLElement;
  41288. /** XR initialization options for the button */
  41289. initializationOptions: XRSessionCreationOptions;
  41290. /**
  41291. * Creates a WebXREnterExitUIButton
  41292. * @param element button element
  41293. * @param initializationOptions XR initialization options for the button
  41294. */
  41295. constructor(
  41296. /** button element */
  41297. element: HTMLElement,
  41298. /** XR initialization options for the button */
  41299. initializationOptions: XRSessionCreationOptions);
  41300. /**
  41301. * Overwritable function which can be used to update the button's visuals when the state changes
  41302. * @param activeButton the current active button in the UI
  41303. */
  41304. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41305. }
  41306. /**
  41307. * Options to create the webXR UI
  41308. */
  41309. export class WebXREnterExitUIOptions {
  41310. /**
  41311. * Context to enter xr with
  41312. */
  41313. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  41314. /**
  41315. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41316. */
  41317. customButtons?: Array<WebXREnterExitUIButton>;
  41318. }
  41319. /**
  41320. * UI to allow the user to enter/exit XR mode
  41321. */
  41322. export class WebXREnterExitUI implements IDisposable {
  41323. private scene;
  41324. private _overlay;
  41325. private _buttons;
  41326. private _activeButton;
  41327. /**
  41328. * Fired every time the active button is changed.
  41329. *
  41330. * When xr is entered via a button that launches xr that button will be the callback parameter
  41331. *
  41332. * When exiting xr the callback parameter will be null)
  41333. */
  41334. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41335. /**
  41336. * Creates UI to allow the user to enter/exit XR mode
  41337. * @param scene the scene to add the ui to
  41338. * @param helper the xr experience helper to enter/exit xr with
  41339. * @param options options to configure the UI
  41340. * @returns the created ui
  41341. */
  41342. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41343. private constructor();
  41344. private _updateButtons;
  41345. /**
  41346. * Disposes of the object
  41347. */
  41348. dispose(): void;
  41349. }
  41350. }
  41351. declare module "babylonjs/Cameras/XR/webXRInput" {
  41352. import { IDisposable, Scene } from "babylonjs/scene";
  41353. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41354. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41355. /**
  41356. * Represents an XR input
  41357. */
  41358. export class WebXRController {
  41359. /**
  41360. * 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
  41361. */
  41362. grip?: AbstractMesh;
  41363. /**
  41364. * Pointer which can be used to select objects or attach a visible laser to
  41365. */
  41366. pointer: AbstractMesh;
  41367. /**
  41368. * Creates the controller
  41369. * @see https://doc.babylonjs.com/how_to/webxr
  41370. * @param scene the scene which the controller should be associated to
  41371. */
  41372. constructor(scene: Scene);
  41373. /**
  41374. * Disposes of the object
  41375. */
  41376. dispose(): void;
  41377. }
  41378. /**
  41379. * XR input used to track XR inputs such as controllers/rays
  41380. */
  41381. export class WebXRInput implements IDisposable {
  41382. private helper;
  41383. /**
  41384. * XR controllers being tracked
  41385. */
  41386. controllers: Array<WebXRController>;
  41387. private _tmpMatrix;
  41388. private _frameObserver;
  41389. /**
  41390. * Initializes the WebXRInput
  41391. * @param helper experience helper which the input should be created for
  41392. */
  41393. constructor(helper: WebXRExperienceHelper);
  41394. /**
  41395. * Disposes of the object
  41396. */
  41397. dispose(): void;
  41398. }
  41399. }
  41400. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  41401. import { Nullable } from "babylonjs/types";
  41402. import { IDisposable } from "babylonjs/scene";
  41403. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41404. /**
  41405. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41406. */
  41407. export class WebXRManagedOutputCanvas implements IDisposable {
  41408. private _canvas;
  41409. /**
  41410. * xrpresent context of the canvas which can be used to display/mirror xr content
  41411. */
  41412. canvasContext: Nullable<WebGLRenderingContext>;
  41413. /**
  41414. * Initializes the canvas to be added/removed upon entering/exiting xr
  41415. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41416. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41417. */
  41418. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41419. /**
  41420. * Disposes of the object
  41421. */
  41422. dispose(): void;
  41423. private _setManagedOutputCanvas;
  41424. private _addCanvas;
  41425. private _removeCanvas;
  41426. }
  41427. }
  41428. declare module "babylonjs/Cameras/XR/index" {
  41429. export * from "babylonjs/Cameras/XR/webXRCamera";
  41430. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  41431. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41432. export * from "babylonjs/Cameras/XR/webXRInput";
  41433. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  41434. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  41435. }
  41436. declare module "babylonjs/Cameras/RigModes/index" {
  41437. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41438. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41439. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  41440. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  41441. }
  41442. declare module "babylonjs/Cameras/index" {
  41443. export * from "babylonjs/Cameras/Inputs/index";
  41444. export * from "babylonjs/Cameras/cameraInputsManager";
  41445. export * from "babylonjs/Cameras/camera";
  41446. export * from "babylonjs/Cameras/targetCamera";
  41447. export * from "babylonjs/Cameras/freeCamera";
  41448. export * from "babylonjs/Cameras/freeCameraInputsManager";
  41449. export * from "babylonjs/Cameras/touchCamera";
  41450. export * from "babylonjs/Cameras/arcRotateCamera";
  41451. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  41452. export * from "babylonjs/Cameras/deviceOrientationCamera";
  41453. export * from "babylonjs/Cameras/flyCamera";
  41454. export * from "babylonjs/Cameras/flyCameraInputsManager";
  41455. export * from "babylonjs/Cameras/followCamera";
  41456. export * from "babylonjs/Cameras/gamepadCamera";
  41457. export * from "babylonjs/Cameras/Stereoscopic/index";
  41458. export * from "babylonjs/Cameras/universalCamera";
  41459. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  41460. export * from "babylonjs/Cameras/VR/index";
  41461. export * from "babylonjs/Cameras/XR/index";
  41462. export * from "babylonjs/Cameras/RigModes/index";
  41463. }
  41464. declare module "babylonjs/Collisions/index" {
  41465. export * from "babylonjs/Collisions/collider";
  41466. export * from "babylonjs/Collisions/collisionCoordinator";
  41467. export * from "babylonjs/Collisions/pickingInfo";
  41468. export * from "babylonjs/Collisions/intersectionInfo";
  41469. }
  41470. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  41471. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  41472. import { Vector3, Plane } from "babylonjs/Maths/math";
  41473. import { Ray } from "babylonjs/Culling/ray";
  41474. /**
  41475. * Contains an array of blocks representing the octree
  41476. */
  41477. export interface IOctreeContainer<T> {
  41478. /**
  41479. * Blocks within the octree
  41480. */
  41481. blocks: Array<OctreeBlock<T>>;
  41482. }
  41483. /**
  41484. * Class used to store a cell in an octree
  41485. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41486. */
  41487. export class OctreeBlock<T> {
  41488. /**
  41489. * Gets the content of the current block
  41490. */
  41491. entries: T[];
  41492. /**
  41493. * Gets the list of block children
  41494. */
  41495. blocks: Array<OctreeBlock<T>>;
  41496. private _depth;
  41497. private _maxDepth;
  41498. private _capacity;
  41499. private _minPoint;
  41500. private _maxPoint;
  41501. private _boundingVectors;
  41502. private _creationFunc;
  41503. /**
  41504. * Creates a new block
  41505. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41506. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41507. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41508. * @param depth defines the current depth of this block in the octree
  41509. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41510. * @param creationFunc defines a callback to call when an element is added to the block
  41511. */
  41512. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41513. /**
  41514. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41515. */
  41516. readonly capacity: number;
  41517. /**
  41518. * Gets the minimum vector (in world space) of the block's bounding box
  41519. */
  41520. readonly minPoint: Vector3;
  41521. /**
  41522. * Gets the maximum vector (in world space) of the block's bounding box
  41523. */
  41524. readonly maxPoint: Vector3;
  41525. /**
  41526. * Add a new element to this block
  41527. * @param entry defines the element to add
  41528. */
  41529. addEntry(entry: T): void;
  41530. /**
  41531. * Remove an element from this block
  41532. * @param entry defines the element to remove
  41533. */
  41534. removeEntry(entry: T): void;
  41535. /**
  41536. * Add an array of elements to this block
  41537. * @param entries defines the array of elements to add
  41538. */
  41539. addEntries(entries: T[]): void;
  41540. /**
  41541. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41542. * @param frustumPlanes defines the frustum planes to test
  41543. * @param selection defines the array to store current content if selection is positive
  41544. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41545. */
  41546. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41547. /**
  41548. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41549. * @param sphereCenter defines the bounding sphere center
  41550. * @param sphereRadius defines the bounding sphere radius
  41551. * @param selection defines the array to store current content if selection is positive
  41552. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41553. */
  41554. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41555. /**
  41556. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41557. * @param ray defines the ray to test with
  41558. * @param selection defines the array to store current content if selection is positive
  41559. */
  41560. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41561. /**
  41562. * Subdivide the content into child blocks (this block will then be empty)
  41563. */
  41564. createInnerBlocks(): void;
  41565. /**
  41566. * @hidden
  41567. */
  41568. 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;
  41569. }
  41570. }
  41571. declare module "babylonjs/Culling/Octrees/octree" {
  41572. import { SmartArray } from "babylonjs/Misc/smartArray";
  41573. import { Vector3, Plane } from "babylonjs/Maths/math";
  41574. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41575. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41576. import { Ray } from "babylonjs/Culling/ray";
  41577. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  41578. /**
  41579. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41580. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41581. */
  41582. export class Octree<T> {
  41583. /** 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.) */
  41584. maxDepth: number;
  41585. /**
  41586. * Blocks within the octree containing objects
  41587. */
  41588. blocks: Array<OctreeBlock<T>>;
  41589. /**
  41590. * Content stored in the octree
  41591. */
  41592. dynamicContent: T[];
  41593. private _maxBlockCapacity;
  41594. private _selectionContent;
  41595. private _creationFunc;
  41596. /**
  41597. * Creates a octree
  41598. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41599. * @param creationFunc function to be used to instatiate the octree
  41600. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41601. * @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.)
  41602. */
  41603. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41604. /** 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.) */
  41605. maxDepth?: number);
  41606. /**
  41607. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41608. * @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);
  41609. * @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);
  41610. * @param entries meshes to be added to the octree blocks
  41611. */
  41612. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41613. /**
  41614. * Adds a mesh to the octree
  41615. * @param entry Mesh to add to the octree
  41616. */
  41617. addMesh(entry: T): void;
  41618. /**
  41619. * Remove an element from the octree
  41620. * @param entry defines the element to remove
  41621. */
  41622. removeMesh(entry: T): void;
  41623. /**
  41624. * Selects an array of meshes within the frustum
  41625. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41626. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41627. * @returns array of meshes within the frustum
  41628. */
  41629. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41630. /**
  41631. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41632. * @param sphereCenter defines the bounding sphere center
  41633. * @param sphereRadius defines the bounding sphere radius
  41634. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41635. * @returns an array of objects that intersect the sphere
  41636. */
  41637. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41638. /**
  41639. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41640. * @param ray defines the ray to test with
  41641. * @returns array of intersected objects
  41642. */
  41643. intersectsRay(ray: Ray): SmartArray<T>;
  41644. /**
  41645. * Adds a mesh into the octree block if it intersects the block
  41646. */
  41647. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41648. /**
  41649. * Adds a submesh into the octree block if it intersects the block
  41650. */
  41651. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41652. }
  41653. }
  41654. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  41655. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  41656. import { Scene } from "babylonjs/scene";
  41657. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41658. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41659. import { Ray } from "babylonjs/Culling/ray";
  41660. import { Octree } from "babylonjs/Culling/Octrees/octree";
  41661. import { Collider } from "babylonjs/Collisions/collider";
  41662. module "babylonjs/scene" {
  41663. interface Scene {
  41664. /**
  41665. * @hidden
  41666. * Backing Filed
  41667. */
  41668. _selectionOctree: Octree<AbstractMesh>;
  41669. /**
  41670. * Gets the octree used to boost mesh selection (picking)
  41671. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41672. */
  41673. selectionOctree: Octree<AbstractMesh>;
  41674. /**
  41675. * Creates or updates the octree used to boost selection (picking)
  41676. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41677. * @param maxCapacity defines the maximum capacity per leaf
  41678. * @param maxDepth defines the maximum depth of the octree
  41679. * @returns an octree of AbstractMesh
  41680. */
  41681. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41682. }
  41683. }
  41684. module "babylonjs/Meshes/abstractMesh" {
  41685. interface AbstractMesh {
  41686. /**
  41687. * @hidden
  41688. * Backing Field
  41689. */
  41690. _submeshesOctree: Octree<SubMesh>;
  41691. /**
  41692. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41693. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41694. * @param maxCapacity defines the maximum size of each block (64 by default)
  41695. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41696. * @returns the new octree
  41697. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41698. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41699. */
  41700. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41701. }
  41702. }
  41703. /**
  41704. * Defines the octree scene component responsible to manage any octrees
  41705. * in a given scene.
  41706. */
  41707. export class OctreeSceneComponent {
  41708. /**
  41709. * The component name helpfull to identify the component in the list of scene components.
  41710. */
  41711. readonly name: string;
  41712. /**
  41713. * The scene the component belongs to.
  41714. */
  41715. scene: Scene;
  41716. /**
  41717. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41718. */
  41719. readonly checksIsEnabled: boolean;
  41720. /**
  41721. * Creates a new instance of the component for the given scene
  41722. * @param scene Defines the scene to register the component in
  41723. */
  41724. constructor(scene: Scene);
  41725. /**
  41726. * Registers the component in a given scene
  41727. */
  41728. register(): void;
  41729. /**
  41730. * Return the list of active meshes
  41731. * @returns the list of active meshes
  41732. */
  41733. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41734. /**
  41735. * Return the list of active sub meshes
  41736. * @param mesh The mesh to get the candidates sub meshes from
  41737. * @returns the list of active sub meshes
  41738. */
  41739. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41740. private _tempRay;
  41741. /**
  41742. * Return the list of sub meshes intersecting with a given local ray
  41743. * @param mesh defines the mesh to find the submesh for
  41744. * @param localRay defines the ray in local space
  41745. * @returns the list of intersecting sub meshes
  41746. */
  41747. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41748. /**
  41749. * Return the list of sub meshes colliding with a collider
  41750. * @param mesh defines the mesh to find the submesh for
  41751. * @param collider defines the collider to evaluate the collision against
  41752. * @returns the list of colliding sub meshes
  41753. */
  41754. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41755. /**
  41756. * Rebuilds the elements related to this component in case of
  41757. * context lost for instance.
  41758. */
  41759. rebuild(): void;
  41760. /**
  41761. * Disposes the component and the associated ressources.
  41762. */
  41763. dispose(): void;
  41764. }
  41765. }
  41766. declare module "babylonjs/Culling/Octrees/index" {
  41767. export * from "babylonjs/Culling/Octrees/octree";
  41768. export * from "babylonjs/Culling/Octrees/octreeBlock";
  41769. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  41770. }
  41771. declare module "babylonjs/Culling/index" {
  41772. export * from "babylonjs/Culling/boundingBox";
  41773. export * from "babylonjs/Culling/boundingInfo";
  41774. export * from "babylonjs/Culling/boundingSphere";
  41775. export * from "babylonjs/Culling/Octrees/index";
  41776. export * from "babylonjs/Culling/ray";
  41777. }
  41778. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  41779. import { IDisposable, Scene } from "babylonjs/scene";
  41780. import { Nullable } from "babylonjs/types";
  41781. import { Observable } from "babylonjs/Misc/observable";
  41782. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41783. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  41784. /**
  41785. * Renders a layer on top of an existing scene
  41786. */
  41787. export class UtilityLayerRenderer implements IDisposable {
  41788. /** the original scene that will be rendered on top of */
  41789. originalScene: Scene;
  41790. private _pointerCaptures;
  41791. private _lastPointerEvents;
  41792. private static _DefaultUtilityLayer;
  41793. private static _DefaultKeepDepthUtilityLayer;
  41794. private _sharedGizmoLight;
  41795. /**
  41796. * @hidden
  41797. * Light which used by gizmos to get light shading
  41798. */
  41799. _getSharedGizmoLight(): HemisphericLight;
  41800. /**
  41801. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41802. */
  41803. pickUtilitySceneFirst: boolean;
  41804. /**
  41805. * 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)
  41806. */
  41807. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41808. /**
  41809. * 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)
  41810. */
  41811. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41812. /**
  41813. * The scene that is rendered on top of the original scene
  41814. */
  41815. utilityLayerScene: Scene;
  41816. /**
  41817. * If the utility layer should automatically be rendered on top of existing scene
  41818. */
  41819. shouldRender: boolean;
  41820. /**
  41821. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41822. */
  41823. onlyCheckPointerDownEvents: boolean;
  41824. /**
  41825. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41826. */
  41827. processAllEvents: boolean;
  41828. /**
  41829. * Observable raised when the pointer move from the utility layer scene to the main scene
  41830. */
  41831. onPointerOutObservable: Observable<number>;
  41832. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41833. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41834. private _afterRenderObserver;
  41835. private _sceneDisposeObserver;
  41836. private _originalPointerObserver;
  41837. /**
  41838. * Instantiates a UtilityLayerRenderer
  41839. * @param originalScene the original scene that will be rendered on top of
  41840. * @param handleEvents boolean indicating if the utility layer should handle events
  41841. */
  41842. constructor(
  41843. /** the original scene that will be rendered on top of */
  41844. originalScene: Scene, handleEvents?: boolean);
  41845. private _notifyObservers;
  41846. /**
  41847. * Renders the utility layers scene on top of the original scene
  41848. */
  41849. render(): void;
  41850. /**
  41851. * Disposes of the renderer
  41852. */
  41853. dispose(): void;
  41854. private _updateCamera;
  41855. }
  41856. }
  41857. declare module "babylonjs/Gizmos/gizmo" {
  41858. import { Nullable } from "babylonjs/types";
  41859. import { IDisposable } from "babylonjs/scene";
  41860. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41861. import { Mesh } from "babylonjs/Meshes/mesh";
  41862. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41863. /**
  41864. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  41865. */
  41866. export class Gizmo implements IDisposable {
  41867. /** The utility layer the gizmo will be added to */
  41868. gizmoLayer: UtilityLayerRenderer;
  41869. /**
  41870. * The root mesh of the gizmo
  41871. */
  41872. _rootMesh: Mesh;
  41873. private _attachedMesh;
  41874. /**
  41875. * Ratio for the scale of the gizmo (Default: 1)
  41876. */
  41877. scaleRatio: number;
  41878. private _tmpMatrix;
  41879. /**
  41880. * If a custom mesh has been set (Default: false)
  41881. */
  41882. protected _customMeshSet: boolean;
  41883. /**
  41884. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41885. * * When set, interactions will be enabled
  41886. */
  41887. attachedMesh: Nullable<AbstractMesh>;
  41888. /**
  41889. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41890. * @param mesh The mesh to replace the default mesh of the gizmo
  41891. */
  41892. setCustomMesh(mesh: Mesh): void;
  41893. /**
  41894. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41895. */
  41896. updateGizmoRotationToMatchAttachedMesh: boolean;
  41897. /**
  41898. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41899. */
  41900. updateGizmoPositionToMatchAttachedMesh: boolean;
  41901. /**
  41902. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  41903. */
  41904. protected _updateScale: boolean;
  41905. protected _interactionsEnabled: boolean;
  41906. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41907. private _beforeRenderObserver;
  41908. /**
  41909. * Creates a gizmo
  41910. * @param gizmoLayer The utility layer the gizmo will be added to
  41911. */
  41912. constructor(
  41913. /** The utility layer the gizmo will be added to */
  41914. gizmoLayer?: UtilityLayerRenderer);
  41915. private _tempVector;
  41916. /**
  41917. * @hidden
  41918. * Updates the gizmo to match the attached mesh's position/rotation
  41919. */
  41920. protected _update(): void;
  41921. /**
  41922. * Disposes of the gizmo
  41923. */
  41924. dispose(): void;
  41925. }
  41926. }
  41927. declare module "babylonjs/Gizmos/axisDragGizmo" {
  41928. import { Observable } from "babylonjs/Misc/observable";
  41929. import { Nullable } from "babylonjs/types";
  41930. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41931. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41932. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41933. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  41934. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  41935. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41936. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  41937. import { Scene } from "babylonjs/scene";
  41938. /**
  41939. * Single axis drag gizmo
  41940. */
  41941. export class AxisDragGizmo extends Gizmo {
  41942. /**
  41943. * Drag behavior responsible for the gizmos dragging interactions
  41944. */
  41945. dragBehavior: PointerDragBehavior;
  41946. private _pointerObserver;
  41947. /**
  41948. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41949. */
  41950. snapDistance: number;
  41951. /**
  41952. * Event that fires each time the gizmo snaps to a new location.
  41953. * * snapDistance is the the change in distance
  41954. */
  41955. onSnapObservable: Observable<{
  41956. snapDistance: number;
  41957. }>;
  41958. /** @hidden */
  41959. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  41960. /** @hidden */
  41961. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41962. /**
  41963. * Creates an AxisDragGizmo
  41964. * @param gizmoLayer The utility layer the gizmo will be added to
  41965. * @param dragAxis The axis which the gizmo will be able to drag on
  41966. * @param color The color of the gizmo
  41967. */
  41968. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41969. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41970. /**
  41971. * Disposes of the gizmo
  41972. */
  41973. dispose(): void;
  41974. }
  41975. }
  41976. declare module "babylonjs/Debug/axesViewer" {
  41977. import { Vector3 } from "babylonjs/Maths/math";
  41978. import { Nullable } from "babylonjs/types";
  41979. import { Scene } from "babylonjs/scene";
  41980. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41981. /**
  41982. * The Axes viewer will show 3 axes in a specific point in space
  41983. */
  41984. export class AxesViewer {
  41985. private _xAxis;
  41986. private _yAxis;
  41987. private _zAxis;
  41988. private _scaleLinesFactor;
  41989. private _instanced;
  41990. /**
  41991. * Gets the hosting scene
  41992. */
  41993. scene: Scene;
  41994. /**
  41995. * Gets or sets a number used to scale line length
  41996. */
  41997. scaleLines: number;
  41998. /** Gets the node hierarchy used to render x-axis */
  41999. readonly xAxis: TransformNode;
  42000. /** Gets the node hierarchy used to render y-axis */
  42001. readonly yAxis: TransformNode;
  42002. /** Gets the node hierarchy used to render z-axis */
  42003. readonly zAxis: TransformNode;
  42004. /**
  42005. * Creates a new AxesViewer
  42006. * @param scene defines the hosting scene
  42007. * @param scaleLines defines a number used to scale line length (1 by default)
  42008. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42009. * @param xAxis defines the node hierarchy used to render the x-axis
  42010. * @param yAxis defines the node hierarchy used to render the y-axis
  42011. * @param zAxis defines the node hierarchy used to render the z-axis
  42012. */
  42013. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42014. /**
  42015. * Force the viewer to update
  42016. * @param position defines the position of the viewer
  42017. * @param xaxis defines the x axis of the viewer
  42018. * @param yaxis defines the y axis of the viewer
  42019. * @param zaxis defines the z axis of the viewer
  42020. */
  42021. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42022. /**
  42023. * Creates an instance of this axes viewer.
  42024. * @returns a new axes viewer with instanced meshes
  42025. */
  42026. createInstance(): AxesViewer;
  42027. /** Releases resources */
  42028. dispose(): void;
  42029. private static _SetRenderingGroupId;
  42030. }
  42031. }
  42032. declare module "babylonjs/Debug/boneAxesViewer" {
  42033. import { Nullable } from "babylonjs/types";
  42034. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  42035. import { Vector3 } from "babylonjs/Maths/math";
  42036. import { Mesh } from "babylonjs/Meshes/mesh";
  42037. import { Bone } from "babylonjs/Bones/bone";
  42038. import { Scene } from "babylonjs/scene";
  42039. /**
  42040. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42041. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42042. */
  42043. export class BoneAxesViewer extends AxesViewer {
  42044. /**
  42045. * Gets or sets the target mesh where to display the axes viewer
  42046. */
  42047. mesh: Nullable<Mesh>;
  42048. /**
  42049. * Gets or sets the target bone where to display the axes viewer
  42050. */
  42051. bone: Nullable<Bone>;
  42052. /** Gets current position */
  42053. pos: Vector3;
  42054. /** Gets direction of X axis */
  42055. xaxis: Vector3;
  42056. /** Gets direction of Y axis */
  42057. yaxis: Vector3;
  42058. /** Gets direction of Z axis */
  42059. zaxis: Vector3;
  42060. /**
  42061. * Creates a new BoneAxesViewer
  42062. * @param scene defines the hosting scene
  42063. * @param bone defines the target bone
  42064. * @param mesh defines the target mesh
  42065. * @param scaleLines defines a scaling factor for line length (1 by default)
  42066. */
  42067. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42068. /**
  42069. * Force the viewer to update
  42070. */
  42071. update(): void;
  42072. /** Releases resources */
  42073. dispose(): void;
  42074. }
  42075. }
  42076. declare module "babylonjs/Debug/debugLayer" {
  42077. import { Observable } from "babylonjs/Misc/observable";
  42078. import { Scene } from "babylonjs/scene";
  42079. /**
  42080. * Interface used to define scene explorer extensibility option
  42081. */
  42082. export interface IExplorerExtensibilityOption {
  42083. /**
  42084. * Define the option label
  42085. */
  42086. label: string;
  42087. /**
  42088. * Defines the action to execute on click
  42089. */
  42090. action: (entity: any) => void;
  42091. }
  42092. /**
  42093. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42094. */
  42095. export interface IExplorerExtensibilityGroup {
  42096. /**
  42097. * Defines a predicate to test if a given type mut be extended
  42098. */
  42099. predicate: (entity: any) => boolean;
  42100. /**
  42101. * Gets the list of options added to a type
  42102. */
  42103. entries: IExplorerExtensibilityOption[];
  42104. }
  42105. /**
  42106. * Interface used to define the options to use to create the Inspector
  42107. */
  42108. export interface IInspectorOptions {
  42109. /**
  42110. * Display in overlay mode (default: false)
  42111. */
  42112. overlay?: boolean;
  42113. /**
  42114. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42115. */
  42116. globalRoot?: HTMLElement;
  42117. /**
  42118. * Display the Scene explorer
  42119. */
  42120. showExplorer?: boolean;
  42121. /**
  42122. * Display the property inspector
  42123. */
  42124. showInspector?: boolean;
  42125. /**
  42126. * Display in embed mode (both panes on the right)
  42127. */
  42128. embedMode?: boolean;
  42129. /**
  42130. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42131. */
  42132. handleResize?: boolean;
  42133. /**
  42134. * Allow the panes to popup (default: true)
  42135. */
  42136. enablePopup?: boolean;
  42137. /**
  42138. * Allow the panes to be closed by users (default: true)
  42139. */
  42140. enableClose?: boolean;
  42141. /**
  42142. * Optional list of extensibility entries
  42143. */
  42144. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42145. /**
  42146. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42147. */
  42148. inspectorURL?: string;
  42149. }
  42150. module "babylonjs/scene" {
  42151. interface Scene {
  42152. /**
  42153. * @hidden
  42154. * Backing field
  42155. */
  42156. _debugLayer: DebugLayer;
  42157. /**
  42158. * Gets the debug layer (aka Inspector) associated with the scene
  42159. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42160. */
  42161. debugLayer: DebugLayer;
  42162. }
  42163. }
  42164. /**
  42165. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42166. * what is happening in your scene
  42167. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42168. */
  42169. export class DebugLayer {
  42170. /**
  42171. * Define the url to get the inspector script from.
  42172. * By default it uses the babylonjs CDN.
  42173. * @ignoreNaming
  42174. */
  42175. static InspectorURL: string;
  42176. private _scene;
  42177. private BJSINSPECTOR;
  42178. /**
  42179. * Observable triggered when a property is changed through the inspector.
  42180. */
  42181. onPropertyChangedObservable: Observable<{
  42182. object: any;
  42183. property: string;
  42184. value: any;
  42185. initialValue: any;
  42186. }>;
  42187. /**
  42188. * Instantiates a new debug layer.
  42189. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42190. * what is happening in your scene
  42191. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42192. * @param scene Defines the scene to inspect
  42193. */
  42194. constructor(scene: Scene);
  42195. /** Creates the inspector window. */
  42196. private _createInspector;
  42197. /**
  42198. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42199. * @param entity defines the entity to select
  42200. * @param lineContainerTitle defines the specific block to highlight
  42201. */
  42202. select(entity: any, lineContainerTitle?: string): void;
  42203. /** Get the inspector from bundle or global */
  42204. private _getGlobalInspector;
  42205. /**
  42206. * Get if the inspector is visible or not.
  42207. * @returns true if visible otherwise, false
  42208. */
  42209. isVisible(): boolean;
  42210. /**
  42211. * Hide the inspector and close its window.
  42212. */
  42213. hide(): void;
  42214. /**
  42215. * Launch the debugLayer.
  42216. * @param config Define the configuration of the inspector
  42217. * @return a promise fulfilled when the debug layer is visible
  42218. */
  42219. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42220. }
  42221. }
  42222. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  42223. import { Nullable } from "babylonjs/types";
  42224. import { Scene } from "babylonjs/scene";
  42225. import { Vector4, Color4 } from "babylonjs/Maths/math";
  42226. import { Mesh } from "babylonjs/Meshes/mesh";
  42227. /**
  42228. * Class containing static functions to help procedurally build meshes
  42229. */
  42230. export class BoxBuilder {
  42231. /**
  42232. * Creates a box mesh
  42233. * * The parameter `size` sets the size (float) of each box side (default 1)
  42234. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42235. * * 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)
  42236. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42237. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42238. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42239. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42240. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42241. * @param name defines the name of the mesh
  42242. * @param options defines the options used to create the mesh
  42243. * @param scene defines the hosting scene
  42244. * @returns the box mesh
  42245. */
  42246. static CreateBox(name: string, options: {
  42247. size?: number;
  42248. width?: number;
  42249. height?: number;
  42250. depth?: number;
  42251. faceUV?: Vector4[];
  42252. faceColors?: Color4[];
  42253. sideOrientation?: number;
  42254. frontUVs?: Vector4;
  42255. backUVs?: Vector4;
  42256. updatable?: boolean;
  42257. }, scene?: Nullable<Scene>): Mesh;
  42258. }
  42259. }
  42260. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  42261. import { Vector4 } from "babylonjs/Maths/math";
  42262. import { Mesh } from "babylonjs/Meshes/mesh";
  42263. /**
  42264. * Class containing static functions to help procedurally build meshes
  42265. */
  42266. export class SphereBuilder {
  42267. /**
  42268. * Creates a sphere mesh
  42269. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42270. * * 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`)
  42271. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42272. * * 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
  42273. * * 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)
  42274. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42275. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42276. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42277. * @param name defines the name of the mesh
  42278. * @param options defines the options used to create the mesh
  42279. * @param scene defines the hosting scene
  42280. * @returns the sphere mesh
  42281. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42282. */
  42283. static CreateSphere(name: string, options: {
  42284. segments?: number;
  42285. diameter?: number;
  42286. diameterX?: number;
  42287. diameterY?: number;
  42288. diameterZ?: number;
  42289. arc?: number;
  42290. slice?: number;
  42291. sideOrientation?: number;
  42292. frontUVs?: Vector4;
  42293. backUVs?: Vector4;
  42294. updatable?: boolean;
  42295. }, scene: any): Mesh;
  42296. }
  42297. }
  42298. declare module "babylonjs/Debug/physicsViewer" {
  42299. import { Nullable } from "babylonjs/types";
  42300. import { Scene } from "babylonjs/scene";
  42301. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42302. import { Mesh } from "babylonjs/Meshes/mesh";
  42303. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  42304. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  42305. /**
  42306. * Used to show the physics impostor around the specific mesh
  42307. */
  42308. export class PhysicsViewer {
  42309. /** @hidden */
  42310. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42311. /** @hidden */
  42312. protected _meshes: Array<Nullable<AbstractMesh>>;
  42313. /** @hidden */
  42314. protected _scene: Nullable<Scene>;
  42315. /** @hidden */
  42316. protected _numMeshes: number;
  42317. /** @hidden */
  42318. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42319. private _renderFunction;
  42320. private _utilityLayer;
  42321. private _debugBoxMesh;
  42322. private _debugSphereMesh;
  42323. private _debugCylinderMesh;
  42324. private _debugMaterial;
  42325. private _debugMeshMeshes;
  42326. /**
  42327. * Creates a new PhysicsViewer
  42328. * @param scene defines the hosting scene
  42329. */
  42330. constructor(scene: Scene);
  42331. /** @hidden */
  42332. protected _updateDebugMeshes(): void;
  42333. /**
  42334. * Renders a specified physic impostor
  42335. * @param impostor defines the impostor to render
  42336. * @param targetMesh defines the mesh represented by the impostor
  42337. * @returns the new debug mesh used to render the impostor
  42338. */
  42339. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  42340. /**
  42341. * Hides a specified physic impostor
  42342. * @param impostor defines the impostor to hide
  42343. */
  42344. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  42345. private _getDebugMaterial;
  42346. private _getDebugBoxMesh;
  42347. private _getDebugSphereMesh;
  42348. private _getDebugCylinderMesh;
  42349. private _getDebugMeshMesh;
  42350. private _getDebugMesh;
  42351. /** Releases all resources */
  42352. dispose(): void;
  42353. }
  42354. }
  42355. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  42356. import { Vector3, Color4 } from "babylonjs/Maths/math";
  42357. import { Nullable } from "babylonjs/types";
  42358. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42359. import { Scene } from "babylonjs/scene";
  42360. /**
  42361. * Class containing static functions to help procedurally build meshes
  42362. */
  42363. export class LinesBuilder {
  42364. /**
  42365. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  42366. * * 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
  42367. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  42368. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  42369. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  42370. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  42371. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  42372. * * 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
  42373. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  42374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42375. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  42376. * @param name defines the name of the new line system
  42377. * @param options defines the options used to create the line system
  42378. * @param scene defines the hosting scene
  42379. * @returns a new line system mesh
  42380. */
  42381. static CreateLineSystem(name: string, options: {
  42382. lines: Vector3[][];
  42383. updatable?: boolean;
  42384. instance?: Nullable<LinesMesh>;
  42385. colors?: Nullable<Color4[][]>;
  42386. useVertexAlpha?: boolean;
  42387. }, scene: Nullable<Scene>): LinesMesh;
  42388. /**
  42389. * Creates a line mesh
  42390. * 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
  42391. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42392. * * The parameter `points` is an array successive Vector3
  42393. * * 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
  42394. * * The optional parameter `colors` is an array of successive Color4, one per line point
  42395. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  42396. * * When updating an instance, remember that only point positions can change, not the number of points
  42397. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42398. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  42399. * @param name defines the name of the new line system
  42400. * @param options defines the options used to create the line system
  42401. * @param scene defines the hosting scene
  42402. * @returns a new line mesh
  42403. */
  42404. static CreateLines(name: string, options: {
  42405. points: Vector3[];
  42406. updatable?: boolean;
  42407. instance?: Nullable<LinesMesh>;
  42408. colors?: Color4[];
  42409. useVertexAlpha?: boolean;
  42410. }, scene?: Nullable<Scene>): LinesMesh;
  42411. /**
  42412. * Creates a dashed line mesh
  42413. * * 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
  42414. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42415. * * The parameter `points` is an array successive Vector3
  42416. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  42417. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  42418. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  42419. * * 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
  42420. * * When updating an instance, remember that only point positions can change, not the number of points
  42421. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42422. * @param name defines the name of the mesh
  42423. * @param options defines the options used to create the mesh
  42424. * @param scene defines the hosting scene
  42425. * @returns the dashed line mesh
  42426. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  42427. */
  42428. static CreateDashedLines(name: string, options: {
  42429. points: Vector3[];
  42430. dashSize?: number;
  42431. gapSize?: number;
  42432. dashNb?: number;
  42433. updatable?: boolean;
  42434. instance?: LinesMesh;
  42435. }, scene?: Nullable<Scene>): LinesMesh;
  42436. }
  42437. }
  42438. declare module "babylonjs/Debug/rayHelper" {
  42439. import { Nullable } from "babylonjs/types";
  42440. import { Ray } from "babylonjs/Culling/ray";
  42441. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42442. import { Scene } from "babylonjs/scene";
  42443. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42444. import "babylonjs/Meshes/Builders/linesBuilder";
  42445. /**
  42446. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42447. * in order to better appreciate the issue one might have.
  42448. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42449. */
  42450. export class RayHelper {
  42451. /**
  42452. * Defines the ray we are currently tryin to visualize.
  42453. */
  42454. ray: Nullable<Ray>;
  42455. private _renderPoints;
  42456. private _renderLine;
  42457. private _renderFunction;
  42458. private _scene;
  42459. private _updateToMeshFunction;
  42460. private _attachedToMesh;
  42461. private _meshSpaceDirection;
  42462. private _meshSpaceOrigin;
  42463. /**
  42464. * Helper function to create a colored helper in a scene in one line.
  42465. * @param ray Defines the ray we are currently tryin to visualize
  42466. * @param scene Defines the scene the ray is used in
  42467. * @param color Defines the color we want to see the ray in
  42468. * @returns The newly created ray helper.
  42469. */
  42470. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  42471. /**
  42472. * Instantiate a new ray helper.
  42473. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42474. * in order to better appreciate the issue one might have.
  42475. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42476. * @param ray Defines the ray we are currently tryin to visualize
  42477. */
  42478. constructor(ray: Ray);
  42479. /**
  42480. * Shows the ray we are willing to debug.
  42481. * @param scene Defines the scene the ray needs to be rendered in
  42482. * @param color Defines the color the ray needs to be rendered in
  42483. */
  42484. show(scene: Scene, color?: Color3): void;
  42485. /**
  42486. * Hides the ray we are debugging.
  42487. */
  42488. hide(): void;
  42489. private _render;
  42490. /**
  42491. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  42492. * @param mesh Defines the mesh we want the helper attached to
  42493. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  42494. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  42495. * @param length Defines the length of the ray
  42496. */
  42497. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  42498. /**
  42499. * Detach the ray helper from the mesh it has previously been attached to.
  42500. */
  42501. detachFromMesh(): void;
  42502. private _updateToMesh;
  42503. /**
  42504. * Dispose the helper and release its associated resources.
  42505. */
  42506. dispose(): void;
  42507. }
  42508. }
  42509. declare module "babylonjs/Debug/skeletonViewer" {
  42510. import { Color3 } from "babylonjs/Maths/math";
  42511. import { Scene } from "babylonjs/scene";
  42512. import { Nullable } from "babylonjs/types";
  42513. import { Skeleton } from "babylonjs/Bones/skeleton";
  42514. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42515. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42516. /**
  42517. * Class used to render a debug view of a given skeleton
  42518. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  42519. */
  42520. export class SkeletonViewer {
  42521. /** defines the skeleton to render */
  42522. skeleton: Skeleton;
  42523. /** defines the mesh attached to the skeleton */
  42524. mesh: AbstractMesh;
  42525. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42526. autoUpdateBonesMatrices: boolean;
  42527. /** defines the rendering group id to use with the viewer */
  42528. renderingGroupId: number;
  42529. /** Gets or sets the color used to render the skeleton */
  42530. color: Color3;
  42531. private _scene;
  42532. private _debugLines;
  42533. private _debugMesh;
  42534. private _isEnabled;
  42535. private _renderFunction;
  42536. private _utilityLayer;
  42537. /**
  42538. * Returns the mesh used to render the bones
  42539. */
  42540. readonly debugMesh: Nullable<LinesMesh>;
  42541. /**
  42542. * Creates a new SkeletonViewer
  42543. * @param skeleton defines the skeleton to render
  42544. * @param mesh defines the mesh attached to the skeleton
  42545. * @param scene defines the hosting scene
  42546. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  42547. * @param renderingGroupId defines the rendering group id to use with the viewer
  42548. */
  42549. constructor(
  42550. /** defines the skeleton to render */
  42551. skeleton: Skeleton,
  42552. /** defines the mesh attached to the skeleton */
  42553. mesh: AbstractMesh, scene: Scene,
  42554. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42555. autoUpdateBonesMatrices?: boolean,
  42556. /** defines the rendering group id to use with the viewer */
  42557. renderingGroupId?: number);
  42558. /** Gets or sets a boolean indicating if the viewer is enabled */
  42559. isEnabled: boolean;
  42560. private _getBonePosition;
  42561. private _getLinesForBonesWithLength;
  42562. private _getLinesForBonesNoLength;
  42563. /** Update the viewer to sync with current skeleton state */
  42564. update(): void;
  42565. /** Release associated resources */
  42566. dispose(): void;
  42567. }
  42568. }
  42569. declare module "babylonjs/Debug/index" {
  42570. export * from "babylonjs/Debug/axesViewer";
  42571. export * from "babylonjs/Debug/boneAxesViewer";
  42572. export * from "babylonjs/Debug/debugLayer";
  42573. export * from "babylonjs/Debug/physicsViewer";
  42574. export * from "babylonjs/Debug/rayHelper";
  42575. export * from "babylonjs/Debug/skeletonViewer";
  42576. }
  42577. declare module "babylonjs/Engines/nullEngine" {
  42578. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  42579. import { Scene } from "babylonjs/scene";
  42580. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  42581. import { Engine } from "babylonjs/Engines/engine";
  42582. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  42583. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  42584. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  42585. import { Effect } from "babylonjs/Materials/effect";
  42586. /**
  42587. * Options to create the null engine
  42588. */
  42589. export class NullEngineOptions {
  42590. /**
  42591. * Render width (Default: 512)
  42592. */
  42593. renderWidth: number;
  42594. /**
  42595. * Render height (Default: 256)
  42596. */
  42597. renderHeight: number;
  42598. /**
  42599. * Texture size (Default: 512)
  42600. */
  42601. textureSize: number;
  42602. /**
  42603. * If delta time between frames should be constant
  42604. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42605. */
  42606. deterministicLockstep: boolean;
  42607. /**
  42608. * Maximum about of steps between frames (Default: 4)
  42609. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42610. */
  42611. lockstepMaxSteps: number;
  42612. }
  42613. /**
  42614. * The null engine class provides support for headless version of babylon.js.
  42615. * This can be used in server side scenario or for testing purposes
  42616. */
  42617. export class NullEngine extends Engine {
  42618. private _options;
  42619. /**
  42620. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42621. */
  42622. isDeterministicLockStep(): boolean;
  42623. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  42624. getLockstepMaxSteps(): number;
  42625. /**
  42626. * Sets hardware scaling, used to save performance if needed
  42627. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  42628. */
  42629. getHardwareScalingLevel(): number;
  42630. constructor(options?: NullEngineOptions);
  42631. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  42632. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  42633. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  42634. getRenderWidth(useScreen?: boolean): number;
  42635. getRenderHeight(useScreen?: boolean): number;
  42636. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  42637. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  42638. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  42639. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  42640. bindSamplers(effect: Effect): void;
  42641. enableEffect(effect: Effect): void;
  42642. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42643. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  42644. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  42645. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  42646. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  42647. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  42648. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  42649. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  42650. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  42651. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  42652. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  42653. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  42654. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  42655. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  42656. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  42657. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42658. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42659. setFloat(uniform: WebGLUniformLocation, value: number): void;
  42660. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  42661. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  42662. setBool(uniform: WebGLUniformLocation, bool: number): void;
  42663. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  42664. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  42665. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  42666. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  42667. bindBuffers(vertexBuffers: {
  42668. [key: string]: VertexBuffer;
  42669. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  42670. wipeCaches(bruteForce?: boolean): void;
  42671. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42672. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42673. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42674. /** @hidden */
  42675. _createTexture(): WebGLTexture;
  42676. /** @hidden */
  42677. _releaseTexture(texture: InternalTexture): void;
  42678. 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;
  42679. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  42680. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  42681. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  42682. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42683. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  42684. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  42685. areAllEffectsReady(): boolean;
  42686. /**
  42687. * @hidden
  42688. * Get the current error code of the webGL context
  42689. * @returns the error code
  42690. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42691. */
  42692. getError(): number;
  42693. /** @hidden */
  42694. _getUnpackAlignement(): number;
  42695. /** @hidden */
  42696. _unpackFlipY(value: boolean): void;
  42697. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  42698. /**
  42699. * Updates a dynamic vertex buffer.
  42700. * @param vertexBuffer the vertex buffer to update
  42701. * @param data the data used to update the vertex buffer
  42702. * @param byteOffset the byte offset of the data (optional)
  42703. * @param byteLength the byte length of the data (optional)
  42704. */
  42705. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  42706. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  42707. /** @hidden */
  42708. _bindTexture(channel: number, texture: InternalTexture): void;
  42709. /** @hidden */
  42710. _releaseBuffer(buffer: WebGLBuffer): boolean;
  42711. releaseEffects(): void;
  42712. displayLoadingUI(): void;
  42713. hideLoadingUI(): void;
  42714. /** @hidden */
  42715. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42716. /** @hidden */
  42717. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42718. /** @hidden */
  42719. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42720. /** @hidden */
  42721. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  42722. }
  42723. }
  42724. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  42725. import { Nullable, int } from "babylonjs/types";
  42726. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  42727. /** @hidden */
  42728. export class _OcclusionDataStorage {
  42729. /** @hidden */
  42730. occlusionInternalRetryCounter: number;
  42731. /** @hidden */
  42732. isOcclusionQueryInProgress: boolean;
  42733. /** @hidden */
  42734. isOccluded: boolean;
  42735. /** @hidden */
  42736. occlusionRetryCount: number;
  42737. /** @hidden */
  42738. occlusionType: number;
  42739. /** @hidden */
  42740. occlusionQueryAlgorithmType: number;
  42741. }
  42742. module "babylonjs/Engines/engine" {
  42743. interface Engine {
  42744. /**
  42745. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  42746. * @return the new query
  42747. */
  42748. createQuery(): WebGLQuery;
  42749. /**
  42750. * Delete and release a webGL query
  42751. * @param query defines the query to delete
  42752. * @return the current engine
  42753. */
  42754. deleteQuery(query: WebGLQuery): Engine;
  42755. /**
  42756. * Check if a given query has resolved and got its value
  42757. * @param query defines the query to check
  42758. * @returns true if the query got its value
  42759. */
  42760. isQueryResultAvailable(query: WebGLQuery): boolean;
  42761. /**
  42762. * Gets the value of a given query
  42763. * @param query defines the query to check
  42764. * @returns the value of the query
  42765. */
  42766. getQueryResult(query: WebGLQuery): number;
  42767. /**
  42768. * Initiates an occlusion query
  42769. * @param algorithmType defines the algorithm to use
  42770. * @param query defines the query to use
  42771. * @returns the current engine
  42772. * @see http://doc.babylonjs.com/features/occlusionquery
  42773. */
  42774. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42775. /**
  42776. * Ends an occlusion query
  42777. * @see http://doc.babylonjs.com/features/occlusionquery
  42778. * @param algorithmType defines the algorithm to use
  42779. * @returns the current engine
  42780. */
  42781. endOcclusionQuery(algorithmType: number): Engine;
  42782. /**
  42783. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42784. * Please note that only one query can be issued at a time
  42785. * @returns a time token used to track the time span
  42786. */
  42787. startTimeQuery(): Nullable<_TimeToken>;
  42788. /**
  42789. * Ends a time query
  42790. * @param token defines the token used to measure the time span
  42791. * @returns the time spent (in ns)
  42792. */
  42793. endTimeQuery(token: _TimeToken): int;
  42794. /** @hidden */
  42795. _currentNonTimestampToken: Nullable<_TimeToken>;
  42796. /** @hidden */
  42797. _createTimeQuery(): WebGLQuery;
  42798. /** @hidden */
  42799. _deleteTimeQuery(query: WebGLQuery): void;
  42800. /** @hidden */
  42801. _getGlAlgorithmType(algorithmType: number): number;
  42802. /** @hidden */
  42803. _getTimeQueryResult(query: WebGLQuery): any;
  42804. /** @hidden */
  42805. _getTimeQueryAvailability(query: WebGLQuery): any;
  42806. }
  42807. }
  42808. module "babylonjs/Meshes/abstractMesh" {
  42809. interface AbstractMesh {
  42810. /**
  42811. * Backing filed
  42812. * @hidden
  42813. */
  42814. __occlusionDataStorage: _OcclusionDataStorage;
  42815. /**
  42816. * Access property
  42817. * @hidden
  42818. */
  42819. _occlusionDataStorage: _OcclusionDataStorage;
  42820. /**
  42821. * 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.
  42822. * The default value is -1 which means don't break the query and wait till the result
  42823. * @see http://doc.babylonjs.com/features/occlusionquery
  42824. */
  42825. occlusionRetryCount: number;
  42826. /**
  42827. * 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:
  42828. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42829. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42830. * * 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.
  42831. * @see http://doc.babylonjs.com/features/occlusionquery
  42832. */
  42833. occlusionType: number;
  42834. /**
  42835. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42836. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42837. * * 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.
  42838. * @see http://doc.babylonjs.com/features/occlusionquery
  42839. */
  42840. occlusionQueryAlgorithmType: number;
  42841. /**
  42842. * 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
  42843. * @see http://doc.babylonjs.com/features/occlusionquery
  42844. */
  42845. isOccluded: boolean;
  42846. /**
  42847. * Flag to check the progress status of the query
  42848. * @see http://doc.babylonjs.com/features/occlusionquery
  42849. */
  42850. isOcclusionQueryInProgress: boolean;
  42851. }
  42852. }
  42853. }
  42854. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  42855. import { Nullable } from "babylonjs/types";
  42856. /** @hidden */
  42857. export var _forceTransformFeedbackToBundle: boolean;
  42858. module "babylonjs/Engines/engine" {
  42859. interface Engine {
  42860. /**
  42861. * Creates a webGL transform feedback object
  42862. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42863. * @returns the webGL transform feedback object
  42864. */
  42865. createTransformFeedback(): WebGLTransformFeedback;
  42866. /**
  42867. * Delete a webGL transform feedback object
  42868. * @param value defines the webGL transform feedback object to delete
  42869. */
  42870. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42871. /**
  42872. * Bind a webGL transform feedback object to the webgl context
  42873. * @param value defines the webGL transform feedback object to bind
  42874. */
  42875. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42876. /**
  42877. * Begins a transform feedback operation
  42878. * @param usePoints defines if points or triangles must be used
  42879. */
  42880. beginTransformFeedback(usePoints: boolean): void;
  42881. /**
  42882. * Ends a transform feedback operation
  42883. */
  42884. endTransformFeedback(): void;
  42885. /**
  42886. * Specify the varyings to use with transform feedback
  42887. * @param program defines the associated webGL program
  42888. * @param value defines the list of strings representing the varying names
  42889. */
  42890. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42891. /**
  42892. * Bind a webGL buffer for a transform feedback operation
  42893. * @param value defines the webGL buffer to bind
  42894. */
  42895. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  42896. }
  42897. }
  42898. }
  42899. declare module "babylonjs/Engines/Extensions/index" {
  42900. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  42901. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  42902. export * from "babylonjs/Engines/Extensions/engine.multiview";
  42903. }
  42904. declare module "babylonjs/Engines/index" {
  42905. export * from "babylonjs/Engines/constants";
  42906. export * from "babylonjs/Engines/engine";
  42907. export * from "babylonjs/Engines/engineStore";
  42908. export * from "babylonjs/Engines/nullEngine";
  42909. export * from "babylonjs/Engines/Extensions/index";
  42910. }
  42911. declare module "babylonjs/Events/clipboardEvents" {
  42912. /**
  42913. * Gather the list of clipboard event types as constants.
  42914. */
  42915. export class ClipboardEventTypes {
  42916. /**
  42917. * The clipboard event is fired when a copy command is active (pressed).
  42918. */
  42919. static readonly COPY: number;
  42920. /**
  42921. * The clipboard event is fired when a cut command is active (pressed).
  42922. */
  42923. static readonly CUT: number;
  42924. /**
  42925. * The clipboard event is fired when a paste command is active (pressed).
  42926. */
  42927. static readonly PASTE: number;
  42928. }
  42929. /**
  42930. * This class is used to store clipboard related info for the onClipboardObservable event.
  42931. */
  42932. export class ClipboardInfo {
  42933. /**
  42934. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42935. */
  42936. type: number;
  42937. /**
  42938. * Defines the related dom event
  42939. */
  42940. event: ClipboardEvent;
  42941. /**
  42942. *Creates an instance of ClipboardInfo.
  42943. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  42944. * @param event Defines the related dom event
  42945. */
  42946. constructor(
  42947. /**
  42948. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42949. */
  42950. type: number,
  42951. /**
  42952. * Defines the related dom event
  42953. */
  42954. event: ClipboardEvent);
  42955. /**
  42956. * Get the clipboard event's type from the keycode.
  42957. * @param keyCode Defines the keyCode for the current keyboard event.
  42958. * @return {number}
  42959. */
  42960. static GetTypeFromCharacter(keyCode: number): number;
  42961. }
  42962. }
  42963. declare module "babylonjs/Events/index" {
  42964. export * from "babylonjs/Events/keyboardEvents";
  42965. export * from "babylonjs/Events/pointerEvents";
  42966. export * from "babylonjs/Events/clipboardEvents";
  42967. }
  42968. declare module "babylonjs/Loading/sceneLoader" {
  42969. import { Observable } from "babylonjs/Misc/observable";
  42970. import { Nullable } from "babylonjs/types";
  42971. import { Scene } from "babylonjs/scene";
  42972. import { Engine } from "babylonjs/Engines/engine";
  42973. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42974. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42975. import { AssetContainer } from "babylonjs/assetContainer";
  42976. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42977. import { Skeleton } from "babylonjs/Bones/skeleton";
  42978. /**
  42979. * Class used to represent data loading progression
  42980. */
  42981. export class SceneLoaderProgressEvent {
  42982. /** defines if data length to load can be evaluated */
  42983. readonly lengthComputable: boolean;
  42984. /** defines the loaded data length */
  42985. readonly loaded: number;
  42986. /** defines the data length to load */
  42987. readonly total: number;
  42988. /**
  42989. * Create a new progress event
  42990. * @param lengthComputable defines if data length to load can be evaluated
  42991. * @param loaded defines the loaded data length
  42992. * @param total defines the data length to load
  42993. */
  42994. constructor(
  42995. /** defines if data length to load can be evaluated */
  42996. lengthComputable: boolean,
  42997. /** defines the loaded data length */
  42998. loaded: number,
  42999. /** defines the data length to load */
  43000. total: number);
  43001. /**
  43002. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43003. * @param event defines the source event
  43004. * @returns a new SceneLoaderProgressEvent
  43005. */
  43006. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43007. }
  43008. /**
  43009. * Interface used by SceneLoader plugins to define supported file extensions
  43010. */
  43011. export interface ISceneLoaderPluginExtensions {
  43012. /**
  43013. * Defines the list of supported extensions
  43014. */
  43015. [extension: string]: {
  43016. isBinary: boolean;
  43017. };
  43018. }
  43019. /**
  43020. * Interface used by SceneLoader plugin factory
  43021. */
  43022. export interface ISceneLoaderPluginFactory {
  43023. /**
  43024. * Defines the name of the factory
  43025. */
  43026. name: string;
  43027. /**
  43028. * Function called to create a new plugin
  43029. * @return the new plugin
  43030. */
  43031. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43032. /**
  43033. * Boolean indicating if the plugin can direct load specific data
  43034. */
  43035. canDirectLoad?: (data: string) => boolean;
  43036. }
  43037. /**
  43038. * Interface used to define a SceneLoader plugin
  43039. */
  43040. export interface ISceneLoaderPlugin {
  43041. /**
  43042. * The friendly name of this plugin.
  43043. */
  43044. name: string;
  43045. /**
  43046. * The file extensions supported by this plugin.
  43047. */
  43048. extensions: string | ISceneLoaderPluginExtensions;
  43049. /**
  43050. * Import meshes into a scene.
  43051. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43052. * @param scene The scene to import into
  43053. * @param data The data to import
  43054. * @param rootUrl The root url for scene and resources
  43055. * @param meshes The meshes array to import into
  43056. * @param particleSystems The particle systems array to import into
  43057. * @param skeletons The skeletons array to import into
  43058. * @param onError The callback when import fails
  43059. * @returns True if successful or false otherwise
  43060. */
  43061. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43062. /**
  43063. * Load into a scene.
  43064. * @param scene The scene to load into
  43065. * @param data The data to import
  43066. * @param rootUrl The root url for scene and resources
  43067. * @param onError The callback when import fails
  43068. * @returns true if successful or false otherwise
  43069. */
  43070. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43071. /**
  43072. * The callback that returns true if the data can be directly loaded.
  43073. */
  43074. canDirectLoad?: (data: string) => boolean;
  43075. /**
  43076. * The callback that allows custom handling of the root url based on the response url.
  43077. */
  43078. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43079. /**
  43080. * Load into an asset container.
  43081. * @param scene The scene to load into
  43082. * @param data The data to import
  43083. * @param rootUrl The root url for scene and resources
  43084. * @param onError The callback when import fails
  43085. * @returns The loaded asset container
  43086. */
  43087. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43088. }
  43089. /**
  43090. * Interface used to define an async SceneLoader plugin
  43091. */
  43092. export interface ISceneLoaderPluginAsync {
  43093. /**
  43094. * The friendly name of this plugin.
  43095. */
  43096. name: string;
  43097. /**
  43098. * The file extensions supported by this plugin.
  43099. */
  43100. extensions: string | ISceneLoaderPluginExtensions;
  43101. /**
  43102. * Import meshes into a scene.
  43103. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43104. * @param scene The scene to import into
  43105. * @param data The data to import
  43106. * @param rootUrl The root url for scene and resources
  43107. * @param onProgress The callback when the load progresses
  43108. * @param fileName Defines the name of the file to load
  43109. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43110. */
  43111. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43112. meshes: AbstractMesh[];
  43113. particleSystems: IParticleSystem[];
  43114. skeletons: Skeleton[];
  43115. animationGroups: AnimationGroup[];
  43116. }>;
  43117. /**
  43118. * Load into a scene.
  43119. * @param scene The scene to load into
  43120. * @param data The data to import
  43121. * @param rootUrl The root url for scene and resources
  43122. * @param onProgress The callback when the load progresses
  43123. * @param fileName Defines the name of the file to load
  43124. * @returns Nothing
  43125. */
  43126. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43127. /**
  43128. * The callback that returns true if the data can be directly loaded.
  43129. */
  43130. canDirectLoad?: (data: string) => boolean;
  43131. /**
  43132. * The callback that allows custom handling of the root url based on the response url.
  43133. */
  43134. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43135. /**
  43136. * Load into an asset container.
  43137. * @param scene The scene to load into
  43138. * @param data The data to import
  43139. * @param rootUrl The root url for scene and resources
  43140. * @param onProgress The callback when the load progresses
  43141. * @param fileName Defines the name of the file to load
  43142. * @returns The loaded asset container
  43143. */
  43144. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43145. }
  43146. /**
  43147. * Class used to load scene from various file formats using registered plugins
  43148. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43149. */
  43150. export class SceneLoader {
  43151. /**
  43152. * No logging while loading
  43153. */
  43154. static readonly NO_LOGGING: number;
  43155. /**
  43156. * Minimal logging while loading
  43157. */
  43158. static readonly MINIMAL_LOGGING: number;
  43159. /**
  43160. * Summary logging while loading
  43161. */
  43162. static readonly SUMMARY_LOGGING: number;
  43163. /**
  43164. * Detailled logging while loading
  43165. */
  43166. static readonly DETAILED_LOGGING: number;
  43167. /**
  43168. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43169. */
  43170. static ForceFullSceneLoadingForIncremental: boolean;
  43171. /**
  43172. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43173. */
  43174. static ShowLoadingScreen: boolean;
  43175. /**
  43176. * Defines the current logging level (while loading the scene)
  43177. * @ignorenaming
  43178. */
  43179. static loggingLevel: number;
  43180. /**
  43181. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43182. */
  43183. static CleanBoneMatrixWeights: boolean;
  43184. /**
  43185. * Event raised when a plugin is used to load a scene
  43186. */
  43187. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43188. private static _registeredPlugins;
  43189. private static _getDefaultPlugin;
  43190. private static _getPluginForExtension;
  43191. private static _getPluginForDirectLoad;
  43192. private static _getPluginForFilename;
  43193. private static _getDirectLoad;
  43194. private static _loadData;
  43195. private static _getFileInfo;
  43196. /**
  43197. * Gets a plugin that can load the given extension
  43198. * @param extension defines the extension to load
  43199. * @returns a plugin or null if none works
  43200. */
  43201. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43202. /**
  43203. * Gets a boolean indicating that the given extension can be loaded
  43204. * @param extension defines the extension to load
  43205. * @returns true if the extension is supported
  43206. */
  43207. static IsPluginForExtensionAvailable(extension: string): boolean;
  43208. /**
  43209. * Adds a new plugin to the list of registered plugins
  43210. * @param plugin defines the plugin to add
  43211. */
  43212. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43213. /**
  43214. * Import meshes into a scene
  43215. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43216. * @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)
  43217. * @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)
  43218. * @param scene the instance of BABYLON.Scene to append to
  43219. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43220. * @param onProgress a callback with a progress event for each file being loaded
  43221. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43222. * @param pluginExtension the extension used to determine the plugin
  43223. * @returns The loaded plugin
  43224. */
  43225. 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>;
  43226. /**
  43227. * Import meshes into a scene
  43228. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43229. * @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)
  43230. * @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)
  43231. * @param scene the instance of BABYLON.Scene to append to
  43232. * @param onProgress a callback with a progress event for each file being loaded
  43233. * @param pluginExtension the extension used to determine the plugin
  43234. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43235. */
  43236. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43237. meshes: AbstractMesh[];
  43238. particleSystems: IParticleSystem[];
  43239. skeletons: Skeleton[];
  43240. animationGroups: AnimationGroup[];
  43241. }>;
  43242. /**
  43243. * Load a scene
  43244. * @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)
  43245. * @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)
  43246. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43247. * @param onSuccess a callback with the scene when import succeeds
  43248. * @param onProgress a callback with a progress event for each file being loaded
  43249. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43250. * @param pluginExtension the extension used to determine the plugin
  43251. * @returns The loaded plugin
  43252. */
  43253. 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>;
  43254. /**
  43255. * Load a scene
  43256. * @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)
  43257. * @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)
  43258. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43259. * @param onProgress a callback with a progress event for each file being loaded
  43260. * @param pluginExtension the extension used to determine the plugin
  43261. * @returns The loaded scene
  43262. */
  43263. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43264. /**
  43265. * Append a scene
  43266. * @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)
  43267. * @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)
  43268. * @param scene is the instance of BABYLON.Scene to append to
  43269. * @param onSuccess a callback with the scene when import succeeds
  43270. * @param onProgress a callback with a progress event for each file being loaded
  43271. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43272. * @param pluginExtension the extension used to determine the plugin
  43273. * @returns The loaded plugin
  43274. */
  43275. 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>;
  43276. /**
  43277. * Append a scene
  43278. * @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)
  43279. * @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)
  43280. * @param scene is the instance of BABYLON.Scene to append to
  43281. * @param onProgress a callback with a progress event for each file being loaded
  43282. * @param pluginExtension the extension used to determine the plugin
  43283. * @returns The given scene
  43284. */
  43285. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43286. /**
  43287. * Load a scene into an asset container
  43288. * @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)
  43289. * @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)
  43290. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43291. * @param onSuccess a callback with the scene when import succeeds
  43292. * @param onProgress a callback with a progress event for each file being loaded
  43293. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43294. * @param pluginExtension the extension used to determine the plugin
  43295. * @returns The loaded plugin
  43296. */
  43297. 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>;
  43298. /**
  43299. * Load a scene into an asset container
  43300. * @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)
  43301. * @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)
  43302. * @param scene is the instance of Scene to append to
  43303. * @param onProgress a callback with a progress event for each file being loaded
  43304. * @param pluginExtension the extension used to determine the plugin
  43305. * @returns The loaded asset container
  43306. */
  43307. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43308. }
  43309. }
  43310. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  43311. import { Scene } from "babylonjs/scene";
  43312. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43313. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43314. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43315. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43316. /**
  43317. * Google Daydream controller
  43318. */
  43319. export class DaydreamController extends WebVRController {
  43320. /**
  43321. * Base Url for the controller model.
  43322. */
  43323. static MODEL_BASE_URL: string;
  43324. /**
  43325. * File name for the controller model.
  43326. */
  43327. static MODEL_FILENAME: string;
  43328. /**
  43329. * Gamepad Id prefix used to identify Daydream Controller.
  43330. */
  43331. static readonly GAMEPAD_ID_PREFIX: string;
  43332. /**
  43333. * Creates a new DaydreamController from a gamepad
  43334. * @param vrGamepad the gamepad that the controller should be created from
  43335. */
  43336. constructor(vrGamepad: any);
  43337. /**
  43338. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43339. * @param scene scene in which to add meshes
  43340. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43341. */
  43342. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43343. /**
  43344. * Called once for each button that changed state since the last frame
  43345. * @param buttonIdx Which button index changed
  43346. * @param state New state of the button
  43347. * @param changes Which properties on the state changed since last frame
  43348. */
  43349. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43350. }
  43351. }
  43352. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  43353. import { Scene } from "babylonjs/scene";
  43354. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43355. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43356. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43357. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43358. /**
  43359. * Gear VR Controller
  43360. */
  43361. export class GearVRController extends WebVRController {
  43362. /**
  43363. * Base Url for the controller model.
  43364. */
  43365. static MODEL_BASE_URL: string;
  43366. /**
  43367. * File name for the controller model.
  43368. */
  43369. static MODEL_FILENAME: string;
  43370. /**
  43371. * Gamepad Id prefix used to identify this controller.
  43372. */
  43373. static readonly GAMEPAD_ID_PREFIX: string;
  43374. private readonly _buttonIndexToObservableNameMap;
  43375. /**
  43376. * Creates a new GearVRController from a gamepad
  43377. * @param vrGamepad the gamepad that the controller should be created from
  43378. */
  43379. constructor(vrGamepad: any);
  43380. /**
  43381. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43382. * @param scene scene in which to add meshes
  43383. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43384. */
  43385. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43386. /**
  43387. * Called once for each button that changed state since the last frame
  43388. * @param buttonIdx Which button index changed
  43389. * @param state New state of the button
  43390. * @param changes Which properties on the state changed since last frame
  43391. */
  43392. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43393. }
  43394. }
  43395. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43396. import { Scene } from "babylonjs/scene";
  43397. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43398. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43399. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43400. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43401. /**
  43402. * Generic Controller
  43403. */
  43404. export class GenericController extends WebVRController {
  43405. /**
  43406. * Base Url for the controller model.
  43407. */
  43408. static readonly MODEL_BASE_URL: string;
  43409. /**
  43410. * File name for the controller model.
  43411. */
  43412. static readonly MODEL_FILENAME: string;
  43413. /**
  43414. * Creates a new GenericController from a gamepad
  43415. * @param vrGamepad the gamepad that the controller should be created from
  43416. */
  43417. constructor(vrGamepad: any);
  43418. /**
  43419. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43420. * @param scene scene in which to add meshes
  43421. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43422. */
  43423. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43424. /**
  43425. * Called once for each button that changed state since the last frame
  43426. * @param buttonIdx Which button index changed
  43427. * @param state New state of the button
  43428. * @param changes Which properties on the state changed since last frame
  43429. */
  43430. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43431. }
  43432. }
  43433. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43434. import { Observable } from "babylonjs/Misc/observable";
  43435. import { Scene } from "babylonjs/scene";
  43436. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43437. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43438. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43439. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43440. /**
  43441. * Oculus Touch Controller
  43442. */
  43443. export class OculusTouchController extends WebVRController {
  43444. /**
  43445. * Base Url for the controller model.
  43446. */
  43447. static MODEL_BASE_URL: string;
  43448. /**
  43449. * File name for the left controller model.
  43450. */
  43451. static MODEL_LEFT_FILENAME: string;
  43452. /**
  43453. * File name for the right controller model.
  43454. */
  43455. static MODEL_RIGHT_FILENAME: string;
  43456. /**
  43457. * Fired when the secondary trigger on this controller is modified
  43458. */
  43459. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43460. /**
  43461. * Fired when the thumb rest on this controller is modified
  43462. */
  43463. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43464. /**
  43465. * Creates a new OculusTouchController from a gamepad
  43466. * @param vrGamepad the gamepad that the controller should be created from
  43467. */
  43468. constructor(vrGamepad: any);
  43469. /**
  43470. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43471. * @param scene scene in which to add meshes
  43472. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43473. */
  43474. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43475. /**
  43476. * Fired when the A button on this controller is modified
  43477. */
  43478. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43479. /**
  43480. * Fired when the B button on this controller is modified
  43481. */
  43482. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43483. /**
  43484. * Fired when the X button on this controller is modified
  43485. */
  43486. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43487. /**
  43488. * Fired when the Y button on this controller is modified
  43489. */
  43490. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43491. /**
  43492. * Called once for each button that changed state since the last frame
  43493. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43494. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43495. * 2) secondary trigger (same)
  43496. * 3) A (right) X (left), touch, pressed = value
  43497. * 4) B / Y
  43498. * 5) thumb rest
  43499. * @param buttonIdx Which button index changed
  43500. * @param state New state of the button
  43501. * @param changes Which properties on the state changed since last frame
  43502. */
  43503. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43504. }
  43505. }
  43506. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43507. import { Scene } from "babylonjs/scene";
  43508. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43509. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43510. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43511. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43512. import { Observable } from "babylonjs/Misc/observable";
  43513. /**
  43514. * Vive Controller
  43515. */
  43516. export class ViveController extends WebVRController {
  43517. /**
  43518. * Base Url for the controller model.
  43519. */
  43520. static MODEL_BASE_URL: string;
  43521. /**
  43522. * File name for the controller model.
  43523. */
  43524. static MODEL_FILENAME: string;
  43525. /**
  43526. * Creates a new ViveController from a gamepad
  43527. * @param vrGamepad the gamepad that the controller should be created from
  43528. */
  43529. constructor(vrGamepad: any);
  43530. /**
  43531. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43532. * @param scene scene in which to add meshes
  43533. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43534. */
  43535. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43536. /**
  43537. * Fired when the left button on this controller is modified
  43538. */
  43539. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43540. /**
  43541. * Fired when the right button on this controller is modified
  43542. */
  43543. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43544. /**
  43545. * Fired when the menu button on this controller is modified
  43546. */
  43547. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43548. /**
  43549. * Called once for each button that changed state since the last frame
  43550. * Vive mapping:
  43551. * 0: touchpad
  43552. * 1: trigger
  43553. * 2: left AND right buttons
  43554. * 3: menu button
  43555. * @param buttonIdx Which button index changed
  43556. * @param state New state of the button
  43557. * @param changes Which properties on the state changed since last frame
  43558. */
  43559. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43560. }
  43561. }
  43562. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43563. import { Observable } from "babylonjs/Misc/observable";
  43564. import { Scene } from "babylonjs/scene";
  43565. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43566. import { Ray } from "babylonjs/Culling/ray";
  43567. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43568. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43569. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43570. /**
  43571. * Defines the WindowsMotionController object that the state of the windows motion controller
  43572. */
  43573. export class WindowsMotionController extends WebVRController {
  43574. /**
  43575. * The base url used to load the left and right controller models
  43576. */
  43577. static MODEL_BASE_URL: string;
  43578. /**
  43579. * The name of the left controller model file
  43580. */
  43581. static MODEL_LEFT_FILENAME: string;
  43582. /**
  43583. * The name of the right controller model file
  43584. */
  43585. static MODEL_RIGHT_FILENAME: string;
  43586. /**
  43587. * The controller name prefix for this controller type
  43588. */
  43589. static readonly GAMEPAD_ID_PREFIX: string;
  43590. /**
  43591. * The controller id pattern for this controller type
  43592. */
  43593. private static readonly GAMEPAD_ID_PATTERN;
  43594. private _loadedMeshInfo;
  43595. private readonly _mapping;
  43596. /**
  43597. * Fired when the trackpad on this controller is clicked
  43598. */
  43599. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43600. /**
  43601. * Fired when the trackpad on this controller is modified
  43602. */
  43603. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43604. /**
  43605. * The current x and y values of this controller's trackpad
  43606. */
  43607. trackpad: StickValues;
  43608. /**
  43609. * Creates a new WindowsMotionController from a gamepad
  43610. * @param vrGamepad the gamepad that the controller should be created from
  43611. */
  43612. constructor(vrGamepad: any);
  43613. /**
  43614. * Fired when the trigger on this controller is modified
  43615. */
  43616. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43617. /**
  43618. * Fired when the menu button on this controller is modified
  43619. */
  43620. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43621. /**
  43622. * Fired when the grip button on this controller is modified
  43623. */
  43624. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43625. /**
  43626. * Fired when the thumbstick button on this controller is modified
  43627. */
  43628. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43629. /**
  43630. * Fired when the touchpad button on this controller is modified
  43631. */
  43632. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43633. /**
  43634. * Fired when the touchpad values on this controller are modified
  43635. */
  43636. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43637. private _updateTrackpad;
  43638. /**
  43639. * Called once per frame by the engine.
  43640. */
  43641. update(): void;
  43642. /**
  43643. * Called once for each button that changed state since the last frame
  43644. * @param buttonIdx Which button index changed
  43645. * @param state New state of the button
  43646. * @param changes Which properties on the state changed since last frame
  43647. */
  43648. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43649. /**
  43650. * Moves the buttons on the controller mesh based on their current state
  43651. * @param buttonName the name of the button to move
  43652. * @param buttonValue the value of the button which determines the buttons new position
  43653. */
  43654. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43655. /**
  43656. * Moves the axis on the controller mesh based on its current state
  43657. * @param axis the index of the axis
  43658. * @param axisValue the value of the axis which determines the meshes new position
  43659. * @hidden
  43660. */
  43661. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43662. /**
  43663. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43664. * @param scene scene in which to add meshes
  43665. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43666. */
  43667. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43668. /**
  43669. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43670. * can be transformed by button presses and axes values, based on this._mapping.
  43671. *
  43672. * @param scene scene in which the meshes exist
  43673. * @param meshes list of meshes that make up the controller model to process
  43674. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43675. */
  43676. private processModel;
  43677. private createMeshInfo;
  43678. /**
  43679. * Gets the ray of the controller in the direction the controller is pointing
  43680. * @param length the length the resulting ray should be
  43681. * @returns a ray in the direction the controller is pointing
  43682. */
  43683. getForwardRay(length?: number): Ray;
  43684. /**
  43685. * Disposes of the controller
  43686. */
  43687. dispose(): void;
  43688. }
  43689. }
  43690. declare module "babylonjs/Gamepads/Controllers/index" {
  43691. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  43692. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  43693. export * from "babylonjs/Gamepads/Controllers/genericController";
  43694. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  43695. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43696. export * from "babylonjs/Gamepads/Controllers/viveController";
  43697. export * from "babylonjs/Gamepads/Controllers/webVRController";
  43698. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  43699. }
  43700. declare module "babylonjs/Gamepads/index" {
  43701. export * from "babylonjs/Gamepads/Controllers/index";
  43702. export * from "babylonjs/Gamepads/gamepad";
  43703. export * from "babylonjs/Gamepads/gamepadManager";
  43704. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  43705. export * from "babylonjs/Gamepads/xboxGamepad";
  43706. }
  43707. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  43708. import { Observable } from "babylonjs/Misc/observable";
  43709. import { Nullable } from "babylonjs/types";
  43710. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43711. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43712. import { Mesh } from "babylonjs/Meshes/mesh";
  43713. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43714. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43715. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43716. /**
  43717. * Single axis scale gizmo
  43718. */
  43719. export class AxisScaleGizmo extends Gizmo {
  43720. private _coloredMaterial;
  43721. /**
  43722. * Drag behavior responsible for the gizmos dragging interactions
  43723. */
  43724. dragBehavior: PointerDragBehavior;
  43725. private _pointerObserver;
  43726. /**
  43727. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43728. */
  43729. snapDistance: number;
  43730. /**
  43731. * Event that fires each time the gizmo snaps to a new location.
  43732. * * snapDistance is the the change in distance
  43733. */
  43734. onSnapObservable: Observable<{
  43735. snapDistance: number;
  43736. }>;
  43737. /**
  43738. * If the scaling operation should be done on all axis (default: false)
  43739. */
  43740. uniformScaling: boolean;
  43741. /**
  43742. * Creates an AxisScaleGizmo
  43743. * @param gizmoLayer The utility layer the gizmo will be added to
  43744. * @param dragAxis The axis which the gizmo will be able to scale on
  43745. * @param color The color of the gizmo
  43746. */
  43747. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43748. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43749. /**
  43750. * Disposes of the gizmo
  43751. */
  43752. dispose(): void;
  43753. /**
  43754. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43755. * @param mesh The mesh to replace the default mesh of the gizmo
  43756. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  43757. */
  43758. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  43759. }
  43760. }
  43761. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  43762. import { Observable } from "babylonjs/Misc/observable";
  43763. import { Nullable } from "babylonjs/types";
  43764. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43765. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43766. import { Mesh } from "babylonjs/Meshes/mesh";
  43767. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43768. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43769. import "babylonjs/Meshes/Builders/boxBuilder";
  43770. /**
  43771. * Bounding box gizmo
  43772. */
  43773. export class BoundingBoxGizmo extends Gizmo {
  43774. private _lineBoundingBox;
  43775. private _rotateSpheresParent;
  43776. private _scaleBoxesParent;
  43777. private _boundingDimensions;
  43778. private _renderObserver;
  43779. private _pointerObserver;
  43780. private _scaleDragSpeed;
  43781. private _tmpQuaternion;
  43782. private _tmpVector;
  43783. private _tmpRotationMatrix;
  43784. /**
  43785. * 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)
  43786. */
  43787. ignoreChildren: boolean;
  43788. /**
  43789. * 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)
  43790. */
  43791. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43792. /**
  43793. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43794. */
  43795. rotationSphereSize: number;
  43796. /**
  43797. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43798. */
  43799. scaleBoxSize: number;
  43800. /**
  43801. * 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)
  43802. */
  43803. fixedDragMeshScreenSize: boolean;
  43804. /**
  43805. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43806. */
  43807. fixedDragMeshScreenSizeDistanceFactor: number;
  43808. /**
  43809. * Fired when a rotation sphere or scale box is dragged
  43810. */
  43811. onDragStartObservable: Observable<{}>;
  43812. /**
  43813. * Fired when a scale box is dragged
  43814. */
  43815. onScaleBoxDragObservable: Observable<{}>;
  43816. /**
  43817. * Fired when a scale box drag is ended
  43818. */
  43819. onScaleBoxDragEndObservable: Observable<{}>;
  43820. /**
  43821. * Fired when a rotation sphere is dragged
  43822. */
  43823. onRotationSphereDragObservable: Observable<{}>;
  43824. /**
  43825. * Fired when a rotation sphere drag is ended
  43826. */
  43827. onRotationSphereDragEndObservable: Observable<{}>;
  43828. /**
  43829. * 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)
  43830. */
  43831. scalePivot: Nullable<Vector3>;
  43832. private _anchorMesh;
  43833. private _existingMeshScale;
  43834. private _dragMesh;
  43835. private pointerDragBehavior;
  43836. private coloredMaterial;
  43837. private hoverColoredMaterial;
  43838. /**
  43839. * Sets the color of the bounding box gizmo
  43840. * @param color the color to set
  43841. */
  43842. setColor(color: Color3): void;
  43843. /**
  43844. * Creates an BoundingBoxGizmo
  43845. * @param gizmoLayer The utility layer the gizmo will be added to
  43846. * @param color The color of the gizmo
  43847. */
  43848. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43849. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43850. private _selectNode;
  43851. /**
  43852. * Updates the bounding box information for the Gizmo
  43853. */
  43854. updateBoundingBox(): void;
  43855. private _updateRotationSpheres;
  43856. private _updateScaleBoxes;
  43857. /**
  43858. * Enables rotation on the specified axis and disables rotation on the others
  43859. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43860. */
  43861. setEnabledRotationAxis(axis: string): void;
  43862. /**
  43863. * Enables/disables scaling
  43864. * @param enable if scaling should be enabled
  43865. */
  43866. setEnabledScaling(enable: boolean): void;
  43867. private _updateDummy;
  43868. /**
  43869. * Enables a pointer drag behavior on the bounding box of the gizmo
  43870. */
  43871. enableDragBehavior(): void;
  43872. /**
  43873. * Disposes of the gizmo
  43874. */
  43875. dispose(): void;
  43876. /**
  43877. * 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)
  43878. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43879. * @returns the bounding box mesh with the passed in mesh as a child
  43880. */
  43881. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43882. /**
  43883. * CustomMeshes are not supported by this gizmo
  43884. * @param mesh The mesh to replace the default mesh of the gizmo
  43885. */
  43886. setCustomMesh(mesh: Mesh): void;
  43887. }
  43888. }
  43889. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  43890. import { Observable } from "babylonjs/Misc/observable";
  43891. import { Nullable } from "babylonjs/types";
  43892. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43893. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43894. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43895. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43896. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43897. import "babylonjs/Meshes/Builders/linesBuilder";
  43898. /**
  43899. * Single plane rotation gizmo
  43900. */
  43901. export class PlaneRotationGizmo extends Gizmo {
  43902. /**
  43903. * Drag behavior responsible for the gizmos dragging interactions
  43904. */
  43905. dragBehavior: PointerDragBehavior;
  43906. private _pointerObserver;
  43907. /**
  43908. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43909. */
  43910. snapDistance: number;
  43911. /**
  43912. * Event that fires each time the gizmo snaps to a new location.
  43913. * * snapDistance is the the change in distance
  43914. */
  43915. onSnapObservable: Observable<{
  43916. snapDistance: number;
  43917. }>;
  43918. /**
  43919. * Creates a PlaneRotationGizmo
  43920. * @param gizmoLayer The utility layer the gizmo will be added to
  43921. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43922. * @param color The color of the gizmo
  43923. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43924. */
  43925. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43926. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43927. /**
  43928. * Disposes of the gizmo
  43929. */
  43930. dispose(): void;
  43931. }
  43932. }
  43933. declare module "babylonjs/Gizmos/rotationGizmo" {
  43934. import { Observable } from "babylonjs/Misc/observable";
  43935. import { Nullable } from "babylonjs/types";
  43936. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43937. import { Mesh } from "babylonjs/Meshes/mesh";
  43938. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43939. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  43940. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43941. /**
  43942. * Gizmo that enables rotating a mesh along 3 axis
  43943. */
  43944. export class RotationGizmo extends Gizmo {
  43945. /**
  43946. * Internal gizmo used for interactions on the x axis
  43947. */
  43948. xGizmo: PlaneRotationGizmo;
  43949. /**
  43950. * Internal gizmo used for interactions on the y axis
  43951. */
  43952. yGizmo: PlaneRotationGizmo;
  43953. /**
  43954. * Internal gizmo used for interactions on the z axis
  43955. */
  43956. zGizmo: PlaneRotationGizmo;
  43957. /** Fires an event when any of it's sub gizmos are dragged */
  43958. onDragStartObservable: Observable<{}>;
  43959. /** Fires an event when any of it's sub gizmos are released from dragging */
  43960. onDragEndObservable: Observable<{}>;
  43961. attachedMesh: Nullable<AbstractMesh>;
  43962. /**
  43963. * Creates a RotationGizmo
  43964. * @param gizmoLayer The utility layer the gizmo will be added to
  43965. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43966. */
  43967. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43968. updateGizmoRotationToMatchAttachedMesh: boolean;
  43969. /**
  43970. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43971. */
  43972. snapDistance: number;
  43973. /**
  43974. * Ratio for the scale of the gizmo (Default: 1)
  43975. */
  43976. scaleRatio: number;
  43977. /**
  43978. * Disposes of the gizmo
  43979. */
  43980. dispose(): void;
  43981. /**
  43982. * CustomMeshes are not supported by this gizmo
  43983. * @param mesh The mesh to replace the default mesh of the gizmo
  43984. */
  43985. setCustomMesh(mesh: Mesh): void;
  43986. }
  43987. }
  43988. declare module "babylonjs/Gizmos/positionGizmo" {
  43989. import { Observable } from "babylonjs/Misc/observable";
  43990. import { Nullable } from "babylonjs/types";
  43991. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43992. import { Mesh } from "babylonjs/Meshes/mesh";
  43993. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43994. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  43995. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43996. /**
  43997. * Gizmo that enables dragging a mesh along 3 axis
  43998. */
  43999. export class PositionGizmo extends Gizmo {
  44000. /**
  44001. * Internal gizmo used for interactions on the x axis
  44002. */
  44003. xGizmo: AxisDragGizmo;
  44004. /**
  44005. * Internal gizmo used for interactions on the y axis
  44006. */
  44007. yGizmo: AxisDragGizmo;
  44008. /**
  44009. * Internal gizmo used for interactions on the z axis
  44010. */
  44011. zGizmo: AxisDragGizmo;
  44012. /** Fires an event when any of it's sub gizmos are dragged */
  44013. onDragStartObservable: Observable<{}>;
  44014. /** Fires an event when any of it's sub gizmos are released from dragging */
  44015. onDragEndObservable: Observable<{}>;
  44016. attachedMesh: Nullable<AbstractMesh>;
  44017. /**
  44018. * Creates a PositionGizmo
  44019. * @param gizmoLayer The utility layer the gizmo will be added to
  44020. */
  44021. constructor(gizmoLayer?: UtilityLayerRenderer);
  44022. updateGizmoRotationToMatchAttachedMesh: boolean;
  44023. /**
  44024. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44025. */
  44026. snapDistance: number;
  44027. /**
  44028. * Ratio for the scale of the gizmo (Default: 1)
  44029. */
  44030. scaleRatio: number;
  44031. /**
  44032. * Disposes of the gizmo
  44033. */
  44034. dispose(): void;
  44035. /**
  44036. * CustomMeshes are not supported by this gizmo
  44037. * @param mesh The mesh to replace the default mesh of the gizmo
  44038. */
  44039. setCustomMesh(mesh: Mesh): void;
  44040. }
  44041. }
  44042. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  44043. import { Scene } from "babylonjs/scene";
  44044. import { Color4, Vector4 } from "babylonjs/Maths/math";
  44045. import { Mesh } from "babylonjs/Meshes/mesh";
  44046. import { Nullable } from "babylonjs/types";
  44047. /**
  44048. * Class containing static functions to help procedurally build meshes
  44049. */
  44050. export class PolyhedronBuilder {
  44051. /**
  44052. * Creates a polyhedron mesh
  44053. * * 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
  44054. * * The parameter `size` (positive float, default 1) sets the polygon size
  44055. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44056. * * 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`
  44057. * * 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
  44058. * * 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)`)
  44059. * * 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
  44060. * * 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
  44061. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44062. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44063. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44064. * @param name defines the name of the mesh
  44065. * @param options defines the options used to create the mesh
  44066. * @param scene defines the hosting scene
  44067. * @returns the polyhedron mesh
  44068. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44069. */
  44070. static CreatePolyhedron(name: string, options: {
  44071. type?: number;
  44072. size?: number;
  44073. sizeX?: number;
  44074. sizeY?: number;
  44075. sizeZ?: number;
  44076. custom?: any;
  44077. faceUV?: Vector4[];
  44078. faceColors?: Color4[];
  44079. flat?: boolean;
  44080. updatable?: boolean;
  44081. sideOrientation?: number;
  44082. frontUVs?: Vector4;
  44083. backUVs?: Vector4;
  44084. }, scene?: Nullable<Scene>): Mesh;
  44085. }
  44086. }
  44087. declare module "babylonjs/Gizmos/scaleGizmo" {
  44088. import { Observable } from "babylonjs/Misc/observable";
  44089. import { Nullable } from "babylonjs/types";
  44090. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44091. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44092. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  44093. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44094. /**
  44095. * Gizmo that enables scaling a mesh along 3 axis
  44096. */
  44097. export class ScaleGizmo extends Gizmo {
  44098. /**
  44099. * Internal gizmo used for interactions on the x axis
  44100. */
  44101. xGizmo: AxisScaleGizmo;
  44102. /**
  44103. * Internal gizmo used for interactions on the y axis
  44104. */
  44105. yGizmo: AxisScaleGizmo;
  44106. /**
  44107. * Internal gizmo used for interactions on the z axis
  44108. */
  44109. zGizmo: AxisScaleGizmo;
  44110. /**
  44111. * Internal gizmo used to scale all axis equally
  44112. */
  44113. uniformScaleGizmo: AxisScaleGizmo;
  44114. /** Fires an event when any of it's sub gizmos are dragged */
  44115. onDragStartObservable: Observable<{}>;
  44116. /** Fires an event when any of it's sub gizmos are released from dragging */
  44117. onDragEndObservable: Observable<{}>;
  44118. attachedMesh: Nullable<AbstractMesh>;
  44119. /**
  44120. * Creates a ScaleGizmo
  44121. * @param gizmoLayer The utility layer the gizmo will be added to
  44122. */
  44123. constructor(gizmoLayer?: UtilityLayerRenderer);
  44124. updateGizmoRotationToMatchAttachedMesh: boolean;
  44125. /**
  44126. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44127. */
  44128. snapDistance: number;
  44129. /**
  44130. * Ratio for the scale of the gizmo (Default: 1)
  44131. */
  44132. scaleRatio: number;
  44133. /**
  44134. * Disposes of the gizmo
  44135. */
  44136. dispose(): void;
  44137. }
  44138. }
  44139. declare module "babylonjs/Gizmos/gizmoManager" {
  44140. import { Observable } from "babylonjs/Misc/observable";
  44141. import { Nullable } from "babylonjs/types";
  44142. import { Scene, IDisposable } from "babylonjs/scene";
  44143. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44144. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  44145. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  44146. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44147. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  44148. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  44149. /**
  44150. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  44151. */
  44152. export class GizmoManager implements IDisposable {
  44153. private scene;
  44154. /**
  44155. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  44156. */
  44157. gizmos: {
  44158. positionGizmo: Nullable<PositionGizmo>;
  44159. rotationGizmo: Nullable<RotationGizmo>;
  44160. scaleGizmo: Nullable<ScaleGizmo>;
  44161. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  44162. };
  44163. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  44164. clearGizmoOnEmptyPointerEvent: boolean;
  44165. /** Fires an event when the manager is attached to a mesh */
  44166. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  44167. private _gizmosEnabled;
  44168. private _pointerObserver;
  44169. private _attachedMesh;
  44170. private _boundingBoxColor;
  44171. private _defaultUtilityLayer;
  44172. private _defaultKeepDepthUtilityLayer;
  44173. /**
  44174. * When bounding box gizmo is enabled, this can be used to track drag/end events
  44175. */
  44176. boundingBoxDragBehavior: SixDofDragBehavior;
  44177. /**
  44178. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  44179. */
  44180. attachableMeshes: Nullable<Array<AbstractMesh>>;
  44181. /**
  44182. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  44183. */
  44184. usePointerToAttachGizmos: boolean;
  44185. /**
  44186. * Instatiates a gizmo manager
  44187. * @param scene the scene to overlay the gizmos on top of
  44188. */
  44189. constructor(scene: Scene);
  44190. /**
  44191. * Attaches a set of gizmos to the specified mesh
  44192. * @param mesh The mesh the gizmo's should be attached to
  44193. */
  44194. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44195. /**
  44196. * If the position gizmo is enabled
  44197. */
  44198. positionGizmoEnabled: boolean;
  44199. /**
  44200. * If the rotation gizmo is enabled
  44201. */
  44202. rotationGizmoEnabled: boolean;
  44203. /**
  44204. * If the scale gizmo is enabled
  44205. */
  44206. scaleGizmoEnabled: boolean;
  44207. /**
  44208. * If the boundingBox gizmo is enabled
  44209. */
  44210. boundingBoxGizmoEnabled: boolean;
  44211. /**
  44212. * Disposes of the gizmo manager
  44213. */
  44214. dispose(): void;
  44215. }
  44216. }
  44217. declare module "babylonjs/Lights/directionalLight" {
  44218. import { Camera } from "babylonjs/Cameras/camera";
  44219. import { Scene } from "babylonjs/scene";
  44220. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44221. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44222. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44223. import { Effect } from "babylonjs/Materials/effect";
  44224. /**
  44225. * A directional light is defined by a direction (what a surprise!).
  44226. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44227. * 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.
  44228. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44229. */
  44230. export class DirectionalLight extends ShadowLight {
  44231. private _shadowFrustumSize;
  44232. /**
  44233. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44234. */
  44235. /**
  44236. * Specifies a fix frustum size for the shadow generation.
  44237. */
  44238. shadowFrustumSize: number;
  44239. private _shadowOrthoScale;
  44240. /**
  44241. * Gets the shadow projection scale against the optimal computed one.
  44242. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44243. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44244. */
  44245. /**
  44246. * Sets the shadow projection scale against the optimal computed one.
  44247. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44248. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44249. */
  44250. shadowOrthoScale: number;
  44251. /**
  44252. * Automatically compute the projection matrix to best fit (including all the casters)
  44253. * on each frame.
  44254. */
  44255. autoUpdateExtends: boolean;
  44256. private _orthoLeft;
  44257. private _orthoRight;
  44258. private _orthoTop;
  44259. private _orthoBottom;
  44260. /**
  44261. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44262. * The directional light is emitted from everywhere in the given direction.
  44263. * It can cast shadows.
  44264. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44265. * @param name The friendly name of the light
  44266. * @param direction The direction of the light
  44267. * @param scene The scene the light belongs to
  44268. */
  44269. constructor(name: string, direction: Vector3, scene: Scene);
  44270. /**
  44271. * Returns the string "DirectionalLight".
  44272. * @return The class name
  44273. */
  44274. getClassName(): string;
  44275. /**
  44276. * Returns the integer 1.
  44277. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44278. */
  44279. getTypeID(): number;
  44280. /**
  44281. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44282. * Returns the DirectionalLight Shadow projection matrix.
  44283. */
  44284. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44285. /**
  44286. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44287. * Returns the DirectionalLight Shadow projection matrix.
  44288. */
  44289. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44290. /**
  44291. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44292. * Returns the DirectionalLight Shadow projection matrix.
  44293. */
  44294. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44295. protected _buildUniformLayout(): void;
  44296. /**
  44297. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44298. * @param effect The effect to update
  44299. * @param lightIndex The index of the light in the effect to update
  44300. * @returns The directional light
  44301. */
  44302. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44303. /**
  44304. * Gets the minZ used for shadow according to both the scene and the light.
  44305. *
  44306. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44307. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44308. * @param activeCamera The camera we are returning the min for
  44309. * @returns the depth min z
  44310. */
  44311. getDepthMinZ(activeCamera: Camera): number;
  44312. /**
  44313. * Gets the maxZ used for shadow according to both the scene and the light.
  44314. *
  44315. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44316. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44317. * @param activeCamera The camera we are returning the max for
  44318. * @returns the depth max z
  44319. */
  44320. getDepthMaxZ(activeCamera: Camera): number;
  44321. /**
  44322. * Prepares the list of defines specific to the light type.
  44323. * @param defines the list of defines
  44324. * @param lightIndex defines the index of the light for the effect
  44325. */
  44326. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44327. }
  44328. }
  44329. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  44330. import { Mesh } from "babylonjs/Meshes/mesh";
  44331. /**
  44332. * Class containing static functions to help procedurally build meshes
  44333. */
  44334. export class HemisphereBuilder {
  44335. /**
  44336. * Creates a hemisphere mesh
  44337. * @param name defines the name of the mesh
  44338. * @param options defines the options used to create the mesh
  44339. * @param scene defines the hosting scene
  44340. * @returns the hemisphere mesh
  44341. */
  44342. static CreateHemisphere(name: string, options: {
  44343. segments?: number;
  44344. diameter?: number;
  44345. sideOrientation?: number;
  44346. }, scene: any): Mesh;
  44347. }
  44348. }
  44349. declare module "babylonjs/Lights/spotLight" {
  44350. import { Nullable } from "babylonjs/types";
  44351. import { Scene } from "babylonjs/scene";
  44352. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44353. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44354. import { Effect } from "babylonjs/Materials/effect";
  44355. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44356. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44357. /**
  44358. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44359. * These values define a cone of light starting from the position, emitting toward the direction.
  44360. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44361. * and the exponent defines the speed of the decay of the light with distance (reach).
  44362. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44363. */
  44364. export class SpotLight extends ShadowLight {
  44365. private _angle;
  44366. private _innerAngle;
  44367. private _cosHalfAngle;
  44368. private _lightAngleScale;
  44369. private _lightAngleOffset;
  44370. /**
  44371. * Gets the cone angle of the spot light in Radians.
  44372. */
  44373. /**
  44374. * Sets the cone angle of the spot light in Radians.
  44375. */
  44376. angle: number;
  44377. /**
  44378. * Only used in gltf falloff mode, this defines the angle where
  44379. * the directional falloff will start before cutting at angle which could be seen
  44380. * as outer angle.
  44381. */
  44382. /**
  44383. * Only used in gltf falloff mode, this defines the angle where
  44384. * the directional falloff will start before cutting at angle which could be seen
  44385. * as outer angle.
  44386. */
  44387. innerAngle: number;
  44388. private _shadowAngleScale;
  44389. /**
  44390. * Allows scaling the angle of the light for shadow generation only.
  44391. */
  44392. /**
  44393. * Allows scaling the angle of the light for shadow generation only.
  44394. */
  44395. shadowAngleScale: number;
  44396. /**
  44397. * The light decay speed with the distance from the emission spot.
  44398. */
  44399. exponent: number;
  44400. private _projectionTextureMatrix;
  44401. /**
  44402. * Allows reading the projecton texture
  44403. */
  44404. readonly projectionTextureMatrix: Matrix;
  44405. protected _projectionTextureLightNear: number;
  44406. /**
  44407. * Gets the near clip of the Spotlight for texture projection.
  44408. */
  44409. /**
  44410. * Sets the near clip of the Spotlight for texture projection.
  44411. */
  44412. projectionTextureLightNear: number;
  44413. protected _projectionTextureLightFar: number;
  44414. /**
  44415. * Gets the far clip of the Spotlight for texture projection.
  44416. */
  44417. /**
  44418. * Sets the far clip of the Spotlight for texture projection.
  44419. */
  44420. projectionTextureLightFar: number;
  44421. protected _projectionTextureUpDirection: Vector3;
  44422. /**
  44423. * Gets the Up vector of the Spotlight for texture projection.
  44424. */
  44425. /**
  44426. * Sets the Up vector of the Spotlight for texture projection.
  44427. */
  44428. projectionTextureUpDirection: Vector3;
  44429. private _projectionTexture;
  44430. /**
  44431. * Gets the projection texture of the light.
  44432. */
  44433. /**
  44434. * Sets the projection texture of the light.
  44435. */
  44436. projectionTexture: Nullable<BaseTexture>;
  44437. private _projectionTextureViewLightDirty;
  44438. private _projectionTextureProjectionLightDirty;
  44439. private _projectionTextureDirty;
  44440. private _projectionTextureViewTargetVector;
  44441. private _projectionTextureViewLightMatrix;
  44442. private _projectionTextureProjectionLightMatrix;
  44443. private _projectionTextureScalingMatrix;
  44444. /**
  44445. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  44446. * It can cast shadows.
  44447. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44448. * @param name The light friendly name
  44449. * @param position The position of the spot light in the scene
  44450. * @param direction The direction of the light in the scene
  44451. * @param angle The cone angle of the light in Radians
  44452. * @param exponent The light decay speed with the distance from the emission spot
  44453. * @param scene The scene the lights belongs to
  44454. */
  44455. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  44456. /**
  44457. * Returns the string "SpotLight".
  44458. * @returns the class name
  44459. */
  44460. getClassName(): string;
  44461. /**
  44462. * Returns the integer 2.
  44463. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44464. */
  44465. getTypeID(): number;
  44466. /**
  44467. * Overrides the direction setter to recompute the projection texture view light Matrix.
  44468. */
  44469. protected _setDirection(value: Vector3): void;
  44470. /**
  44471. * Overrides the position setter to recompute the projection texture view light Matrix.
  44472. */
  44473. protected _setPosition(value: Vector3): void;
  44474. /**
  44475. * 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.
  44476. * Returns the SpotLight.
  44477. */
  44478. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44479. protected _computeProjectionTextureViewLightMatrix(): void;
  44480. protected _computeProjectionTextureProjectionLightMatrix(): void;
  44481. /**
  44482. * Main function for light texture projection matrix computing.
  44483. */
  44484. protected _computeProjectionTextureMatrix(): void;
  44485. protected _buildUniformLayout(): void;
  44486. private _computeAngleValues;
  44487. /**
  44488. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  44489. * @param effect The effect to update
  44490. * @param lightIndex The index of the light in the effect to update
  44491. * @returns The spot light
  44492. */
  44493. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  44494. /**
  44495. * Disposes the light and the associated resources.
  44496. */
  44497. dispose(): void;
  44498. /**
  44499. * Prepares the list of defines specific to the light type.
  44500. * @param defines the list of defines
  44501. * @param lightIndex defines the index of the light for the effect
  44502. */
  44503. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44504. }
  44505. }
  44506. declare module "babylonjs/Gizmos/lightGizmo" {
  44507. import { Nullable } from "babylonjs/types";
  44508. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44509. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44510. import { Light } from "babylonjs/Lights/light";
  44511. /**
  44512. * Gizmo that enables viewing a light
  44513. */
  44514. export class LightGizmo extends Gizmo {
  44515. private _lightMesh;
  44516. private _material;
  44517. /**
  44518. * Creates a LightGizmo
  44519. * @param gizmoLayer The utility layer the gizmo will be added to
  44520. */
  44521. constructor(gizmoLayer?: UtilityLayerRenderer);
  44522. private _light;
  44523. /**
  44524. * The light that the gizmo is attached to
  44525. */
  44526. light: Nullable<Light>;
  44527. /**
  44528. * @hidden
  44529. * Updates the gizmo to match the attached mesh's position/rotation
  44530. */
  44531. protected _update(): void;
  44532. private static _Scale;
  44533. /**
  44534. * Creates the lines for a light mesh
  44535. */
  44536. private static _createLightLines;
  44537. private static _CreateHemisphericLightMesh;
  44538. private static _CreatePointLightMesh;
  44539. private static _CreateSpotLightMesh;
  44540. private static _CreateDirectionalLightMesh;
  44541. }
  44542. }
  44543. declare module "babylonjs/Gizmos/index" {
  44544. export * from "babylonjs/Gizmos/axisDragGizmo";
  44545. export * from "babylonjs/Gizmos/axisScaleGizmo";
  44546. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  44547. export * from "babylonjs/Gizmos/gizmo";
  44548. export * from "babylonjs/Gizmos/gizmoManager";
  44549. export * from "babylonjs/Gizmos/planeRotationGizmo";
  44550. export * from "babylonjs/Gizmos/positionGizmo";
  44551. export * from "babylonjs/Gizmos/rotationGizmo";
  44552. export * from "babylonjs/Gizmos/scaleGizmo";
  44553. export * from "babylonjs/Gizmos/lightGizmo";
  44554. }
  44555. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  44556. /** @hidden */
  44557. export var backgroundFragmentDeclaration: {
  44558. name: string;
  44559. shader: string;
  44560. };
  44561. }
  44562. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  44563. /** @hidden */
  44564. export var backgroundUboDeclaration: {
  44565. name: string;
  44566. shader: string;
  44567. };
  44568. }
  44569. declare module "babylonjs/Shaders/background.fragment" {
  44570. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  44571. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  44572. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  44573. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  44574. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44575. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44576. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44577. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  44578. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  44579. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  44580. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  44581. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  44582. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  44583. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  44584. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  44585. /** @hidden */
  44586. export var backgroundPixelShader: {
  44587. name: string;
  44588. shader: string;
  44589. };
  44590. }
  44591. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  44592. /** @hidden */
  44593. export var backgroundVertexDeclaration: {
  44594. name: string;
  44595. shader: string;
  44596. };
  44597. }
  44598. declare module "babylonjs/Shaders/background.vertex" {
  44599. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  44600. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  44601. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44602. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  44603. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  44604. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  44605. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  44606. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44607. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44608. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  44609. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  44610. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  44611. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  44612. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  44613. /** @hidden */
  44614. export var backgroundVertexShader: {
  44615. name: string;
  44616. shader: string;
  44617. };
  44618. }
  44619. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  44620. import { Nullable, int, float } from "babylonjs/types";
  44621. import { Scene } from "babylonjs/scene";
  44622. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  44623. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44624. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44625. import { Mesh } from "babylonjs/Meshes/mesh";
  44626. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  44627. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  44628. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44629. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44630. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  44631. import "babylonjs/Shaders/background.fragment";
  44632. import "babylonjs/Shaders/background.vertex";
  44633. /**
  44634. * Background material used to create an efficient environement around your scene.
  44635. */
  44636. export class BackgroundMaterial extends PushMaterial {
  44637. /**
  44638. * Standard reflectance value at parallel view angle.
  44639. */
  44640. static StandardReflectance0: number;
  44641. /**
  44642. * Standard reflectance value at grazing angle.
  44643. */
  44644. static StandardReflectance90: number;
  44645. protected _primaryColor: Color3;
  44646. /**
  44647. * Key light Color (multiply against the environement texture)
  44648. */
  44649. primaryColor: Color3;
  44650. protected __perceptualColor: Nullable<Color3>;
  44651. /**
  44652. * Experimental Internal Use Only.
  44653. *
  44654. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44655. * This acts as a helper to set the primary color to a more "human friendly" value.
  44656. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44657. * output color as close as possible from the chosen value.
  44658. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44659. * part of lighting setup.)
  44660. */
  44661. _perceptualColor: Nullable<Color3>;
  44662. protected _primaryColorShadowLevel: float;
  44663. /**
  44664. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44665. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44666. */
  44667. primaryColorShadowLevel: float;
  44668. protected _primaryColorHighlightLevel: float;
  44669. /**
  44670. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44671. * The primary color is used at the level chosen to define what the white area would look.
  44672. */
  44673. primaryColorHighlightLevel: float;
  44674. protected _reflectionTexture: Nullable<BaseTexture>;
  44675. /**
  44676. * Reflection Texture used in the material.
  44677. * Should be author in a specific way for the best result (refer to the documentation).
  44678. */
  44679. reflectionTexture: Nullable<BaseTexture>;
  44680. protected _reflectionBlur: float;
  44681. /**
  44682. * Reflection Texture level of blur.
  44683. *
  44684. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44685. * texture twice.
  44686. */
  44687. reflectionBlur: float;
  44688. protected _diffuseTexture: Nullable<BaseTexture>;
  44689. /**
  44690. * Diffuse Texture used in the material.
  44691. * Should be author in a specific way for the best result (refer to the documentation).
  44692. */
  44693. diffuseTexture: Nullable<BaseTexture>;
  44694. protected _shadowLights: Nullable<IShadowLight[]>;
  44695. /**
  44696. * Specify the list of lights casting shadow on the material.
  44697. * All scene shadow lights will be included if null.
  44698. */
  44699. shadowLights: Nullable<IShadowLight[]>;
  44700. protected _shadowLevel: float;
  44701. /**
  44702. * Helps adjusting the shadow to a softer level if required.
  44703. * 0 means black shadows and 1 means no shadows.
  44704. */
  44705. shadowLevel: float;
  44706. protected _sceneCenter: Vector3;
  44707. /**
  44708. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44709. * It is usually zero but might be interesting to modify according to your setup.
  44710. */
  44711. sceneCenter: Vector3;
  44712. protected _opacityFresnel: boolean;
  44713. /**
  44714. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44715. * This helps ensuring a nice transition when the camera goes under the ground.
  44716. */
  44717. opacityFresnel: boolean;
  44718. protected _reflectionFresnel: boolean;
  44719. /**
  44720. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44721. * This helps adding a mirror texture on the ground.
  44722. */
  44723. reflectionFresnel: boolean;
  44724. protected _reflectionFalloffDistance: number;
  44725. /**
  44726. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44727. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44728. */
  44729. reflectionFalloffDistance: number;
  44730. protected _reflectionAmount: number;
  44731. /**
  44732. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44733. */
  44734. reflectionAmount: number;
  44735. protected _reflectionReflectance0: number;
  44736. /**
  44737. * This specifies the weight of the reflection at grazing angle.
  44738. */
  44739. reflectionReflectance0: number;
  44740. protected _reflectionReflectance90: number;
  44741. /**
  44742. * This specifies the weight of the reflection at a perpendicular point of view.
  44743. */
  44744. reflectionReflectance90: number;
  44745. /**
  44746. * Sets the reflection reflectance fresnel values according to the default standard
  44747. * empirically know to work well :-)
  44748. */
  44749. reflectionStandardFresnelWeight: number;
  44750. protected _useRGBColor: boolean;
  44751. /**
  44752. * Helps to directly use the maps channels instead of their level.
  44753. */
  44754. useRGBColor: boolean;
  44755. protected _enableNoise: boolean;
  44756. /**
  44757. * This helps reducing the banding effect that could occur on the background.
  44758. */
  44759. enableNoise: boolean;
  44760. /**
  44761. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44762. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44763. * Recommended to be keep at 1.0 except for special cases.
  44764. */
  44765. fovMultiplier: number;
  44766. private _fovMultiplier;
  44767. /**
  44768. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44769. */
  44770. useEquirectangularFOV: boolean;
  44771. private _maxSimultaneousLights;
  44772. /**
  44773. * Number of Simultaneous lights allowed on the material.
  44774. */
  44775. maxSimultaneousLights: int;
  44776. /**
  44777. * Default configuration related to image processing available in the Background Material.
  44778. */
  44779. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44780. /**
  44781. * Keep track of the image processing observer to allow dispose and replace.
  44782. */
  44783. private _imageProcessingObserver;
  44784. /**
  44785. * Attaches a new image processing configuration to the PBR Material.
  44786. * @param configuration (if null the scene configuration will be use)
  44787. */
  44788. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44789. /**
  44790. * Gets the image processing configuration used either in this material.
  44791. */
  44792. /**
  44793. * Sets the Default image processing configuration used either in the this material.
  44794. *
  44795. * If sets to null, the scene one is in use.
  44796. */
  44797. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44798. /**
  44799. * Gets wether the color curves effect is enabled.
  44800. */
  44801. /**
  44802. * Sets wether the color curves effect is enabled.
  44803. */
  44804. cameraColorCurvesEnabled: boolean;
  44805. /**
  44806. * Gets wether the color grading effect is enabled.
  44807. */
  44808. /**
  44809. * Gets wether the color grading effect is enabled.
  44810. */
  44811. cameraColorGradingEnabled: boolean;
  44812. /**
  44813. * Gets wether tonemapping is enabled or not.
  44814. */
  44815. /**
  44816. * Sets wether tonemapping is enabled or not
  44817. */
  44818. cameraToneMappingEnabled: boolean;
  44819. /**
  44820. * The camera exposure used on this material.
  44821. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44822. * This corresponds to a photographic exposure.
  44823. */
  44824. /**
  44825. * The camera exposure used on this material.
  44826. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44827. * This corresponds to a photographic exposure.
  44828. */
  44829. cameraExposure: float;
  44830. /**
  44831. * Gets The camera contrast used on this material.
  44832. */
  44833. /**
  44834. * Sets The camera contrast used on this material.
  44835. */
  44836. cameraContrast: float;
  44837. /**
  44838. * Gets the Color Grading 2D Lookup Texture.
  44839. */
  44840. /**
  44841. * Sets the Color Grading 2D Lookup Texture.
  44842. */
  44843. cameraColorGradingTexture: Nullable<BaseTexture>;
  44844. /**
  44845. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44846. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44847. * 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;
  44848. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44849. */
  44850. /**
  44851. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44852. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44853. * 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;
  44854. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44855. */
  44856. cameraColorCurves: Nullable<ColorCurves>;
  44857. /**
  44858. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  44859. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  44860. */
  44861. switchToBGR: boolean;
  44862. private _renderTargets;
  44863. private _reflectionControls;
  44864. private _white;
  44865. private _primaryShadowColor;
  44866. private _primaryHighlightColor;
  44867. /**
  44868. * Instantiates a Background Material in the given scene
  44869. * @param name The friendly name of the material
  44870. * @param scene The scene to add the material to
  44871. */
  44872. constructor(name: string, scene: Scene);
  44873. /**
  44874. * Gets a boolean indicating that current material needs to register RTT
  44875. */
  44876. readonly hasRenderTargetTextures: boolean;
  44877. /**
  44878. * The entire material has been created in order to prevent overdraw.
  44879. * @returns false
  44880. */
  44881. needAlphaTesting(): boolean;
  44882. /**
  44883. * The entire material has been created in order to prevent overdraw.
  44884. * @returns true if blending is enable
  44885. */
  44886. needAlphaBlending(): boolean;
  44887. /**
  44888. * Checks wether the material is ready to be rendered for a given mesh.
  44889. * @param mesh The mesh to render
  44890. * @param subMesh The submesh to check against
  44891. * @param useInstances Specify wether or not the material is used with instances
  44892. * @returns true if all the dependencies are ready (Textures, Effects...)
  44893. */
  44894. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44895. /**
  44896. * Compute the primary color according to the chosen perceptual color.
  44897. */
  44898. private _computePrimaryColorFromPerceptualColor;
  44899. /**
  44900. * Compute the highlights and shadow colors according to their chosen levels.
  44901. */
  44902. private _computePrimaryColors;
  44903. /**
  44904. * Build the uniform buffer used in the material.
  44905. */
  44906. buildUniformLayout(): void;
  44907. /**
  44908. * Unbind the material.
  44909. */
  44910. unbind(): void;
  44911. /**
  44912. * Bind only the world matrix to the material.
  44913. * @param world The world matrix to bind.
  44914. */
  44915. bindOnlyWorldMatrix(world: Matrix): void;
  44916. /**
  44917. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  44918. * @param world The world matrix to bind.
  44919. * @param subMesh The submesh to bind for.
  44920. */
  44921. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44922. /**
  44923. * Dispose the material.
  44924. * @param forceDisposeEffect Force disposal of the associated effect.
  44925. * @param forceDisposeTextures Force disposal of the associated textures.
  44926. */
  44927. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44928. /**
  44929. * Clones the material.
  44930. * @param name The cloned name.
  44931. * @returns The cloned material.
  44932. */
  44933. clone(name: string): BackgroundMaterial;
  44934. /**
  44935. * Serializes the current material to its JSON representation.
  44936. * @returns The JSON representation.
  44937. */
  44938. serialize(): any;
  44939. /**
  44940. * Gets the class name of the material
  44941. * @returns "BackgroundMaterial"
  44942. */
  44943. getClassName(): string;
  44944. /**
  44945. * Parse a JSON input to create back a background material.
  44946. * @param source The JSON data to parse
  44947. * @param scene The scene to create the parsed material in
  44948. * @param rootUrl The root url of the assets the material depends upon
  44949. * @returns the instantiated BackgroundMaterial.
  44950. */
  44951. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  44952. }
  44953. }
  44954. declare module "babylonjs/Helpers/environmentHelper" {
  44955. import { Observable } from "babylonjs/Misc/observable";
  44956. import { Nullable } from "babylonjs/types";
  44957. import { Scene } from "babylonjs/scene";
  44958. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44959. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44960. import { Mesh } from "babylonjs/Meshes/mesh";
  44961. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44962. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  44963. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  44964. import "babylonjs/Meshes/Builders/planeBuilder";
  44965. import "babylonjs/Meshes/Builders/boxBuilder";
  44966. /**
  44967. * Represents the different options available during the creation of
  44968. * a Environment helper.
  44969. *
  44970. * This can control the default ground, skybox and image processing setup of your scene.
  44971. */
  44972. export interface IEnvironmentHelperOptions {
  44973. /**
  44974. * Specifies wether or not to create a ground.
  44975. * True by default.
  44976. */
  44977. createGround: boolean;
  44978. /**
  44979. * Specifies the ground size.
  44980. * 15 by default.
  44981. */
  44982. groundSize: number;
  44983. /**
  44984. * The texture used on the ground for the main color.
  44985. * Comes from the BabylonJS CDN by default.
  44986. *
  44987. * Remarks: Can be either a texture or a url.
  44988. */
  44989. groundTexture: string | BaseTexture;
  44990. /**
  44991. * The color mixed in the ground texture by default.
  44992. * BabylonJS clearColor by default.
  44993. */
  44994. groundColor: Color3;
  44995. /**
  44996. * Specifies the ground opacity.
  44997. * 1 by default.
  44998. */
  44999. groundOpacity: number;
  45000. /**
  45001. * Enables the ground to receive shadows.
  45002. * True by default.
  45003. */
  45004. enableGroundShadow: boolean;
  45005. /**
  45006. * Helps preventing the shadow to be fully black on the ground.
  45007. * 0.5 by default.
  45008. */
  45009. groundShadowLevel: number;
  45010. /**
  45011. * Creates a mirror texture attach to the ground.
  45012. * false by default.
  45013. */
  45014. enableGroundMirror: boolean;
  45015. /**
  45016. * Specifies the ground mirror size ratio.
  45017. * 0.3 by default as the default kernel is 64.
  45018. */
  45019. groundMirrorSizeRatio: number;
  45020. /**
  45021. * Specifies the ground mirror blur kernel size.
  45022. * 64 by default.
  45023. */
  45024. groundMirrorBlurKernel: number;
  45025. /**
  45026. * Specifies the ground mirror visibility amount.
  45027. * 1 by default
  45028. */
  45029. groundMirrorAmount: number;
  45030. /**
  45031. * Specifies the ground mirror reflectance weight.
  45032. * This uses the standard weight of the background material to setup the fresnel effect
  45033. * of the mirror.
  45034. * 1 by default.
  45035. */
  45036. groundMirrorFresnelWeight: number;
  45037. /**
  45038. * Specifies the ground mirror Falloff distance.
  45039. * This can helps reducing the size of the reflection.
  45040. * 0 by Default.
  45041. */
  45042. groundMirrorFallOffDistance: number;
  45043. /**
  45044. * Specifies the ground mirror texture type.
  45045. * Unsigned Int by Default.
  45046. */
  45047. groundMirrorTextureType: number;
  45048. /**
  45049. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  45050. * the shown objects.
  45051. */
  45052. groundYBias: number;
  45053. /**
  45054. * Specifies wether or not to create a skybox.
  45055. * True by default.
  45056. */
  45057. createSkybox: boolean;
  45058. /**
  45059. * Specifies the skybox size.
  45060. * 20 by default.
  45061. */
  45062. skyboxSize: number;
  45063. /**
  45064. * The texture used on the skybox for the main color.
  45065. * Comes from the BabylonJS CDN by default.
  45066. *
  45067. * Remarks: Can be either a texture or a url.
  45068. */
  45069. skyboxTexture: string | BaseTexture;
  45070. /**
  45071. * The color mixed in the skybox texture by default.
  45072. * BabylonJS clearColor by default.
  45073. */
  45074. skyboxColor: Color3;
  45075. /**
  45076. * The background rotation around the Y axis of the scene.
  45077. * This helps aligning the key lights of your scene with the background.
  45078. * 0 by default.
  45079. */
  45080. backgroundYRotation: number;
  45081. /**
  45082. * Compute automatically the size of the elements to best fit with the scene.
  45083. */
  45084. sizeAuto: boolean;
  45085. /**
  45086. * Default position of the rootMesh if autoSize is not true.
  45087. */
  45088. rootPosition: Vector3;
  45089. /**
  45090. * Sets up the image processing in the scene.
  45091. * true by default.
  45092. */
  45093. setupImageProcessing: boolean;
  45094. /**
  45095. * The texture used as your environment texture in the scene.
  45096. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45097. *
  45098. * Remarks: Can be either a texture or a url.
  45099. */
  45100. environmentTexture: string | BaseTexture;
  45101. /**
  45102. * The value of the exposure to apply to the scene.
  45103. * 0.6 by default if setupImageProcessing is true.
  45104. */
  45105. cameraExposure: number;
  45106. /**
  45107. * The value of the contrast to apply to the scene.
  45108. * 1.6 by default if setupImageProcessing is true.
  45109. */
  45110. cameraContrast: number;
  45111. /**
  45112. * Specifies wether or not tonemapping should be enabled in the scene.
  45113. * true by default if setupImageProcessing is true.
  45114. */
  45115. toneMappingEnabled: boolean;
  45116. }
  45117. /**
  45118. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45119. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45120. * It also helps with the default setup of your imageProcessing configuration.
  45121. */
  45122. export class EnvironmentHelper {
  45123. /**
  45124. * Default ground texture URL.
  45125. */
  45126. private static _groundTextureCDNUrl;
  45127. /**
  45128. * Default skybox texture URL.
  45129. */
  45130. private static _skyboxTextureCDNUrl;
  45131. /**
  45132. * Default environment texture URL.
  45133. */
  45134. private static _environmentTextureCDNUrl;
  45135. /**
  45136. * Creates the default options for the helper.
  45137. */
  45138. private static _getDefaultOptions;
  45139. private _rootMesh;
  45140. /**
  45141. * Gets the root mesh created by the helper.
  45142. */
  45143. readonly rootMesh: Mesh;
  45144. private _skybox;
  45145. /**
  45146. * Gets the skybox created by the helper.
  45147. */
  45148. readonly skybox: Nullable<Mesh>;
  45149. private _skyboxTexture;
  45150. /**
  45151. * Gets the skybox texture created by the helper.
  45152. */
  45153. readonly skyboxTexture: Nullable<BaseTexture>;
  45154. private _skyboxMaterial;
  45155. /**
  45156. * Gets the skybox material created by the helper.
  45157. */
  45158. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  45159. private _ground;
  45160. /**
  45161. * Gets the ground mesh created by the helper.
  45162. */
  45163. readonly ground: Nullable<Mesh>;
  45164. private _groundTexture;
  45165. /**
  45166. * Gets the ground texture created by the helper.
  45167. */
  45168. readonly groundTexture: Nullable<BaseTexture>;
  45169. private _groundMirror;
  45170. /**
  45171. * Gets the ground mirror created by the helper.
  45172. */
  45173. readonly groundMirror: Nullable<MirrorTexture>;
  45174. /**
  45175. * Gets the ground mirror render list to helps pushing the meshes
  45176. * you wish in the ground reflection.
  45177. */
  45178. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  45179. private _groundMaterial;
  45180. /**
  45181. * Gets the ground material created by the helper.
  45182. */
  45183. readonly groundMaterial: Nullable<BackgroundMaterial>;
  45184. /**
  45185. * Stores the creation options.
  45186. */
  45187. private readonly _scene;
  45188. private _options;
  45189. /**
  45190. * This observable will be notified with any error during the creation of the environment,
  45191. * mainly texture creation errors.
  45192. */
  45193. onErrorObservable: Observable<{
  45194. message?: string;
  45195. exception?: any;
  45196. }>;
  45197. /**
  45198. * constructor
  45199. * @param options Defines the options we want to customize the helper
  45200. * @param scene The scene to add the material to
  45201. */
  45202. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  45203. /**
  45204. * Updates the background according to the new options
  45205. * @param options
  45206. */
  45207. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  45208. /**
  45209. * Sets the primary color of all the available elements.
  45210. * @param color the main color to affect to the ground and the background
  45211. */
  45212. setMainColor(color: Color3): void;
  45213. /**
  45214. * Setup the image processing according to the specified options.
  45215. */
  45216. private _setupImageProcessing;
  45217. /**
  45218. * Setup the environment texture according to the specified options.
  45219. */
  45220. private _setupEnvironmentTexture;
  45221. /**
  45222. * Setup the background according to the specified options.
  45223. */
  45224. private _setupBackground;
  45225. /**
  45226. * Get the scene sizes according to the setup.
  45227. */
  45228. private _getSceneSize;
  45229. /**
  45230. * Setup the ground according to the specified options.
  45231. */
  45232. private _setupGround;
  45233. /**
  45234. * Setup the ground material according to the specified options.
  45235. */
  45236. private _setupGroundMaterial;
  45237. /**
  45238. * Setup the ground diffuse texture according to the specified options.
  45239. */
  45240. private _setupGroundDiffuseTexture;
  45241. /**
  45242. * Setup the ground mirror texture according to the specified options.
  45243. */
  45244. private _setupGroundMirrorTexture;
  45245. /**
  45246. * Setup the ground to receive the mirror texture.
  45247. */
  45248. private _setupMirrorInGroundMaterial;
  45249. /**
  45250. * Setup the skybox according to the specified options.
  45251. */
  45252. private _setupSkybox;
  45253. /**
  45254. * Setup the skybox material according to the specified options.
  45255. */
  45256. private _setupSkyboxMaterial;
  45257. /**
  45258. * Setup the skybox reflection texture according to the specified options.
  45259. */
  45260. private _setupSkyboxReflectionTexture;
  45261. private _errorHandler;
  45262. /**
  45263. * Dispose all the elements created by the Helper.
  45264. */
  45265. dispose(): void;
  45266. }
  45267. }
  45268. declare module "babylonjs/Helpers/photoDome" {
  45269. import { Observable } from "babylonjs/Misc/observable";
  45270. import { Nullable } from "babylonjs/types";
  45271. import { Scene } from "babylonjs/scene";
  45272. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45273. import { Mesh } from "babylonjs/Meshes/mesh";
  45274. import { Texture } from "babylonjs/Materials/Textures/texture";
  45275. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45276. import "babylonjs/Meshes/Builders/sphereBuilder";
  45277. /**
  45278. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  45279. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  45280. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  45281. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45282. */
  45283. export class PhotoDome extends TransformNode {
  45284. private _useDirectMapping;
  45285. /**
  45286. * The texture being displayed on the sphere
  45287. */
  45288. protected _photoTexture: Texture;
  45289. /**
  45290. * Gets or sets the texture being displayed on the sphere
  45291. */
  45292. photoTexture: Texture;
  45293. /**
  45294. * Observable raised when an error occured while loading the 360 image
  45295. */
  45296. onLoadErrorObservable: Observable<string>;
  45297. /**
  45298. * The skybox material
  45299. */
  45300. protected _material: BackgroundMaterial;
  45301. /**
  45302. * The surface used for the skybox
  45303. */
  45304. protected _mesh: Mesh;
  45305. /**
  45306. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45307. * Also see the options.resolution property.
  45308. */
  45309. fovMultiplier: number;
  45310. /**
  45311. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  45312. * @param name Element's name, child elements will append suffixes for their own names.
  45313. * @param urlsOfPhoto defines the url of the photo to display
  45314. * @param options defines an object containing optional or exposed sub element properties
  45315. * @param onError defines a callback called when an error occured while loading the texture
  45316. */
  45317. constructor(name: string, urlOfPhoto: string, options: {
  45318. resolution?: number;
  45319. size?: number;
  45320. useDirectMapping?: boolean;
  45321. faceForward?: boolean;
  45322. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  45323. /**
  45324. * Releases resources associated with this node.
  45325. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45326. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45327. */
  45328. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45329. }
  45330. }
  45331. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  45332. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45333. /** @hidden */
  45334. export var rgbdDecodePixelShader: {
  45335. name: string;
  45336. shader: string;
  45337. };
  45338. }
  45339. declare module "babylonjs/Misc/brdfTextureTools" {
  45340. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45341. import { Scene } from "babylonjs/scene";
  45342. import "babylonjs/Shaders/rgbdDecode.fragment";
  45343. /**
  45344. * Class used to host texture specific utilities
  45345. */
  45346. export class BRDFTextureTools {
  45347. /**
  45348. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  45349. * @param texture the texture to expand.
  45350. */
  45351. private static _ExpandDefaultBRDFTexture;
  45352. /**
  45353. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  45354. * @param scene defines the hosting scene
  45355. * @returns the environment BRDF texture
  45356. */
  45357. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  45358. private static _environmentBRDFBase64Texture;
  45359. }
  45360. }
  45361. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  45362. import { Nullable } from "babylonjs/types";
  45363. import { IAnimatable } from "babylonjs/Misc/tools";
  45364. import { Color3 } from "babylonjs/Maths/math";
  45365. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45366. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45367. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45368. import { Engine } from "babylonjs/Engines/engine";
  45369. import { Scene } from "babylonjs/scene";
  45370. /**
  45371. * @hidden
  45372. */
  45373. export interface IMaterialClearCoatDefines {
  45374. CLEARCOAT: boolean;
  45375. CLEARCOAT_DEFAULTIOR: boolean;
  45376. CLEARCOAT_TEXTURE: boolean;
  45377. CLEARCOAT_TEXTUREDIRECTUV: number;
  45378. CLEARCOAT_BUMP: boolean;
  45379. CLEARCOAT_BUMPDIRECTUV: number;
  45380. CLEARCOAT_TINT: boolean;
  45381. CLEARCOAT_TINT_TEXTURE: boolean;
  45382. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45383. /** @hidden */
  45384. _areTexturesDirty: boolean;
  45385. }
  45386. /**
  45387. * Define the code related to the clear coat parameters of the pbr material.
  45388. */
  45389. export class PBRClearCoatConfiguration {
  45390. /**
  45391. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45392. * The default fits with a polyurethane material.
  45393. */
  45394. private static readonly _DefaultIndiceOfRefraction;
  45395. private _isEnabled;
  45396. /**
  45397. * Defines if the clear coat is enabled in the material.
  45398. */
  45399. isEnabled: boolean;
  45400. /**
  45401. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  45402. */
  45403. intensity: number;
  45404. /**
  45405. * Defines the clear coat layer roughness.
  45406. */
  45407. roughness: number;
  45408. private _indiceOfRefraction;
  45409. /**
  45410. * Defines the indice of refraction of the clear coat.
  45411. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45412. * The default fits with a polyurethane material.
  45413. * Changing the default value is more performance intensive.
  45414. */
  45415. indiceOfRefraction: number;
  45416. private _texture;
  45417. /**
  45418. * Stores the clear coat values in a texture.
  45419. */
  45420. texture: Nullable<BaseTexture>;
  45421. private _bumpTexture;
  45422. /**
  45423. * Define the clear coat specific bump texture.
  45424. */
  45425. bumpTexture: Nullable<BaseTexture>;
  45426. private _isTintEnabled;
  45427. /**
  45428. * Defines if the clear coat tint is enabled in the material.
  45429. */
  45430. isTintEnabled: boolean;
  45431. /**
  45432. * Defines the clear coat tint of the material.
  45433. * This is only use if tint is enabled
  45434. */
  45435. tintColor: Color3;
  45436. /**
  45437. * Defines the distance at which the tint color should be found in the
  45438. * clear coat media.
  45439. * This is only use if tint is enabled
  45440. */
  45441. tintColorAtDistance: number;
  45442. /**
  45443. * Defines the clear coat layer thickness.
  45444. * This is only use if tint is enabled
  45445. */
  45446. tintThickness: number;
  45447. private _tintTexture;
  45448. /**
  45449. * Stores the clear tint values in a texture.
  45450. * rgb is tint
  45451. * a is a thickness factor
  45452. */
  45453. tintTexture: Nullable<BaseTexture>;
  45454. /** @hidden */
  45455. private _internalMarkAllSubMeshesAsTexturesDirty;
  45456. /** @hidden */
  45457. _markAllSubMeshesAsTexturesDirty(): void;
  45458. /**
  45459. * Instantiate a new istance of clear coat configuration.
  45460. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45461. */
  45462. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45463. /**
  45464. * Gets wehter the submesh is ready to be used or not.
  45465. * @param defines the list of "defines" to update.
  45466. * @param scene defines the scene the material belongs to.
  45467. * @param engine defines the engine the material belongs to.
  45468. * @param disableBumpMap defines wether the material disables bump or not.
  45469. * @returns - boolean indicating that the submesh is ready or not.
  45470. */
  45471. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  45472. /**
  45473. * Checks to see if a texture is used in the material.
  45474. * @param defines the list of "defines" to update.
  45475. * @param scene defines the scene to the material belongs to.
  45476. */
  45477. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  45478. /**
  45479. * Binds the material data.
  45480. * @param uniformBuffer defines the Uniform buffer to fill in.
  45481. * @param scene defines the scene the material belongs to.
  45482. * @param engine defines the engine the material belongs to.
  45483. * @param disableBumpMap defines wether the material disables bump or not.
  45484. * @param isFrozen defines wether the material is frozen or not.
  45485. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45486. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45487. */
  45488. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  45489. /**
  45490. * Checks to see if a texture is used in the material.
  45491. * @param texture - Base texture to use.
  45492. * @returns - Boolean specifying if a texture is used in the material.
  45493. */
  45494. hasTexture(texture: BaseTexture): boolean;
  45495. /**
  45496. * Returns an array of the actively used textures.
  45497. * @param activeTextures Array of BaseTextures
  45498. */
  45499. getActiveTextures(activeTextures: BaseTexture[]): void;
  45500. /**
  45501. * Returns the animatable textures.
  45502. * @param animatables Array of animatable textures.
  45503. */
  45504. getAnimatables(animatables: IAnimatable[]): void;
  45505. /**
  45506. * Disposes the resources of the material.
  45507. * @param forceDisposeTextures - Forces the disposal of all textures.
  45508. */
  45509. dispose(forceDisposeTextures?: boolean): void;
  45510. /**
  45511. * Get the current class name of the texture useful for serialization or dynamic coding.
  45512. * @returns "PBRClearCoatConfiguration"
  45513. */
  45514. getClassName(): string;
  45515. /**
  45516. * Add fallbacks to the effect fallbacks list.
  45517. * @param defines defines the Base texture to use.
  45518. * @param fallbacks defines the current fallback list.
  45519. * @param currentRank defines the current fallback rank.
  45520. * @returns the new fallback rank.
  45521. */
  45522. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45523. /**
  45524. * Add the required uniforms to the current list.
  45525. * @param uniforms defines the current uniform list.
  45526. */
  45527. static AddUniforms(uniforms: string[]): void;
  45528. /**
  45529. * Add the required samplers to the current list.
  45530. * @param samplers defines the current sampler list.
  45531. */
  45532. static AddSamplers(samplers: string[]): void;
  45533. /**
  45534. * Add the required uniforms to the current buffer.
  45535. * @param uniformBuffer defines the current uniform buffer.
  45536. */
  45537. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45538. /**
  45539. * Makes a duplicate of the current configuration into another one.
  45540. * @param clearCoatConfiguration define the config where to copy the info
  45541. */
  45542. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  45543. /**
  45544. * Serializes this clear coat configuration.
  45545. * @returns - An object with the serialized config.
  45546. */
  45547. serialize(): any;
  45548. /**
  45549. * Parses a Clear Coat Configuration from a serialized object.
  45550. * @param source - Serialized object.
  45551. */
  45552. parse(source: any): void;
  45553. }
  45554. }
  45555. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  45556. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45557. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45558. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45559. import { Vector2 } from "babylonjs/Maths/math";
  45560. import { Scene } from "babylonjs/scene";
  45561. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45562. import { IAnimatable } from "babylonjs/Misc/tools";
  45563. import { Nullable } from "babylonjs/types";
  45564. /**
  45565. * @hidden
  45566. */
  45567. export interface IMaterialAnisotropicDefines {
  45568. ANISOTROPIC: boolean;
  45569. ANISOTROPIC_TEXTURE: boolean;
  45570. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45571. MAINUV1: boolean;
  45572. _areTexturesDirty: boolean;
  45573. _needUVs: boolean;
  45574. }
  45575. /**
  45576. * Define the code related to the anisotropic parameters of the pbr material.
  45577. */
  45578. export class PBRAnisotropicConfiguration {
  45579. private _isEnabled;
  45580. /**
  45581. * Defines if the anisotropy is enabled in the material.
  45582. */
  45583. isEnabled: boolean;
  45584. /**
  45585. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  45586. */
  45587. intensity: number;
  45588. /**
  45589. * Defines if the effect is along the tangents, bitangents or in between.
  45590. * By default, the effect is "strectching" the highlights along the tangents.
  45591. */
  45592. direction: Vector2;
  45593. private _texture;
  45594. /**
  45595. * Stores the anisotropy values in a texture.
  45596. * rg is direction (like normal from -1 to 1)
  45597. * b is a intensity
  45598. */
  45599. texture: Nullable<BaseTexture>;
  45600. /** @hidden */
  45601. private _internalMarkAllSubMeshesAsTexturesDirty;
  45602. /** @hidden */
  45603. _markAllSubMeshesAsTexturesDirty(): void;
  45604. /**
  45605. * Instantiate a new istance of anisotropy configuration.
  45606. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45607. */
  45608. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45609. /**
  45610. * Specifies that the submesh is ready to be used.
  45611. * @param defines the list of "defines" to update.
  45612. * @param scene defines the scene the material belongs to.
  45613. * @returns - boolean indicating that the submesh is ready or not.
  45614. */
  45615. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  45616. /**
  45617. * Checks to see if a texture is used in the material.
  45618. * @param defines the list of "defines" to update.
  45619. * @param mesh the mesh we are preparing the defines for.
  45620. * @param scene defines the scene the material belongs to.
  45621. */
  45622. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  45623. /**
  45624. * Binds the material data.
  45625. * @param uniformBuffer defines the Uniform buffer to fill in.
  45626. * @param scene defines the scene the material belongs to.
  45627. * @param isFrozen defines wether the material is frozen or not.
  45628. */
  45629. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45630. /**
  45631. * Checks to see if a texture is used in the material.
  45632. * @param texture - Base texture to use.
  45633. * @returns - Boolean specifying if a texture is used in the material.
  45634. */
  45635. hasTexture(texture: BaseTexture): boolean;
  45636. /**
  45637. * Returns an array of the actively used textures.
  45638. * @param activeTextures Array of BaseTextures
  45639. */
  45640. getActiveTextures(activeTextures: BaseTexture[]): void;
  45641. /**
  45642. * Returns the animatable textures.
  45643. * @param animatables Array of animatable textures.
  45644. */
  45645. getAnimatables(animatables: IAnimatable[]): void;
  45646. /**
  45647. * Disposes the resources of the material.
  45648. * @param forceDisposeTextures - Forces the disposal of all textures.
  45649. */
  45650. dispose(forceDisposeTextures?: boolean): void;
  45651. /**
  45652. * Get the current class name of the texture useful for serialization or dynamic coding.
  45653. * @returns "PBRAnisotropicConfiguration"
  45654. */
  45655. getClassName(): string;
  45656. /**
  45657. * Add fallbacks to the effect fallbacks list.
  45658. * @param defines defines the Base texture to use.
  45659. * @param fallbacks defines the current fallback list.
  45660. * @param currentRank defines the current fallback rank.
  45661. * @returns the new fallback rank.
  45662. */
  45663. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45664. /**
  45665. * Add the required uniforms to the current list.
  45666. * @param uniforms defines the current uniform list.
  45667. */
  45668. static AddUniforms(uniforms: string[]): void;
  45669. /**
  45670. * Add the required uniforms to the current buffer.
  45671. * @param uniformBuffer defines the current uniform buffer.
  45672. */
  45673. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45674. /**
  45675. * Add the required samplers to the current list.
  45676. * @param samplers defines the current sampler list.
  45677. */
  45678. static AddSamplers(samplers: string[]): void;
  45679. /**
  45680. * Makes a duplicate of the current configuration into another one.
  45681. * @param anisotropicConfiguration define the config where to copy the info
  45682. */
  45683. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  45684. /**
  45685. * Serializes this anisotropy configuration.
  45686. * @returns - An object with the serialized config.
  45687. */
  45688. serialize(): any;
  45689. /**
  45690. * Parses a anisotropy Configuration from a serialized object.
  45691. * @param source - Serialized object.
  45692. */
  45693. parse(source: any): void;
  45694. }
  45695. }
  45696. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  45697. /**
  45698. * @hidden
  45699. */
  45700. export interface IMaterialBRDFDefines {
  45701. BRDF_V_HEIGHT_CORRELATED: boolean;
  45702. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45703. /** @hidden */
  45704. _areMiscDirty: boolean;
  45705. }
  45706. /**
  45707. * Define the code related to the BRDF parameters of the pbr material.
  45708. */
  45709. export class PBRBRDFConfiguration {
  45710. /**
  45711. * Default value used for the energy conservation.
  45712. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45713. */
  45714. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  45715. /**
  45716. * Default value used for the Smith Visibility Height Correlated mode.
  45717. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45718. */
  45719. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  45720. private _useEnergyConservation;
  45721. /**
  45722. * Defines if the material uses energy conservation.
  45723. */
  45724. useEnergyConservation: boolean;
  45725. private _useSmithVisibilityHeightCorrelated;
  45726. /**
  45727. * LEGACY Mode set to false
  45728. * Defines if the material uses height smith correlated visibility term.
  45729. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  45730. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45731. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  45732. * Not relying on height correlated will also disable energy conservation.
  45733. */
  45734. useSmithVisibilityHeightCorrelated: boolean;
  45735. /** @hidden */
  45736. private _internalMarkAllSubMeshesAsMiscDirty;
  45737. /** @hidden */
  45738. _markAllSubMeshesAsMiscDirty(): void;
  45739. /**
  45740. * Instantiate a new istance of clear coat configuration.
  45741. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  45742. */
  45743. constructor(markAllSubMeshesAsMiscDirty: () => void);
  45744. /**
  45745. * Checks to see if a texture is used in the material.
  45746. * @param defines the list of "defines" to update.
  45747. */
  45748. prepareDefines(defines: IMaterialBRDFDefines): void;
  45749. /**
  45750. * Get the current class name of the texture useful for serialization or dynamic coding.
  45751. * @returns "PBRClearCoatConfiguration"
  45752. */
  45753. getClassName(): string;
  45754. /**
  45755. * Makes a duplicate of the current configuration into another one.
  45756. * @param brdfConfiguration define the config where to copy the info
  45757. */
  45758. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  45759. /**
  45760. * Serializes this BRDF configuration.
  45761. * @returns - An object with the serialized config.
  45762. */
  45763. serialize(): any;
  45764. /**
  45765. * Parses a BRDF Configuration from a serialized object.
  45766. * @param source - Serialized object.
  45767. */
  45768. parse(source: any): void;
  45769. }
  45770. }
  45771. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  45772. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45773. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45774. import { Color3 } from "babylonjs/Maths/math";
  45775. import { Scene } from "babylonjs/scene";
  45776. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45777. import { IAnimatable } from "babylonjs/Misc/tools";
  45778. import { Nullable } from "babylonjs/types";
  45779. /**
  45780. * @hidden
  45781. */
  45782. export interface IMaterialSheenDefines {
  45783. SHEEN: boolean;
  45784. SHEEN_TEXTURE: boolean;
  45785. SHEEN_TEXTUREDIRECTUV: number;
  45786. SHEEN_LINKWITHALBEDO: boolean;
  45787. /** @hidden */
  45788. _areTexturesDirty: boolean;
  45789. }
  45790. /**
  45791. * Define the code related to the Sheen parameters of the pbr material.
  45792. */
  45793. export class PBRSheenConfiguration {
  45794. private _isEnabled;
  45795. /**
  45796. * Defines if the material uses sheen.
  45797. */
  45798. isEnabled: boolean;
  45799. private _linkSheenWithAlbedo;
  45800. /**
  45801. * Defines if the sheen is linked to the sheen color.
  45802. */
  45803. linkSheenWithAlbedo: boolean;
  45804. /**
  45805. * Defines the sheen intensity.
  45806. */
  45807. intensity: number;
  45808. /**
  45809. * Defines the sheen color.
  45810. */
  45811. color: Color3;
  45812. private _texture;
  45813. /**
  45814. * Stores the sheen tint values in a texture.
  45815. * rgb is tint
  45816. * a is a intensity
  45817. */
  45818. texture: Nullable<BaseTexture>;
  45819. /** @hidden */
  45820. private _internalMarkAllSubMeshesAsTexturesDirty;
  45821. /** @hidden */
  45822. _markAllSubMeshesAsTexturesDirty(): void;
  45823. /**
  45824. * Instantiate a new istance of clear coat configuration.
  45825. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45826. */
  45827. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45828. /**
  45829. * Specifies that the submesh is ready to be used.
  45830. * @param defines the list of "defines" to update.
  45831. * @param scene defines the scene the material belongs to.
  45832. * @returns - boolean indicating that the submesh is ready or not.
  45833. */
  45834. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  45835. /**
  45836. * Checks to see if a texture is used in the material.
  45837. * @param defines the list of "defines" to update.
  45838. * @param scene defines the scene the material belongs to.
  45839. */
  45840. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  45841. /**
  45842. * Binds the material data.
  45843. * @param uniformBuffer defines the Uniform buffer to fill in.
  45844. * @param scene defines the scene the material belongs to.
  45845. * @param isFrozen defines wether the material is frozen or not.
  45846. */
  45847. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45848. /**
  45849. * Checks to see if a texture is used in the material.
  45850. * @param texture - Base texture to use.
  45851. * @returns - Boolean specifying if a texture is used in the material.
  45852. */
  45853. hasTexture(texture: BaseTexture): boolean;
  45854. /**
  45855. * Returns an array of the actively used textures.
  45856. * @param activeTextures Array of BaseTextures
  45857. */
  45858. getActiveTextures(activeTextures: BaseTexture[]): void;
  45859. /**
  45860. * Returns the animatable textures.
  45861. * @param animatables Array of animatable textures.
  45862. */
  45863. getAnimatables(animatables: IAnimatable[]): void;
  45864. /**
  45865. * Disposes the resources of the material.
  45866. * @param forceDisposeTextures - Forces the disposal of all textures.
  45867. */
  45868. dispose(forceDisposeTextures?: boolean): void;
  45869. /**
  45870. * Get the current class name of the texture useful for serialization or dynamic coding.
  45871. * @returns "PBRSheenConfiguration"
  45872. */
  45873. getClassName(): string;
  45874. /**
  45875. * Add fallbacks to the effect fallbacks list.
  45876. * @param defines defines the Base texture to use.
  45877. * @param fallbacks defines the current fallback list.
  45878. * @param currentRank defines the current fallback rank.
  45879. * @returns the new fallback rank.
  45880. */
  45881. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45882. /**
  45883. * Add the required uniforms to the current list.
  45884. * @param uniforms defines the current uniform list.
  45885. */
  45886. static AddUniforms(uniforms: string[]): void;
  45887. /**
  45888. * Add the required uniforms to the current buffer.
  45889. * @param uniformBuffer defines the current uniform buffer.
  45890. */
  45891. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45892. /**
  45893. * Add the required samplers to the current list.
  45894. * @param samplers defines the current sampler list.
  45895. */
  45896. static AddSamplers(samplers: string[]): void;
  45897. /**
  45898. * Makes a duplicate of the current configuration into another one.
  45899. * @param sheenConfiguration define the config where to copy the info
  45900. */
  45901. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  45902. /**
  45903. * Serializes this BRDF configuration.
  45904. * @returns - An object with the serialized config.
  45905. */
  45906. serialize(): any;
  45907. /**
  45908. * Parses a Sheen Configuration from a serialized object.
  45909. * @param source - Serialized object.
  45910. */
  45911. parse(source: any): void;
  45912. }
  45913. }
  45914. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  45915. import { Nullable } from "babylonjs/types";
  45916. import { IAnimatable } from "babylonjs/Misc/tools";
  45917. import { Color3 } from "babylonjs/Maths/math";
  45918. import { SmartArray } from "babylonjs/Misc/smartArray";
  45919. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45920. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45921. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  45922. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45923. import { Engine } from "babylonjs/Engines/engine";
  45924. import { Scene } from "babylonjs/scene";
  45925. /**
  45926. * @hidden
  45927. */
  45928. export interface IMaterialSubSurfaceDefines {
  45929. SUBSURFACE: boolean;
  45930. SS_REFRACTION: boolean;
  45931. SS_TRANSLUCENCY: boolean;
  45932. SS_SCATERRING: boolean;
  45933. SS_THICKNESSANDMASK_TEXTURE: boolean;
  45934. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  45935. SS_REFRACTIONMAP_3D: boolean;
  45936. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  45937. SS_LODINREFRACTIONALPHA: boolean;
  45938. SS_GAMMAREFRACTION: boolean;
  45939. SS_RGBDREFRACTION: boolean;
  45940. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  45941. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  45942. /** @hidden */
  45943. _areTexturesDirty: boolean;
  45944. }
  45945. /**
  45946. * Define the code related to the sub surface parameters of the pbr material.
  45947. */
  45948. export class PBRSubSurfaceConfiguration {
  45949. private _isRefractionEnabled;
  45950. /**
  45951. * Defines if the refraction is enabled in the material.
  45952. */
  45953. isRefractionEnabled: boolean;
  45954. private _isTranslucencyEnabled;
  45955. /**
  45956. * Defines if the translucency is enabled in the material.
  45957. */
  45958. isTranslucencyEnabled: boolean;
  45959. private _isScatteringEnabled;
  45960. /**
  45961. * Defines the refraction intensity of the material.
  45962. * The refraction when enabled replaces the Diffuse part of the material.
  45963. * The intensity helps transitionning between diffuse and refraction.
  45964. */
  45965. refractionIntensity: number;
  45966. /**
  45967. * Defines the translucency intensity of the material.
  45968. * When translucency has been enabled, this defines how much of the "translucency"
  45969. * is addded to the diffuse part of the material.
  45970. */
  45971. translucencyIntensity: number;
  45972. /**
  45973. * Defines the scattering intensity of the material.
  45974. * When scattering has been enabled, this defines how much of the "scattered light"
  45975. * is addded to the diffuse part of the material.
  45976. */
  45977. scatteringIntensity: number;
  45978. private _thicknessTexture;
  45979. /**
  45980. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  45981. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  45982. * 0 would mean minimumThickness
  45983. * 1 would mean maximumThickness
  45984. * The other channels might be use as a mask to vary the different effects intensity.
  45985. */
  45986. thicknessTexture: Nullable<BaseTexture>;
  45987. private _refractionTexture;
  45988. /**
  45989. * Defines the texture to use for refraction.
  45990. */
  45991. refractionTexture: Nullable<BaseTexture>;
  45992. private _indexOfRefraction;
  45993. /**
  45994. * Defines the indice of refraction used in the material.
  45995. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  45996. */
  45997. indexOfRefraction: number;
  45998. private _invertRefractionY;
  45999. /**
  46000. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46001. */
  46002. invertRefractionY: boolean;
  46003. private _linkRefractionWithTransparency;
  46004. /**
  46005. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46006. * Materials half opaque for instance using refraction could benefit from this control.
  46007. */
  46008. linkRefractionWithTransparency: boolean;
  46009. /**
  46010. * Defines the minimum thickness stored in the thickness map.
  46011. * If no thickness map is defined, this value will be used to simulate thickness.
  46012. */
  46013. minimumThickness: number;
  46014. /**
  46015. * Defines the maximum thickness stored in the thickness map.
  46016. */
  46017. maximumThickness: number;
  46018. /**
  46019. * Defines the volume tint of the material.
  46020. * This is used for both translucency and scattering.
  46021. */
  46022. tintColor: Color3;
  46023. /**
  46024. * Defines the distance at which the tint color should be found in the media.
  46025. * This is used for refraction only.
  46026. */
  46027. tintColorAtDistance: number;
  46028. /**
  46029. * Defines how far each channel transmit through the media.
  46030. * It is defined as a color to simplify it selection.
  46031. */
  46032. diffusionDistance: Color3;
  46033. private _useMaskFromThicknessTexture;
  46034. /**
  46035. * Stores the intensity of the different subsurface effects in the thickness texture.
  46036. * * the green channel is the translucency intensity.
  46037. * * the blue channel is the scattering intensity.
  46038. * * the alpha channel is the refraction intensity.
  46039. */
  46040. useMaskFromThicknessTexture: boolean;
  46041. /** @hidden */
  46042. private _internalMarkAllSubMeshesAsTexturesDirty;
  46043. /** @hidden */
  46044. _markAllSubMeshesAsTexturesDirty(): void;
  46045. /**
  46046. * Instantiate a new istance of sub surface configuration.
  46047. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46048. */
  46049. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46050. /**
  46051. * Gets wehter the submesh is ready to be used or not.
  46052. * @param defines the list of "defines" to update.
  46053. * @param scene defines the scene the material belongs to.
  46054. * @returns - boolean indicating that the submesh is ready or not.
  46055. */
  46056. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  46057. /**
  46058. * Checks to see if a texture is used in the material.
  46059. * @param defines the list of "defines" to update.
  46060. * @param scene defines the scene to the material belongs to.
  46061. */
  46062. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  46063. /**
  46064. * Binds the material data.
  46065. * @param uniformBuffer defines the Uniform buffer to fill in.
  46066. * @param scene defines the scene the material belongs to.
  46067. * @param engine defines the engine the material belongs to.
  46068. * @param isFrozen defines wether the material is frozen or not.
  46069. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  46070. */
  46071. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  46072. /**
  46073. * Unbinds the material from the mesh.
  46074. * @param activeEffect defines the effect that should be unbound from.
  46075. * @returns true if unbound, otherwise false
  46076. */
  46077. unbind(activeEffect: Effect): boolean;
  46078. /**
  46079. * Returns the texture used for refraction or null if none is used.
  46080. * @param scene defines the scene the material belongs to.
  46081. * @returns - Refraction texture if present. If no refraction texture and refraction
  46082. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46083. */
  46084. private _getRefractionTexture;
  46085. /**
  46086. * Returns true if alpha blending should be disabled.
  46087. */
  46088. readonly disableAlphaBlending: boolean;
  46089. /**
  46090. * Fills the list of render target textures.
  46091. * @param renderTargets the list of render targets to update
  46092. */
  46093. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  46094. /**
  46095. * Checks to see if a texture is used in the material.
  46096. * @param texture - Base texture to use.
  46097. * @returns - Boolean specifying if a texture is used in the material.
  46098. */
  46099. hasTexture(texture: BaseTexture): boolean;
  46100. /**
  46101. * Gets a boolean indicating that current material needs to register RTT
  46102. * @returns true if this uses a render target otherwise false.
  46103. */
  46104. hasRenderTargetTextures(): boolean;
  46105. /**
  46106. * Returns an array of the actively used textures.
  46107. * @param activeTextures Array of BaseTextures
  46108. */
  46109. getActiveTextures(activeTextures: BaseTexture[]): void;
  46110. /**
  46111. * Returns the animatable textures.
  46112. * @param animatables Array of animatable textures.
  46113. */
  46114. getAnimatables(animatables: IAnimatable[]): void;
  46115. /**
  46116. * Disposes the resources of the material.
  46117. * @param forceDisposeTextures - Forces the disposal of all textures.
  46118. */
  46119. dispose(forceDisposeTextures?: boolean): void;
  46120. /**
  46121. * Get the current class name of the texture useful for serialization or dynamic coding.
  46122. * @returns "PBRSubSurfaceConfiguration"
  46123. */
  46124. getClassName(): string;
  46125. /**
  46126. * Add fallbacks to the effect fallbacks list.
  46127. * @param defines defines the Base texture to use.
  46128. * @param fallbacks defines the current fallback list.
  46129. * @param currentRank defines the current fallback rank.
  46130. * @returns the new fallback rank.
  46131. */
  46132. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46133. /**
  46134. * Add the required uniforms to the current list.
  46135. * @param uniforms defines the current uniform list.
  46136. */
  46137. static AddUniforms(uniforms: string[]): void;
  46138. /**
  46139. * Add the required samplers to the current list.
  46140. * @param samplers defines the current sampler list.
  46141. */
  46142. static AddSamplers(samplers: string[]): void;
  46143. /**
  46144. * Add the required uniforms to the current buffer.
  46145. * @param uniformBuffer defines the current uniform buffer.
  46146. */
  46147. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46148. /**
  46149. * Makes a duplicate of the current configuration into another one.
  46150. * @param configuration define the config where to copy the info
  46151. */
  46152. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  46153. /**
  46154. * Serializes this Sub Surface configuration.
  46155. * @returns - An object with the serialized config.
  46156. */
  46157. serialize(): any;
  46158. /**
  46159. * Parses a Sub Surface Configuration from a serialized object.
  46160. * @param source - Serialized object.
  46161. */
  46162. parse(source: any): void;
  46163. }
  46164. }
  46165. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  46166. /** @hidden */
  46167. export var pbrFragmentDeclaration: {
  46168. name: string;
  46169. shader: string;
  46170. };
  46171. }
  46172. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  46173. /** @hidden */
  46174. export var pbrUboDeclaration: {
  46175. name: string;
  46176. shader: string;
  46177. };
  46178. }
  46179. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  46180. /** @hidden */
  46181. export var pbrFragmentExtraDeclaration: {
  46182. name: string;
  46183. shader: string;
  46184. };
  46185. }
  46186. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  46187. /** @hidden */
  46188. export var pbrFragmentSamplersDeclaration: {
  46189. name: string;
  46190. shader: string;
  46191. };
  46192. }
  46193. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  46194. /** @hidden */
  46195. export var pbrHelperFunctions: {
  46196. name: string;
  46197. shader: string;
  46198. };
  46199. }
  46200. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  46201. /** @hidden */
  46202. export var harmonicsFunctions: {
  46203. name: string;
  46204. shader: string;
  46205. };
  46206. }
  46207. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  46208. /** @hidden */
  46209. export var pbrDirectLightingSetupFunctions: {
  46210. name: string;
  46211. shader: string;
  46212. };
  46213. }
  46214. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  46215. /** @hidden */
  46216. export var pbrDirectLightingFalloffFunctions: {
  46217. name: string;
  46218. shader: string;
  46219. };
  46220. }
  46221. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  46222. /** @hidden */
  46223. export var pbrBRDFFunctions: {
  46224. name: string;
  46225. shader: string;
  46226. };
  46227. }
  46228. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  46229. /** @hidden */
  46230. export var pbrDirectLightingFunctions: {
  46231. name: string;
  46232. shader: string;
  46233. };
  46234. }
  46235. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  46236. /** @hidden */
  46237. export var pbrIBLFunctions: {
  46238. name: string;
  46239. shader: string;
  46240. };
  46241. }
  46242. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  46243. /** @hidden */
  46244. export var pbrDebug: {
  46245. name: string;
  46246. shader: string;
  46247. };
  46248. }
  46249. declare module "babylonjs/Shaders/pbr.fragment" {
  46250. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  46251. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  46252. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  46253. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46254. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46255. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  46256. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  46257. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  46258. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  46259. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  46260. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46261. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  46262. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  46263. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  46264. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  46265. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  46266. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  46267. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  46268. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  46269. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  46270. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  46271. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  46272. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  46273. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  46274. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  46275. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  46276. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  46277. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  46278. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  46279. /** @hidden */
  46280. export var pbrPixelShader: {
  46281. name: string;
  46282. shader: string;
  46283. };
  46284. }
  46285. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  46286. /** @hidden */
  46287. export var pbrVertexDeclaration: {
  46288. name: string;
  46289. shader: string;
  46290. };
  46291. }
  46292. declare module "babylonjs/Shaders/pbr.vertex" {
  46293. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  46294. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  46295. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46296. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46297. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46298. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  46299. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  46300. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  46301. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  46302. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46303. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46304. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  46305. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  46306. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  46307. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  46308. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46309. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46310. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  46311. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  46312. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  46313. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  46314. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  46315. /** @hidden */
  46316. export var pbrVertexShader: {
  46317. name: string;
  46318. shader: string;
  46319. };
  46320. }
  46321. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  46322. import { IAnimatable } from "babylonjs/Misc/tools";
  46323. import { Nullable } from "babylonjs/types";
  46324. import { Scene } from "babylonjs/scene";
  46325. import { Matrix, Color3 } from "babylonjs/Maths/math";
  46326. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46327. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46328. import { Mesh } from "babylonjs/Meshes/mesh";
  46329. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  46330. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  46331. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  46332. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  46333. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  46334. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  46335. import { Material } from "babylonjs/Materials/material";
  46336. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  46337. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  46338. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46339. import "babylonjs/Shaders/pbr.fragment";
  46340. import "babylonjs/Shaders/pbr.vertex";
  46341. /**
  46342. * Manages the defines for the PBR Material.
  46343. * @hidden
  46344. */
  46345. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  46346. PBR: boolean;
  46347. MAINUV1: boolean;
  46348. MAINUV2: boolean;
  46349. UV1: boolean;
  46350. UV2: boolean;
  46351. ALBEDO: boolean;
  46352. ALBEDODIRECTUV: number;
  46353. VERTEXCOLOR: boolean;
  46354. AMBIENT: boolean;
  46355. AMBIENTDIRECTUV: number;
  46356. AMBIENTINGRAYSCALE: boolean;
  46357. OPACITY: boolean;
  46358. VERTEXALPHA: boolean;
  46359. OPACITYDIRECTUV: number;
  46360. OPACITYRGB: boolean;
  46361. ALPHATEST: boolean;
  46362. DEPTHPREPASS: boolean;
  46363. ALPHABLEND: boolean;
  46364. ALPHAFROMALBEDO: boolean;
  46365. ALPHATESTVALUE: string;
  46366. SPECULAROVERALPHA: boolean;
  46367. RADIANCEOVERALPHA: boolean;
  46368. ALPHAFRESNEL: boolean;
  46369. LINEARALPHAFRESNEL: boolean;
  46370. PREMULTIPLYALPHA: boolean;
  46371. EMISSIVE: boolean;
  46372. EMISSIVEDIRECTUV: number;
  46373. REFLECTIVITY: boolean;
  46374. REFLECTIVITYDIRECTUV: number;
  46375. SPECULARTERM: boolean;
  46376. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  46377. MICROSURFACEAUTOMATIC: boolean;
  46378. LODBASEDMICROSFURACE: boolean;
  46379. MICROSURFACEMAP: boolean;
  46380. MICROSURFACEMAPDIRECTUV: number;
  46381. METALLICWORKFLOW: boolean;
  46382. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  46383. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  46384. METALLNESSSTOREINMETALMAPBLUE: boolean;
  46385. AOSTOREINMETALMAPRED: boolean;
  46386. ENVIRONMENTBRDF: boolean;
  46387. ENVIRONMENTBRDF_RGBD: boolean;
  46388. NORMAL: boolean;
  46389. TANGENT: boolean;
  46390. BUMP: boolean;
  46391. BUMPDIRECTUV: number;
  46392. OBJECTSPACE_NORMALMAP: boolean;
  46393. PARALLAX: boolean;
  46394. PARALLAXOCCLUSION: boolean;
  46395. NORMALXYSCALE: boolean;
  46396. LIGHTMAP: boolean;
  46397. LIGHTMAPDIRECTUV: number;
  46398. USELIGHTMAPASSHADOWMAP: boolean;
  46399. GAMMALIGHTMAP: boolean;
  46400. REFLECTION: boolean;
  46401. REFLECTIONMAP_3D: boolean;
  46402. REFLECTIONMAP_SPHERICAL: boolean;
  46403. REFLECTIONMAP_PLANAR: boolean;
  46404. REFLECTIONMAP_CUBIC: boolean;
  46405. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  46406. REFLECTIONMAP_PROJECTION: boolean;
  46407. REFLECTIONMAP_SKYBOX: boolean;
  46408. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  46409. REFLECTIONMAP_EXPLICIT: boolean;
  46410. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  46411. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  46412. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  46413. INVERTCUBICMAP: boolean;
  46414. USESPHERICALFROMREFLECTIONMAP: boolean;
  46415. USESPHERICALINVERTEX: boolean;
  46416. REFLECTIONMAP_OPPOSITEZ: boolean;
  46417. LODINREFLECTIONALPHA: boolean;
  46418. GAMMAREFLECTION: boolean;
  46419. RGBDREFLECTION: boolean;
  46420. RADIANCEOCCLUSION: boolean;
  46421. HORIZONOCCLUSION: boolean;
  46422. INSTANCES: boolean;
  46423. NUM_BONE_INFLUENCERS: number;
  46424. BonesPerMesh: number;
  46425. BONETEXTURE: boolean;
  46426. NONUNIFORMSCALING: boolean;
  46427. MORPHTARGETS: boolean;
  46428. MORPHTARGETS_NORMAL: boolean;
  46429. MORPHTARGETS_TANGENT: boolean;
  46430. NUM_MORPH_INFLUENCERS: number;
  46431. IMAGEPROCESSING: boolean;
  46432. VIGNETTE: boolean;
  46433. VIGNETTEBLENDMODEMULTIPLY: boolean;
  46434. VIGNETTEBLENDMODEOPAQUE: boolean;
  46435. TONEMAPPING: boolean;
  46436. TONEMAPPING_ACES: boolean;
  46437. CONTRAST: boolean;
  46438. COLORCURVES: boolean;
  46439. COLORGRADING: boolean;
  46440. COLORGRADING3D: boolean;
  46441. SAMPLER3DGREENDEPTH: boolean;
  46442. SAMPLER3DBGRMAP: boolean;
  46443. IMAGEPROCESSINGPOSTPROCESS: boolean;
  46444. EXPOSURE: boolean;
  46445. MULTIVIEW: boolean;
  46446. USEPHYSICALLIGHTFALLOFF: boolean;
  46447. USEGLTFLIGHTFALLOFF: boolean;
  46448. TWOSIDEDLIGHTING: boolean;
  46449. SHADOWFLOAT: boolean;
  46450. CLIPPLANE: boolean;
  46451. CLIPPLANE2: boolean;
  46452. CLIPPLANE3: boolean;
  46453. CLIPPLANE4: boolean;
  46454. POINTSIZE: boolean;
  46455. FOG: boolean;
  46456. LOGARITHMICDEPTH: boolean;
  46457. FORCENORMALFORWARD: boolean;
  46458. SPECULARAA: boolean;
  46459. CLEARCOAT: boolean;
  46460. CLEARCOAT_DEFAULTIOR: boolean;
  46461. CLEARCOAT_TEXTURE: boolean;
  46462. CLEARCOAT_TEXTUREDIRECTUV: number;
  46463. CLEARCOAT_BUMP: boolean;
  46464. CLEARCOAT_BUMPDIRECTUV: number;
  46465. CLEARCOAT_TINT: boolean;
  46466. CLEARCOAT_TINT_TEXTURE: boolean;
  46467. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46468. ANISOTROPIC: boolean;
  46469. ANISOTROPIC_TEXTURE: boolean;
  46470. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46471. BRDF_V_HEIGHT_CORRELATED: boolean;
  46472. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46473. SHEEN: boolean;
  46474. SHEEN_TEXTURE: boolean;
  46475. SHEEN_TEXTUREDIRECTUV: number;
  46476. SHEEN_LINKWITHALBEDO: boolean;
  46477. SUBSURFACE: boolean;
  46478. SS_REFRACTION: boolean;
  46479. SS_TRANSLUCENCY: boolean;
  46480. SS_SCATERRING: boolean;
  46481. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46482. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46483. SS_REFRACTIONMAP_3D: boolean;
  46484. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46485. SS_LODINREFRACTIONALPHA: boolean;
  46486. SS_GAMMAREFRACTION: boolean;
  46487. SS_RGBDREFRACTION: boolean;
  46488. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46489. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46490. UNLIT: boolean;
  46491. DEBUGMODE: number;
  46492. /**
  46493. * Initializes the PBR Material defines.
  46494. */
  46495. constructor();
  46496. /**
  46497. * Resets the PBR Material defines.
  46498. */
  46499. reset(): void;
  46500. }
  46501. /**
  46502. * The Physically based material base class of BJS.
  46503. *
  46504. * This offers the main features of a standard PBR material.
  46505. * For more information, please refer to the documentation :
  46506. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  46507. */
  46508. export abstract class PBRBaseMaterial extends PushMaterial {
  46509. /**
  46510. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46511. */
  46512. static readonly PBRMATERIAL_OPAQUE: number;
  46513. /**
  46514. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46515. */
  46516. static readonly PBRMATERIAL_ALPHATEST: number;
  46517. /**
  46518. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46519. */
  46520. static readonly PBRMATERIAL_ALPHABLEND: number;
  46521. /**
  46522. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46523. * They are also discarded below the alpha cutoff threshold to improve performances.
  46524. */
  46525. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46526. /**
  46527. * Defines the default value of how much AO map is occluding the analytical lights
  46528. * (point spot...).
  46529. */
  46530. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46531. /**
  46532. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  46533. */
  46534. static readonly LIGHTFALLOFF_PHYSICAL: number;
  46535. /**
  46536. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  46537. * to enhance interoperability with other engines.
  46538. */
  46539. static readonly LIGHTFALLOFF_GLTF: number;
  46540. /**
  46541. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  46542. * to enhance interoperability with other materials.
  46543. */
  46544. static readonly LIGHTFALLOFF_STANDARD: number;
  46545. /**
  46546. * Intensity of the direct lights e.g. the four lights available in your scene.
  46547. * This impacts both the direct diffuse and specular highlights.
  46548. */
  46549. protected _directIntensity: number;
  46550. /**
  46551. * Intensity of the emissive part of the material.
  46552. * This helps controlling the emissive effect without modifying the emissive color.
  46553. */
  46554. protected _emissiveIntensity: number;
  46555. /**
  46556. * Intensity of the environment e.g. how much the environment will light the object
  46557. * either through harmonics for rough material or through the refelction for shiny ones.
  46558. */
  46559. protected _environmentIntensity: number;
  46560. /**
  46561. * This is a special control allowing the reduction of the specular highlights coming from the
  46562. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46563. */
  46564. protected _specularIntensity: number;
  46565. /**
  46566. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  46567. */
  46568. private _lightingInfos;
  46569. /**
  46570. * Debug Control allowing disabling the bump map on this material.
  46571. */
  46572. protected _disableBumpMap: boolean;
  46573. /**
  46574. * AKA Diffuse Texture in standard nomenclature.
  46575. */
  46576. protected _albedoTexture: BaseTexture;
  46577. /**
  46578. * AKA Occlusion Texture in other nomenclature.
  46579. */
  46580. protected _ambientTexture: BaseTexture;
  46581. /**
  46582. * AKA Occlusion Texture Intensity in other nomenclature.
  46583. */
  46584. protected _ambientTextureStrength: number;
  46585. /**
  46586. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46587. * 1 means it completely occludes it
  46588. * 0 mean it has no impact
  46589. */
  46590. protected _ambientTextureImpactOnAnalyticalLights: number;
  46591. /**
  46592. * Stores the alpha values in a texture.
  46593. */
  46594. protected _opacityTexture: BaseTexture;
  46595. /**
  46596. * Stores the reflection values in a texture.
  46597. */
  46598. protected _reflectionTexture: BaseTexture;
  46599. /**
  46600. * Stores the emissive values in a texture.
  46601. */
  46602. protected _emissiveTexture: BaseTexture;
  46603. /**
  46604. * AKA Specular texture in other nomenclature.
  46605. */
  46606. protected _reflectivityTexture: BaseTexture;
  46607. /**
  46608. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46609. */
  46610. protected _metallicTexture: BaseTexture;
  46611. /**
  46612. * Specifies the metallic scalar of the metallic/roughness workflow.
  46613. * Can also be used to scale the metalness values of the metallic texture.
  46614. */
  46615. protected _metallic: Nullable<number>;
  46616. /**
  46617. * Specifies the roughness scalar of the metallic/roughness workflow.
  46618. * Can also be used to scale the roughness values of the metallic texture.
  46619. */
  46620. protected _roughness: Nullable<number>;
  46621. /**
  46622. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46623. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46624. */
  46625. protected _microSurfaceTexture: BaseTexture;
  46626. /**
  46627. * Stores surface normal data used to displace a mesh in a texture.
  46628. */
  46629. protected _bumpTexture: BaseTexture;
  46630. /**
  46631. * Stores the pre-calculated light information of a mesh in a texture.
  46632. */
  46633. protected _lightmapTexture: BaseTexture;
  46634. /**
  46635. * The color of a material in ambient lighting.
  46636. */
  46637. protected _ambientColor: Color3;
  46638. /**
  46639. * AKA Diffuse Color in other nomenclature.
  46640. */
  46641. protected _albedoColor: Color3;
  46642. /**
  46643. * AKA Specular Color in other nomenclature.
  46644. */
  46645. protected _reflectivityColor: Color3;
  46646. /**
  46647. * The color applied when light is reflected from a material.
  46648. */
  46649. protected _reflectionColor: Color3;
  46650. /**
  46651. * The color applied when light is emitted from a material.
  46652. */
  46653. protected _emissiveColor: Color3;
  46654. /**
  46655. * AKA Glossiness in other nomenclature.
  46656. */
  46657. protected _microSurface: number;
  46658. /**
  46659. * Specifies that the material will use the light map as a show map.
  46660. */
  46661. protected _useLightmapAsShadowmap: boolean;
  46662. /**
  46663. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46664. * makes the reflect vector face the model (under horizon).
  46665. */
  46666. protected _useHorizonOcclusion: boolean;
  46667. /**
  46668. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46669. * too much the area relying on ambient texture to define their ambient occlusion.
  46670. */
  46671. protected _useRadianceOcclusion: boolean;
  46672. /**
  46673. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46674. */
  46675. protected _useAlphaFromAlbedoTexture: boolean;
  46676. /**
  46677. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  46678. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46679. */
  46680. protected _useSpecularOverAlpha: boolean;
  46681. /**
  46682. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46683. */
  46684. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46685. /**
  46686. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46687. */
  46688. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  46689. /**
  46690. * Specifies if the metallic texture contains the roughness information in its green channel.
  46691. */
  46692. protected _useRoughnessFromMetallicTextureGreen: boolean;
  46693. /**
  46694. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46695. */
  46696. protected _useMetallnessFromMetallicTextureBlue: boolean;
  46697. /**
  46698. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46699. */
  46700. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  46701. /**
  46702. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46703. */
  46704. protected _useAmbientInGrayScale: boolean;
  46705. /**
  46706. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46707. * The material will try to infer what glossiness each pixel should be.
  46708. */
  46709. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  46710. /**
  46711. * Defines the falloff type used in this material.
  46712. * It by default is Physical.
  46713. */
  46714. protected _lightFalloff: number;
  46715. /**
  46716. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46717. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46718. */
  46719. protected _useRadianceOverAlpha: boolean;
  46720. /**
  46721. * Allows using an object space normal map (instead of tangent space).
  46722. */
  46723. protected _useObjectSpaceNormalMap: boolean;
  46724. /**
  46725. * Allows using the bump map in parallax mode.
  46726. */
  46727. protected _useParallax: boolean;
  46728. /**
  46729. * Allows using the bump map in parallax occlusion mode.
  46730. */
  46731. protected _useParallaxOcclusion: boolean;
  46732. /**
  46733. * Controls the scale bias of the parallax mode.
  46734. */
  46735. protected _parallaxScaleBias: number;
  46736. /**
  46737. * If sets to true, disables all the lights affecting the material.
  46738. */
  46739. protected _disableLighting: boolean;
  46740. /**
  46741. * Number of Simultaneous lights allowed on the material.
  46742. */
  46743. protected _maxSimultaneousLights: number;
  46744. /**
  46745. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46746. */
  46747. protected _invertNormalMapX: boolean;
  46748. /**
  46749. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46750. */
  46751. protected _invertNormalMapY: boolean;
  46752. /**
  46753. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46754. */
  46755. protected _twoSidedLighting: boolean;
  46756. /**
  46757. * Defines the alpha limits in alpha test mode.
  46758. */
  46759. protected _alphaCutOff: number;
  46760. /**
  46761. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46762. */
  46763. protected _forceAlphaTest: boolean;
  46764. /**
  46765. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46766. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46767. */
  46768. protected _useAlphaFresnel: boolean;
  46769. /**
  46770. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46771. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46772. */
  46773. protected _useLinearAlphaFresnel: boolean;
  46774. /**
  46775. * The transparency mode of the material.
  46776. */
  46777. protected _transparencyMode: Nullable<number>;
  46778. /**
  46779. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  46780. * from cos thetav and roughness:
  46781. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  46782. */
  46783. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  46784. /**
  46785. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46786. */
  46787. protected _forceIrradianceInFragment: boolean;
  46788. /**
  46789. * Force normal to face away from face.
  46790. */
  46791. protected _forceNormalForward: boolean;
  46792. /**
  46793. * Enables specular anti aliasing in the PBR shader.
  46794. * It will both interacts on the Geometry for analytical and IBL lighting.
  46795. * It also prefilter the roughness map based on the bump values.
  46796. */
  46797. protected _enableSpecularAntiAliasing: boolean;
  46798. /**
  46799. * Default configuration related to image processing available in the PBR Material.
  46800. */
  46801. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46802. /**
  46803. * Keep track of the image processing observer to allow dispose and replace.
  46804. */
  46805. private _imageProcessingObserver;
  46806. /**
  46807. * Attaches a new image processing configuration to the PBR Material.
  46808. * @param configuration
  46809. */
  46810. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46811. /**
  46812. * Stores the available render targets.
  46813. */
  46814. private _renderTargets;
  46815. /**
  46816. * Sets the global ambient color for the material used in lighting calculations.
  46817. */
  46818. private _globalAmbientColor;
  46819. /**
  46820. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  46821. */
  46822. private _useLogarithmicDepth;
  46823. /**
  46824. * If set to true, no lighting calculations will be applied.
  46825. */
  46826. private _unlit;
  46827. private _debugMode;
  46828. /**
  46829. * @hidden
  46830. * This is reserved for the inspector.
  46831. * Defines the material debug mode.
  46832. * It helps seeing only some components of the material while troubleshooting.
  46833. */
  46834. debugMode: number;
  46835. /**
  46836. * @hidden
  46837. * This is reserved for the inspector.
  46838. * Specify from where on screen the debug mode should start.
  46839. * The value goes from -1 (full screen) to 1 (not visible)
  46840. * It helps with side by side comparison against the final render
  46841. * This defaults to -1
  46842. */
  46843. private debugLimit;
  46844. /**
  46845. * @hidden
  46846. * This is reserved for the inspector.
  46847. * As the default viewing range might not be enough (if the ambient is really small for instance)
  46848. * You can use the factor to better multiply the final value.
  46849. */
  46850. private debugFactor;
  46851. /**
  46852. * Defines the clear coat layer parameters for the material.
  46853. */
  46854. readonly clearCoat: PBRClearCoatConfiguration;
  46855. /**
  46856. * Defines the anisotropic parameters for the material.
  46857. */
  46858. readonly anisotropy: PBRAnisotropicConfiguration;
  46859. /**
  46860. * Defines the BRDF parameters for the material.
  46861. */
  46862. readonly brdf: PBRBRDFConfiguration;
  46863. /**
  46864. * Defines the Sheen parameters for the material.
  46865. */
  46866. readonly sheen: PBRSheenConfiguration;
  46867. /**
  46868. * Defines the SubSurface parameters for the material.
  46869. */
  46870. readonly subSurface: PBRSubSurfaceConfiguration;
  46871. /**
  46872. * Custom callback helping to override the default shader used in the material.
  46873. */
  46874. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  46875. /**
  46876. * Instantiates a new PBRMaterial instance.
  46877. *
  46878. * @param name The material name
  46879. * @param scene The scene the material will be use in.
  46880. */
  46881. constructor(name: string, scene: Scene);
  46882. /**
  46883. * Gets a boolean indicating that current material needs to register RTT
  46884. */
  46885. readonly hasRenderTargetTextures: boolean;
  46886. /**
  46887. * Gets the name of the material class.
  46888. */
  46889. getClassName(): string;
  46890. /**
  46891. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46892. */
  46893. /**
  46894. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46895. */
  46896. useLogarithmicDepth: boolean;
  46897. /**
  46898. * Gets the current transparency mode.
  46899. */
  46900. /**
  46901. * Sets the transparency mode of the material.
  46902. *
  46903. * | Value | Type | Description |
  46904. * | ----- | ----------------------------------- | ----------- |
  46905. * | 0 | OPAQUE | |
  46906. * | 1 | ALPHATEST | |
  46907. * | 2 | ALPHABLEND | |
  46908. * | 3 | ALPHATESTANDBLEND | |
  46909. *
  46910. */
  46911. transparencyMode: Nullable<number>;
  46912. /**
  46913. * Returns true if alpha blending should be disabled.
  46914. */
  46915. private readonly _disableAlphaBlending;
  46916. /**
  46917. * Specifies whether or not this material should be rendered in alpha blend mode.
  46918. */
  46919. needAlphaBlending(): boolean;
  46920. /**
  46921. * Specifies if the mesh will require alpha blending.
  46922. * @param mesh - BJS mesh.
  46923. */
  46924. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  46925. /**
  46926. * Specifies whether or not this material should be rendered in alpha test mode.
  46927. */
  46928. needAlphaTesting(): boolean;
  46929. /**
  46930. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  46931. */
  46932. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  46933. /**
  46934. * Gets the texture used for the alpha test.
  46935. */
  46936. getAlphaTestTexture(): BaseTexture;
  46937. /**
  46938. * Specifies that the submesh is ready to be used.
  46939. * @param mesh - BJS mesh.
  46940. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  46941. * @param useInstances - Specifies that instances should be used.
  46942. * @returns - boolean indicating that the submesh is ready or not.
  46943. */
  46944. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46945. /**
  46946. * Specifies if the material uses metallic roughness workflow.
  46947. * @returns boolean specifiying if the material uses metallic roughness workflow.
  46948. */
  46949. isMetallicWorkflow(): boolean;
  46950. private _prepareEffect;
  46951. private _prepareDefines;
  46952. /**
  46953. * Force shader compilation
  46954. */
  46955. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  46956. clipPlane: boolean;
  46957. }>): void;
  46958. /**
  46959. * Initializes the uniform buffer layout for the shader.
  46960. */
  46961. buildUniformLayout(): void;
  46962. /**
  46963. * Unbinds the material from the mesh
  46964. */
  46965. unbind(): void;
  46966. /**
  46967. * Binds the submesh data.
  46968. * @param world - The world matrix.
  46969. * @param mesh - The BJS mesh.
  46970. * @param subMesh - A submesh of the BJS mesh.
  46971. */
  46972. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46973. /**
  46974. * Returns the animatable textures.
  46975. * @returns - Array of animatable textures.
  46976. */
  46977. getAnimatables(): IAnimatable[];
  46978. /**
  46979. * Returns the texture used for reflections.
  46980. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  46981. */
  46982. private _getReflectionTexture;
  46983. /**
  46984. * Returns an array of the actively used textures.
  46985. * @returns - Array of BaseTextures
  46986. */
  46987. getActiveTextures(): BaseTexture[];
  46988. /**
  46989. * Checks to see if a texture is used in the material.
  46990. * @param texture - Base texture to use.
  46991. * @returns - Boolean specifying if a texture is used in the material.
  46992. */
  46993. hasTexture(texture: BaseTexture): boolean;
  46994. /**
  46995. * Disposes the resources of the material.
  46996. * @param forceDisposeEffect - Forces the disposal of effects.
  46997. * @param forceDisposeTextures - Forces the disposal of all textures.
  46998. */
  46999. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47000. }
  47001. }
  47002. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  47003. import { Nullable } from "babylonjs/types";
  47004. import { Scene } from "babylonjs/scene";
  47005. import { Color3 } from "babylonjs/Maths/math";
  47006. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47007. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47008. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47009. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  47010. /**
  47011. * The Physically based material of BJS.
  47012. *
  47013. * This offers the main features of a standard PBR material.
  47014. * For more information, please refer to the documentation :
  47015. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  47016. */
  47017. export class PBRMaterial extends PBRBaseMaterial {
  47018. /**
  47019. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47020. */
  47021. static readonly PBRMATERIAL_OPAQUE: number;
  47022. /**
  47023. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47024. */
  47025. static readonly PBRMATERIAL_ALPHATEST: number;
  47026. /**
  47027. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47028. */
  47029. static readonly PBRMATERIAL_ALPHABLEND: number;
  47030. /**
  47031. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47032. * They are also discarded below the alpha cutoff threshold to improve performances.
  47033. */
  47034. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47035. /**
  47036. * Defines the default value of how much AO map is occluding the analytical lights
  47037. * (point spot...).
  47038. */
  47039. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47040. /**
  47041. * Intensity of the direct lights e.g. the four lights available in your scene.
  47042. * This impacts both the direct diffuse and specular highlights.
  47043. */
  47044. directIntensity: number;
  47045. /**
  47046. * Intensity of the emissive part of the material.
  47047. * This helps controlling the emissive effect without modifying the emissive color.
  47048. */
  47049. emissiveIntensity: number;
  47050. /**
  47051. * Intensity of the environment e.g. how much the environment will light the object
  47052. * either through harmonics for rough material or through the refelction for shiny ones.
  47053. */
  47054. environmentIntensity: number;
  47055. /**
  47056. * This is a special control allowing the reduction of the specular highlights coming from the
  47057. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47058. */
  47059. specularIntensity: number;
  47060. /**
  47061. * Debug Control allowing disabling the bump map on this material.
  47062. */
  47063. disableBumpMap: boolean;
  47064. /**
  47065. * AKA Diffuse Texture in standard nomenclature.
  47066. */
  47067. albedoTexture: BaseTexture;
  47068. /**
  47069. * AKA Occlusion Texture in other nomenclature.
  47070. */
  47071. ambientTexture: BaseTexture;
  47072. /**
  47073. * AKA Occlusion Texture Intensity in other nomenclature.
  47074. */
  47075. ambientTextureStrength: number;
  47076. /**
  47077. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47078. * 1 means it completely occludes it
  47079. * 0 mean it has no impact
  47080. */
  47081. ambientTextureImpactOnAnalyticalLights: number;
  47082. /**
  47083. * Stores the alpha values in a texture.
  47084. */
  47085. opacityTexture: BaseTexture;
  47086. /**
  47087. * Stores the reflection values in a texture.
  47088. */
  47089. reflectionTexture: Nullable<BaseTexture>;
  47090. /**
  47091. * Stores the emissive values in a texture.
  47092. */
  47093. emissiveTexture: BaseTexture;
  47094. /**
  47095. * AKA Specular texture in other nomenclature.
  47096. */
  47097. reflectivityTexture: BaseTexture;
  47098. /**
  47099. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47100. */
  47101. metallicTexture: BaseTexture;
  47102. /**
  47103. * Specifies the metallic scalar of the metallic/roughness workflow.
  47104. * Can also be used to scale the metalness values of the metallic texture.
  47105. */
  47106. metallic: Nullable<number>;
  47107. /**
  47108. * Specifies the roughness scalar of the metallic/roughness workflow.
  47109. * Can also be used to scale the roughness values of the metallic texture.
  47110. */
  47111. roughness: Nullable<number>;
  47112. /**
  47113. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47114. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47115. */
  47116. microSurfaceTexture: BaseTexture;
  47117. /**
  47118. * Stores surface normal data used to displace a mesh in a texture.
  47119. */
  47120. bumpTexture: BaseTexture;
  47121. /**
  47122. * Stores the pre-calculated light information of a mesh in a texture.
  47123. */
  47124. lightmapTexture: BaseTexture;
  47125. /**
  47126. * Stores the refracted light information in a texture.
  47127. */
  47128. refractionTexture: Nullable<BaseTexture>;
  47129. /**
  47130. * The color of a material in ambient lighting.
  47131. */
  47132. ambientColor: Color3;
  47133. /**
  47134. * AKA Diffuse Color in other nomenclature.
  47135. */
  47136. albedoColor: Color3;
  47137. /**
  47138. * AKA Specular Color in other nomenclature.
  47139. */
  47140. reflectivityColor: Color3;
  47141. /**
  47142. * The color reflected from the material.
  47143. */
  47144. reflectionColor: Color3;
  47145. /**
  47146. * The color emitted from the material.
  47147. */
  47148. emissiveColor: Color3;
  47149. /**
  47150. * AKA Glossiness in other nomenclature.
  47151. */
  47152. microSurface: number;
  47153. /**
  47154. * source material index of refraction (IOR)' / 'destination material IOR.
  47155. */
  47156. indexOfRefraction: number;
  47157. /**
  47158. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47159. */
  47160. invertRefractionY: boolean;
  47161. /**
  47162. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47163. * Materials half opaque for instance using refraction could benefit from this control.
  47164. */
  47165. linkRefractionWithTransparency: boolean;
  47166. /**
  47167. * If true, the light map contains occlusion information instead of lighting info.
  47168. */
  47169. useLightmapAsShadowmap: boolean;
  47170. /**
  47171. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47172. */
  47173. useAlphaFromAlbedoTexture: boolean;
  47174. /**
  47175. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47176. */
  47177. forceAlphaTest: boolean;
  47178. /**
  47179. * Defines the alpha limits in alpha test mode.
  47180. */
  47181. alphaCutOff: number;
  47182. /**
  47183. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  47184. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47185. */
  47186. useSpecularOverAlpha: boolean;
  47187. /**
  47188. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47189. */
  47190. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47191. /**
  47192. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47193. */
  47194. useRoughnessFromMetallicTextureAlpha: boolean;
  47195. /**
  47196. * Specifies if the metallic texture contains the roughness information in its green channel.
  47197. */
  47198. useRoughnessFromMetallicTextureGreen: boolean;
  47199. /**
  47200. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47201. */
  47202. useMetallnessFromMetallicTextureBlue: boolean;
  47203. /**
  47204. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47205. */
  47206. useAmbientOcclusionFromMetallicTextureRed: boolean;
  47207. /**
  47208. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47209. */
  47210. useAmbientInGrayScale: boolean;
  47211. /**
  47212. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47213. * The material will try to infer what glossiness each pixel should be.
  47214. */
  47215. useAutoMicroSurfaceFromReflectivityMap: boolean;
  47216. /**
  47217. * BJS is using an harcoded light falloff based on a manually sets up range.
  47218. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47219. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47220. */
  47221. /**
  47222. * BJS is using an harcoded light falloff based on a manually sets up range.
  47223. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47224. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47225. */
  47226. usePhysicalLightFalloff: boolean;
  47227. /**
  47228. * In order to support the falloff compatibility with gltf, a special mode has been added
  47229. * to reproduce the gltf light falloff.
  47230. */
  47231. /**
  47232. * In order to support the falloff compatibility with gltf, a special mode has been added
  47233. * to reproduce the gltf light falloff.
  47234. */
  47235. useGLTFLightFalloff: boolean;
  47236. /**
  47237. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47238. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47239. */
  47240. useRadianceOverAlpha: boolean;
  47241. /**
  47242. * Allows using an object space normal map (instead of tangent space).
  47243. */
  47244. useObjectSpaceNormalMap: boolean;
  47245. /**
  47246. * Allows using the bump map in parallax mode.
  47247. */
  47248. useParallax: boolean;
  47249. /**
  47250. * Allows using the bump map in parallax occlusion mode.
  47251. */
  47252. useParallaxOcclusion: boolean;
  47253. /**
  47254. * Controls the scale bias of the parallax mode.
  47255. */
  47256. parallaxScaleBias: number;
  47257. /**
  47258. * If sets to true, disables all the lights affecting the material.
  47259. */
  47260. disableLighting: boolean;
  47261. /**
  47262. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47263. */
  47264. forceIrradianceInFragment: boolean;
  47265. /**
  47266. * Number of Simultaneous lights allowed on the material.
  47267. */
  47268. maxSimultaneousLights: number;
  47269. /**
  47270. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47271. */
  47272. invertNormalMapX: boolean;
  47273. /**
  47274. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47275. */
  47276. invertNormalMapY: boolean;
  47277. /**
  47278. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47279. */
  47280. twoSidedLighting: boolean;
  47281. /**
  47282. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47283. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47284. */
  47285. useAlphaFresnel: boolean;
  47286. /**
  47287. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47288. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47289. */
  47290. useLinearAlphaFresnel: boolean;
  47291. /**
  47292. * Let user defines the brdf lookup texture used for IBL.
  47293. * A default 8bit version is embedded but you could point at :
  47294. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  47295. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  47296. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  47297. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  47298. */
  47299. environmentBRDFTexture: Nullable<BaseTexture>;
  47300. /**
  47301. * Force normal to face away from face.
  47302. */
  47303. forceNormalForward: boolean;
  47304. /**
  47305. * Enables specular anti aliasing in the PBR shader.
  47306. * It will both interacts on the Geometry for analytical and IBL lighting.
  47307. * It also prefilter the roughness map based on the bump values.
  47308. */
  47309. enableSpecularAntiAliasing: boolean;
  47310. /**
  47311. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47312. * makes the reflect vector face the model (under horizon).
  47313. */
  47314. useHorizonOcclusion: boolean;
  47315. /**
  47316. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47317. * too much the area relying on ambient texture to define their ambient occlusion.
  47318. */
  47319. useRadianceOcclusion: boolean;
  47320. /**
  47321. * If set to true, no lighting calculations will be applied.
  47322. */
  47323. unlit: boolean;
  47324. /**
  47325. * Gets the image processing configuration used either in this material.
  47326. */
  47327. /**
  47328. * Sets the Default image processing configuration used either in the this material.
  47329. *
  47330. * If sets to null, the scene one is in use.
  47331. */
  47332. imageProcessingConfiguration: ImageProcessingConfiguration;
  47333. /**
  47334. * Gets wether the color curves effect is enabled.
  47335. */
  47336. /**
  47337. * Sets wether the color curves effect is enabled.
  47338. */
  47339. cameraColorCurvesEnabled: boolean;
  47340. /**
  47341. * Gets wether the color grading effect is enabled.
  47342. */
  47343. /**
  47344. * Gets wether the color grading effect is enabled.
  47345. */
  47346. cameraColorGradingEnabled: boolean;
  47347. /**
  47348. * Gets wether tonemapping is enabled or not.
  47349. */
  47350. /**
  47351. * Sets wether tonemapping is enabled or not
  47352. */
  47353. cameraToneMappingEnabled: boolean;
  47354. /**
  47355. * The camera exposure used on this material.
  47356. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47357. * This corresponds to a photographic exposure.
  47358. */
  47359. /**
  47360. * The camera exposure used on this material.
  47361. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47362. * This corresponds to a photographic exposure.
  47363. */
  47364. cameraExposure: number;
  47365. /**
  47366. * Gets The camera contrast used on this material.
  47367. */
  47368. /**
  47369. * Sets The camera contrast used on this material.
  47370. */
  47371. cameraContrast: number;
  47372. /**
  47373. * Gets the Color Grading 2D Lookup Texture.
  47374. */
  47375. /**
  47376. * Sets the Color Grading 2D Lookup Texture.
  47377. */
  47378. cameraColorGradingTexture: Nullable<BaseTexture>;
  47379. /**
  47380. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47381. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47382. * 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;
  47383. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47384. */
  47385. /**
  47386. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47387. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47388. * 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;
  47389. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47390. */
  47391. cameraColorCurves: Nullable<ColorCurves>;
  47392. /**
  47393. * Instantiates a new PBRMaterial instance.
  47394. *
  47395. * @param name The material name
  47396. * @param scene The scene the material will be use in.
  47397. */
  47398. constructor(name: string, scene: Scene);
  47399. /**
  47400. * Returns the name of this material class.
  47401. */
  47402. getClassName(): string;
  47403. /**
  47404. * Makes a duplicate of the current material.
  47405. * @param name - name to use for the new material.
  47406. */
  47407. clone(name: string): PBRMaterial;
  47408. /**
  47409. * Serializes this PBR Material.
  47410. * @returns - An object with the serialized material.
  47411. */
  47412. serialize(): any;
  47413. /**
  47414. * Parses a PBR Material from a serialized object.
  47415. * @param source - Serialized object.
  47416. * @param scene - BJS scene instance.
  47417. * @param rootUrl - url for the scene object
  47418. * @returns - PBRMaterial
  47419. */
  47420. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  47421. }
  47422. }
  47423. declare module "babylonjs/Misc/dds" {
  47424. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47425. import { Engine } from "babylonjs/Engines/engine";
  47426. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47427. import { Nullable } from "babylonjs/types";
  47428. import { Scene } from "babylonjs/scene";
  47429. /**
  47430. * Direct draw surface info
  47431. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47432. */
  47433. export interface DDSInfo {
  47434. /**
  47435. * Width of the texture
  47436. */
  47437. width: number;
  47438. /**
  47439. * Width of the texture
  47440. */
  47441. height: number;
  47442. /**
  47443. * Number of Mipmaps for the texture
  47444. * @see https://en.wikipedia.org/wiki/Mipmap
  47445. */
  47446. mipmapCount: number;
  47447. /**
  47448. * If the textures format is a known fourCC format
  47449. * @see https://www.fourcc.org/
  47450. */
  47451. isFourCC: boolean;
  47452. /**
  47453. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47454. */
  47455. isRGB: boolean;
  47456. /**
  47457. * If the texture is a lumincance format
  47458. */
  47459. isLuminance: boolean;
  47460. /**
  47461. * If this is a cube texture
  47462. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47463. */
  47464. isCube: boolean;
  47465. /**
  47466. * If the texture is a compressed format eg. FOURCC_DXT1
  47467. */
  47468. isCompressed: boolean;
  47469. /**
  47470. * The dxgiFormat of the texture
  47471. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47472. */
  47473. dxgiFormat: number;
  47474. /**
  47475. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47476. */
  47477. textureType: number;
  47478. /**
  47479. * Sphericle polynomial created for the dds texture
  47480. */
  47481. sphericalPolynomial?: SphericalPolynomial;
  47482. }
  47483. /**
  47484. * Class used to provide DDS decompression tools
  47485. */
  47486. export class DDSTools {
  47487. /**
  47488. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  47489. */
  47490. static StoreLODInAlphaChannel: boolean;
  47491. /**
  47492. * Gets DDS information from an array buffer
  47493. * @param arrayBuffer defines the array buffer to read data from
  47494. * @returns the DDS information
  47495. */
  47496. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  47497. private static _FloatView;
  47498. private static _Int32View;
  47499. private static _ToHalfFloat;
  47500. private static _FromHalfFloat;
  47501. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  47502. private static _GetHalfFloatRGBAArrayBuffer;
  47503. private static _GetFloatRGBAArrayBuffer;
  47504. private static _GetFloatAsUIntRGBAArrayBuffer;
  47505. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  47506. private static _GetRGBAArrayBuffer;
  47507. private static _ExtractLongWordOrder;
  47508. private static _GetRGBArrayBuffer;
  47509. private static _GetLuminanceArrayBuffer;
  47510. /**
  47511. * Uploads DDS Levels to a Babylon Texture
  47512. * @hidden
  47513. */
  47514. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  47515. }
  47516. module "babylonjs/Engines/engine" {
  47517. interface Engine {
  47518. /**
  47519. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  47520. * @param rootUrl defines the url where the file to load is located
  47521. * @param scene defines the current scene
  47522. * @param lodScale defines scale to apply to the mip map selection
  47523. * @param lodOffset defines offset to apply to the mip map selection
  47524. * @param onLoad defines an optional callback raised when the texture is loaded
  47525. * @param onError defines an optional callback raised if there is an issue to load the texture
  47526. * @param format defines the format of the data
  47527. * @param forcedExtension defines the extension to use to pick the right loader
  47528. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  47529. * @returns the cube texture as an InternalTexture
  47530. */
  47531. 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;
  47532. }
  47533. }
  47534. }
  47535. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  47536. import { Nullable } from "babylonjs/types";
  47537. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47538. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47539. /**
  47540. * Implementation of the DDS Texture Loader.
  47541. * @hidden
  47542. */
  47543. export class _DDSTextureLoader implements IInternalTextureLoader {
  47544. /**
  47545. * Defines wether the loader supports cascade loading the different faces.
  47546. */
  47547. readonly supportCascades: boolean;
  47548. /**
  47549. * This returns if the loader support the current file information.
  47550. * @param extension defines the file extension of the file being loaded
  47551. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47552. * @param fallback defines the fallback internal texture if any
  47553. * @param isBase64 defines whether the texture is encoded as a base64
  47554. * @param isBuffer defines whether the texture data are stored as a buffer
  47555. * @returns true if the loader can load the specified file
  47556. */
  47557. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47558. /**
  47559. * Transform the url before loading if required.
  47560. * @param rootUrl the url of the texture
  47561. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47562. * @returns the transformed texture
  47563. */
  47564. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47565. /**
  47566. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47567. * @param rootUrl the url of the texture
  47568. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47569. * @returns the fallback texture
  47570. */
  47571. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47572. /**
  47573. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47574. * @param data contains the texture data
  47575. * @param texture defines the BabylonJS internal texture
  47576. * @param createPolynomials will be true if polynomials have been requested
  47577. * @param onLoad defines the callback to trigger once the texture is ready
  47578. * @param onError defines the callback to trigger in case of error
  47579. */
  47580. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47581. /**
  47582. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47583. * @param data contains the texture data
  47584. * @param texture defines the BabylonJS internal texture
  47585. * @param callback defines the method to call once ready to upload
  47586. */
  47587. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47588. }
  47589. }
  47590. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  47591. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47592. /** @hidden */
  47593. export var rgbdEncodePixelShader: {
  47594. name: string;
  47595. shader: string;
  47596. };
  47597. }
  47598. declare module "babylonjs/Misc/environmentTextureTools" {
  47599. import { Nullable } from "babylonjs/types";
  47600. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47601. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47602. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  47603. import "babylonjs/Shaders/rgbdEncode.fragment";
  47604. import "babylonjs/Shaders/rgbdDecode.fragment";
  47605. /**
  47606. * Raw texture data and descriptor sufficient for WebGL texture upload
  47607. */
  47608. export interface EnvironmentTextureInfo {
  47609. /**
  47610. * Version of the environment map
  47611. */
  47612. version: number;
  47613. /**
  47614. * Width of image
  47615. */
  47616. width: number;
  47617. /**
  47618. * Irradiance information stored in the file.
  47619. */
  47620. irradiance: any;
  47621. /**
  47622. * Specular information stored in the file.
  47623. */
  47624. specular: any;
  47625. }
  47626. /**
  47627. * Sets of helpers addressing the serialization and deserialization of environment texture
  47628. * stored in a BabylonJS env file.
  47629. * Those files are usually stored as .env files.
  47630. */
  47631. export class EnvironmentTextureTools {
  47632. /**
  47633. * Magic number identifying the env file.
  47634. */
  47635. private static _MagicBytes;
  47636. /**
  47637. * Gets the environment info from an env file.
  47638. * @param data The array buffer containing the .env bytes.
  47639. * @returns the environment file info (the json header) if successfully parsed.
  47640. */
  47641. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  47642. /**
  47643. * Creates an environment texture from a loaded cube texture.
  47644. * @param texture defines the cube texture to convert in env file
  47645. * @return a promise containing the environment data if succesfull.
  47646. */
  47647. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47648. /**
  47649. * Creates a JSON representation of the spherical data.
  47650. * @param texture defines the texture containing the polynomials
  47651. * @return the JSON representation of the spherical info
  47652. */
  47653. private static _CreateEnvTextureIrradiance;
  47654. /**
  47655. * Uploads the texture info contained in the env file to the GPU.
  47656. * @param texture defines the internal texture to upload to
  47657. * @param arrayBuffer defines the buffer cotaining the data to load
  47658. * @param info defines the texture info retrieved through the GetEnvInfo method
  47659. * @returns a promise
  47660. */
  47661. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  47662. /**
  47663. * Uploads the levels of image data to the GPU.
  47664. * @param texture defines the internal texture to upload to
  47665. * @param imageData defines the array buffer views of image data [mipmap][face]
  47666. * @returns a promise
  47667. */
  47668. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47669. /**
  47670. * Uploads spherical polynomials information to the texture.
  47671. * @param texture defines the texture we are trying to upload the information to
  47672. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47673. */
  47674. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47675. /** @hidden */
  47676. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47677. }
  47678. }
  47679. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  47680. import { Nullable } from "babylonjs/types";
  47681. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47682. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47683. /**
  47684. * Implementation of the ENV Texture Loader.
  47685. * @hidden
  47686. */
  47687. export class _ENVTextureLoader implements IInternalTextureLoader {
  47688. /**
  47689. * Defines wether the loader supports cascade loading the different faces.
  47690. */
  47691. readonly supportCascades: boolean;
  47692. /**
  47693. * This returns if the loader support the current file information.
  47694. * @param extension defines the file extension of the file being loaded
  47695. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47696. * @param fallback defines the fallback internal texture if any
  47697. * @param isBase64 defines whether the texture is encoded as a base64
  47698. * @param isBuffer defines whether the texture data are stored as a buffer
  47699. * @returns true if the loader can load the specified file
  47700. */
  47701. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47702. /**
  47703. * Transform the url before loading if required.
  47704. * @param rootUrl the url of the texture
  47705. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47706. * @returns the transformed texture
  47707. */
  47708. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47709. /**
  47710. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47711. * @param rootUrl the url of the texture
  47712. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47713. * @returns the fallback texture
  47714. */
  47715. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47716. /**
  47717. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47718. * @param data contains the texture data
  47719. * @param texture defines the BabylonJS internal texture
  47720. * @param createPolynomials will be true if polynomials have been requested
  47721. * @param onLoad defines the callback to trigger once the texture is ready
  47722. * @param onError defines the callback to trigger in case of error
  47723. */
  47724. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47725. /**
  47726. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47727. * @param data contains the texture data
  47728. * @param texture defines the BabylonJS internal texture
  47729. * @param callback defines the method to call once ready to upload
  47730. */
  47731. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47732. }
  47733. }
  47734. declare module "babylonjs/Misc/khronosTextureContainer" {
  47735. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47736. /**
  47737. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47738. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47739. */
  47740. export class KhronosTextureContainer {
  47741. /** contents of the KTX container file */
  47742. arrayBuffer: any;
  47743. private static HEADER_LEN;
  47744. private static COMPRESSED_2D;
  47745. private static COMPRESSED_3D;
  47746. private static TEX_2D;
  47747. private static TEX_3D;
  47748. /**
  47749. * Gets the openGL type
  47750. */
  47751. glType: number;
  47752. /**
  47753. * Gets the openGL type size
  47754. */
  47755. glTypeSize: number;
  47756. /**
  47757. * Gets the openGL format
  47758. */
  47759. glFormat: number;
  47760. /**
  47761. * Gets the openGL internal format
  47762. */
  47763. glInternalFormat: number;
  47764. /**
  47765. * Gets the base internal format
  47766. */
  47767. glBaseInternalFormat: number;
  47768. /**
  47769. * Gets image width in pixel
  47770. */
  47771. pixelWidth: number;
  47772. /**
  47773. * Gets image height in pixel
  47774. */
  47775. pixelHeight: number;
  47776. /**
  47777. * Gets image depth in pixels
  47778. */
  47779. pixelDepth: number;
  47780. /**
  47781. * Gets the number of array elements
  47782. */
  47783. numberOfArrayElements: number;
  47784. /**
  47785. * Gets the number of faces
  47786. */
  47787. numberOfFaces: number;
  47788. /**
  47789. * Gets the number of mipmap levels
  47790. */
  47791. numberOfMipmapLevels: number;
  47792. /**
  47793. * Gets the bytes of key value data
  47794. */
  47795. bytesOfKeyValueData: number;
  47796. /**
  47797. * Gets the load type
  47798. */
  47799. loadType: number;
  47800. /**
  47801. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  47802. */
  47803. isInvalid: boolean;
  47804. /**
  47805. * Creates a new KhronosTextureContainer
  47806. * @param arrayBuffer contents of the KTX container file
  47807. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  47808. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  47809. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  47810. */
  47811. constructor(
  47812. /** contents of the KTX container file */
  47813. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  47814. /**
  47815. * Uploads KTX content to a Babylon Texture.
  47816. * It is assumed that the texture has already been created & is currently bound
  47817. * @hidden
  47818. */
  47819. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  47820. private _upload2DCompressedLevels;
  47821. }
  47822. }
  47823. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  47824. import { Nullable } from "babylonjs/types";
  47825. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47826. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47827. /**
  47828. * Implementation of the KTX Texture Loader.
  47829. * @hidden
  47830. */
  47831. export class _KTXTextureLoader implements IInternalTextureLoader {
  47832. /**
  47833. * Defines wether the loader supports cascade loading the different faces.
  47834. */
  47835. readonly supportCascades: boolean;
  47836. /**
  47837. * This returns if the loader support the current file information.
  47838. * @param extension defines the file extension of the file being loaded
  47839. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47840. * @param fallback defines the fallback internal texture if any
  47841. * @param isBase64 defines whether the texture is encoded as a base64
  47842. * @param isBuffer defines whether the texture data are stored as a buffer
  47843. * @returns true if the loader can load the specified file
  47844. */
  47845. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47846. /**
  47847. * Transform the url before loading if required.
  47848. * @param rootUrl the url of the texture
  47849. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47850. * @returns the transformed texture
  47851. */
  47852. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47853. /**
  47854. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47855. * @param rootUrl the url of the texture
  47856. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47857. * @returns the fallback texture
  47858. */
  47859. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47860. /**
  47861. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47862. * @param data contains the texture data
  47863. * @param texture defines the BabylonJS internal texture
  47864. * @param createPolynomials will be true if polynomials have been requested
  47865. * @param onLoad defines the callback to trigger once the texture is ready
  47866. * @param onError defines the callback to trigger in case of error
  47867. */
  47868. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47869. /**
  47870. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47871. * @param data contains the texture data
  47872. * @param texture defines the BabylonJS internal texture
  47873. * @param callback defines the method to call once ready to upload
  47874. */
  47875. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  47876. }
  47877. }
  47878. declare module "babylonjs/Helpers/sceneHelpers" {
  47879. import { Nullable } from "babylonjs/types";
  47880. import { Mesh } from "babylonjs/Meshes/mesh";
  47881. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47882. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  47883. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  47884. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  47885. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  47886. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  47887. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  47888. import "babylonjs/Meshes/Builders/boxBuilder";
  47889. /** @hidden */
  47890. export var _forceSceneHelpersToBundle: boolean;
  47891. module "babylonjs/scene" {
  47892. interface Scene {
  47893. /**
  47894. * Creates a default light for the scene.
  47895. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  47896. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  47897. */
  47898. createDefaultLight(replace?: boolean): void;
  47899. /**
  47900. * Creates a default camera for the scene.
  47901. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  47902. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47903. * @param replace has default false, when true replaces the active camera in the scene
  47904. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  47905. */
  47906. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47907. /**
  47908. * Creates a default camera and a default light.
  47909. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  47910. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47911. * @param replace has the default false, when true replaces the active camera/light in the scene
  47912. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  47913. */
  47914. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47915. /**
  47916. * Creates a new sky box
  47917. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  47918. * @param environmentTexture defines the texture to use as environment texture
  47919. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  47920. * @param scale defines the overall scale of the skybox
  47921. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  47922. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  47923. * @returns a new mesh holding the sky box
  47924. */
  47925. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  47926. /**
  47927. * Creates a new environment
  47928. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  47929. * @param options defines the options you can use to configure the environment
  47930. * @returns the new EnvironmentHelper
  47931. */
  47932. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  47933. /**
  47934. * Creates a new VREXperienceHelper
  47935. * @see http://doc.babylonjs.com/how_to/webvr_helper
  47936. * @param webVROptions defines the options used to create the new VREXperienceHelper
  47937. * @returns a new VREXperienceHelper
  47938. */
  47939. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  47940. /**
  47941. * Creates a new XREXperienceHelper
  47942. * @see http://doc.babylonjs.com/how_to/webxr
  47943. * @returns a promise for a new XREXperienceHelper
  47944. */
  47945. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  47946. }
  47947. }
  47948. }
  47949. declare module "babylonjs/Helpers/videoDome" {
  47950. import { Scene } from "babylonjs/scene";
  47951. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47952. import { Mesh } from "babylonjs/Meshes/mesh";
  47953. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  47954. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47955. import "babylonjs/Meshes/Builders/sphereBuilder";
  47956. /**
  47957. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  47958. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  47959. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  47960. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47961. */
  47962. export class VideoDome extends TransformNode {
  47963. /**
  47964. * Define the video source as a Monoscopic panoramic 360 video.
  47965. */
  47966. static readonly MODE_MONOSCOPIC: number;
  47967. /**
  47968. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47969. */
  47970. static readonly MODE_TOPBOTTOM: number;
  47971. /**
  47972. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47973. */
  47974. static readonly MODE_SIDEBYSIDE: number;
  47975. private _useDirectMapping;
  47976. /**
  47977. * The video texture being displayed on the sphere
  47978. */
  47979. protected _videoTexture: VideoTexture;
  47980. /**
  47981. * Gets the video texture being displayed on the sphere
  47982. */
  47983. readonly videoTexture: VideoTexture;
  47984. /**
  47985. * The skybox material
  47986. */
  47987. protected _material: BackgroundMaterial;
  47988. /**
  47989. * The surface used for the skybox
  47990. */
  47991. protected _mesh: Mesh;
  47992. /**
  47993. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47994. * Also see the options.resolution property.
  47995. */
  47996. fovMultiplier: number;
  47997. private _videoMode;
  47998. /**
  47999. * Gets or set the current video mode for the video. It can be:
  48000. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48001. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48002. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48003. */
  48004. videoMode: number;
  48005. /**
  48006. * Oberserver used in Stereoscopic VR Mode.
  48007. */
  48008. private _onBeforeCameraRenderObserver;
  48009. /**
  48010. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48011. * @param name Element's name, child elements will append suffixes for their own names.
  48012. * @param urlsOrVideo defines the url(s) or the video element to use
  48013. * @param options An object containing optional or exposed sub element properties
  48014. */
  48015. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48016. resolution?: number;
  48017. clickToPlay?: boolean;
  48018. autoPlay?: boolean;
  48019. loop?: boolean;
  48020. size?: number;
  48021. poster?: string;
  48022. faceForward?: boolean;
  48023. useDirectMapping?: boolean;
  48024. }, scene: Scene);
  48025. private _changeVideoMode;
  48026. /**
  48027. * Releases resources associated with this node.
  48028. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48029. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48030. */
  48031. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48032. }
  48033. }
  48034. declare module "babylonjs/Helpers/index" {
  48035. export * from "babylonjs/Helpers/environmentHelper";
  48036. export * from "babylonjs/Helpers/photoDome";
  48037. export * from "babylonjs/Helpers/sceneHelpers";
  48038. export * from "babylonjs/Helpers/videoDome";
  48039. }
  48040. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  48041. import { PerfCounter } from "babylonjs/Misc/tools";
  48042. import { IDisposable } from "babylonjs/scene";
  48043. import { Engine } from "babylonjs/Engines/engine";
  48044. /**
  48045. * This class can be used to get instrumentation data from a Babylon engine
  48046. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48047. */
  48048. export class EngineInstrumentation implements IDisposable {
  48049. /**
  48050. * Define the instrumented engine.
  48051. */
  48052. engine: Engine;
  48053. private _captureGPUFrameTime;
  48054. private _gpuFrameTimeToken;
  48055. private _gpuFrameTime;
  48056. private _captureShaderCompilationTime;
  48057. private _shaderCompilationTime;
  48058. private _onBeginFrameObserver;
  48059. private _onEndFrameObserver;
  48060. private _onBeforeShaderCompilationObserver;
  48061. private _onAfterShaderCompilationObserver;
  48062. /**
  48063. * Gets the perf counter used for GPU frame time
  48064. */
  48065. readonly gpuFrameTimeCounter: PerfCounter;
  48066. /**
  48067. * Gets the GPU frame time capture status
  48068. */
  48069. /**
  48070. * Enable or disable the GPU frame time capture
  48071. */
  48072. captureGPUFrameTime: boolean;
  48073. /**
  48074. * Gets the perf counter used for shader compilation time
  48075. */
  48076. readonly shaderCompilationTimeCounter: PerfCounter;
  48077. /**
  48078. * Gets the shader compilation time capture status
  48079. */
  48080. /**
  48081. * Enable or disable the shader compilation time capture
  48082. */
  48083. captureShaderCompilationTime: boolean;
  48084. /**
  48085. * Instantiates a new engine instrumentation.
  48086. * This class can be used to get instrumentation data from a Babylon engine
  48087. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48088. * @param engine Defines the engine to instrument
  48089. */
  48090. constructor(
  48091. /**
  48092. * Define the instrumented engine.
  48093. */
  48094. engine: Engine);
  48095. /**
  48096. * Dispose and release associated resources.
  48097. */
  48098. dispose(): void;
  48099. }
  48100. }
  48101. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  48102. import { PerfCounter } from "babylonjs/Misc/tools";
  48103. import { Scene, IDisposable } from "babylonjs/scene";
  48104. /**
  48105. * This class can be used to get instrumentation data from a Babylon engine
  48106. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48107. */
  48108. export class SceneInstrumentation implements IDisposable {
  48109. /**
  48110. * Defines the scene to instrument
  48111. */
  48112. scene: Scene;
  48113. private _captureActiveMeshesEvaluationTime;
  48114. private _activeMeshesEvaluationTime;
  48115. private _captureRenderTargetsRenderTime;
  48116. private _renderTargetsRenderTime;
  48117. private _captureFrameTime;
  48118. private _frameTime;
  48119. private _captureRenderTime;
  48120. private _renderTime;
  48121. private _captureInterFrameTime;
  48122. private _interFrameTime;
  48123. private _captureParticlesRenderTime;
  48124. private _particlesRenderTime;
  48125. private _captureSpritesRenderTime;
  48126. private _spritesRenderTime;
  48127. private _capturePhysicsTime;
  48128. private _physicsTime;
  48129. private _captureAnimationsTime;
  48130. private _animationsTime;
  48131. private _captureCameraRenderTime;
  48132. private _cameraRenderTime;
  48133. private _onBeforeActiveMeshesEvaluationObserver;
  48134. private _onAfterActiveMeshesEvaluationObserver;
  48135. private _onBeforeRenderTargetsRenderObserver;
  48136. private _onAfterRenderTargetsRenderObserver;
  48137. private _onAfterRenderObserver;
  48138. private _onBeforeDrawPhaseObserver;
  48139. private _onAfterDrawPhaseObserver;
  48140. private _onBeforeAnimationsObserver;
  48141. private _onBeforeParticlesRenderingObserver;
  48142. private _onAfterParticlesRenderingObserver;
  48143. private _onBeforeSpritesRenderingObserver;
  48144. private _onAfterSpritesRenderingObserver;
  48145. private _onBeforePhysicsObserver;
  48146. private _onAfterPhysicsObserver;
  48147. private _onAfterAnimationsObserver;
  48148. private _onBeforeCameraRenderObserver;
  48149. private _onAfterCameraRenderObserver;
  48150. /**
  48151. * Gets the perf counter used for active meshes evaluation time
  48152. */
  48153. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  48154. /**
  48155. * Gets the active meshes evaluation time capture status
  48156. */
  48157. /**
  48158. * Enable or disable the active meshes evaluation time capture
  48159. */
  48160. captureActiveMeshesEvaluationTime: boolean;
  48161. /**
  48162. * Gets the perf counter used for render targets render time
  48163. */
  48164. readonly renderTargetsRenderTimeCounter: PerfCounter;
  48165. /**
  48166. * Gets the render targets render time capture status
  48167. */
  48168. /**
  48169. * Enable or disable the render targets render time capture
  48170. */
  48171. captureRenderTargetsRenderTime: boolean;
  48172. /**
  48173. * Gets the perf counter used for particles render time
  48174. */
  48175. readonly particlesRenderTimeCounter: PerfCounter;
  48176. /**
  48177. * Gets the particles render time capture status
  48178. */
  48179. /**
  48180. * Enable or disable the particles render time capture
  48181. */
  48182. captureParticlesRenderTime: boolean;
  48183. /**
  48184. * Gets the perf counter used for sprites render time
  48185. */
  48186. readonly spritesRenderTimeCounter: PerfCounter;
  48187. /**
  48188. * Gets the sprites render time capture status
  48189. */
  48190. /**
  48191. * Enable or disable the sprites render time capture
  48192. */
  48193. captureSpritesRenderTime: boolean;
  48194. /**
  48195. * Gets the perf counter used for physics time
  48196. */
  48197. readonly physicsTimeCounter: PerfCounter;
  48198. /**
  48199. * Gets the physics time capture status
  48200. */
  48201. /**
  48202. * Enable or disable the physics time capture
  48203. */
  48204. capturePhysicsTime: boolean;
  48205. /**
  48206. * Gets the perf counter used for animations time
  48207. */
  48208. readonly animationsTimeCounter: PerfCounter;
  48209. /**
  48210. * Gets the animations time capture status
  48211. */
  48212. /**
  48213. * Enable or disable the animations time capture
  48214. */
  48215. captureAnimationsTime: boolean;
  48216. /**
  48217. * Gets the perf counter used for frame time capture
  48218. */
  48219. readonly frameTimeCounter: PerfCounter;
  48220. /**
  48221. * Gets the frame time capture status
  48222. */
  48223. /**
  48224. * Enable or disable the frame time capture
  48225. */
  48226. captureFrameTime: boolean;
  48227. /**
  48228. * Gets the perf counter used for inter-frames time capture
  48229. */
  48230. readonly interFrameTimeCounter: PerfCounter;
  48231. /**
  48232. * Gets the inter-frames time capture status
  48233. */
  48234. /**
  48235. * Enable or disable the inter-frames time capture
  48236. */
  48237. captureInterFrameTime: boolean;
  48238. /**
  48239. * Gets the perf counter used for render time capture
  48240. */
  48241. readonly renderTimeCounter: PerfCounter;
  48242. /**
  48243. * Gets the render time capture status
  48244. */
  48245. /**
  48246. * Enable or disable the render time capture
  48247. */
  48248. captureRenderTime: boolean;
  48249. /**
  48250. * Gets the perf counter used for camera render time capture
  48251. */
  48252. readonly cameraRenderTimeCounter: PerfCounter;
  48253. /**
  48254. * Gets the camera render time capture status
  48255. */
  48256. /**
  48257. * Enable or disable the camera render time capture
  48258. */
  48259. captureCameraRenderTime: boolean;
  48260. /**
  48261. * Gets the perf counter used for draw calls
  48262. */
  48263. readonly drawCallsCounter: PerfCounter;
  48264. /**
  48265. * Instantiates a new scene instrumentation.
  48266. * This class can be used to get instrumentation data from a Babylon engine
  48267. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48268. * @param scene Defines the scene to instrument
  48269. */
  48270. constructor(
  48271. /**
  48272. * Defines the scene to instrument
  48273. */
  48274. scene: Scene);
  48275. /**
  48276. * Dispose and release associated resources.
  48277. */
  48278. dispose(): void;
  48279. }
  48280. }
  48281. declare module "babylonjs/Instrumentation/index" {
  48282. export * from "babylonjs/Instrumentation/engineInstrumentation";
  48283. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  48284. export * from "babylonjs/Instrumentation/timeToken";
  48285. }
  48286. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  48287. /** @hidden */
  48288. export var glowMapGenerationPixelShader: {
  48289. name: string;
  48290. shader: string;
  48291. };
  48292. }
  48293. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  48294. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48295. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  48296. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  48297. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48298. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  48299. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48300. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48301. /** @hidden */
  48302. export var glowMapGenerationVertexShader: {
  48303. name: string;
  48304. shader: string;
  48305. };
  48306. }
  48307. declare module "babylonjs/Layers/effectLayer" {
  48308. import { Observable } from "babylonjs/Misc/observable";
  48309. import { Nullable } from "babylonjs/types";
  48310. import { Camera } from "babylonjs/Cameras/camera";
  48311. import { Scene } from "babylonjs/scene";
  48312. import { Color4, ISize } from "babylonjs/Maths/math";
  48313. import { Engine } from "babylonjs/Engines/engine";
  48314. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48315. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48316. import { Mesh } from "babylonjs/Meshes/mesh";
  48317. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  48318. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48319. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48320. import { Effect } from "babylonjs/Materials/effect";
  48321. import { Material } from "babylonjs/Materials/material";
  48322. import "babylonjs/Shaders/glowMapGeneration.fragment";
  48323. import "babylonjs/Shaders/glowMapGeneration.vertex";
  48324. /**
  48325. * Effect layer options. This helps customizing the behaviour
  48326. * of the effect layer.
  48327. */
  48328. export interface IEffectLayerOptions {
  48329. /**
  48330. * Multiplication factor apply to the canvas size to compute the render target size
  48331. * used to generated the objects (the smaller the faster).
  48332. */
  48333. mainTextureRatio: number;
  48334. /**
  48335. * Enforces a fixed size texture to ensure effect stability across devices.
  48336. */
  48337. mainTextureFixedSize?: number;
  48338. /**
  48339. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  48340. */
  48341. alphaBlendingMode: number;
  48342. /**
  48343. * The camera attached to the layer.
  48344. */
  48345. camera: Nullable<Camera>;
  48346. /**
  48347. * The rendering group to draw the layer in.
  48348. */
  48349. renderingGroupId: number;
  48350. }
  48351. /**
  48352. * The effect layer Helps adding post process effect blended with the main pass.
  48353. *
  48354. * This can be for instance use to generate glow or higlight effects on the scene.
  48355. *
  48356. * The effect layer class can not be used directly and is intented to inherited from to be
  48357. * customized per effects.
  48358. */
  48359. export abstract class EffectLayer {
  48360. private _vertexBuffers;
  48361. private _indexBuffer;
  48362. private _cachedDefines;
  48363. private _effectLayerMapGenerationEffect;
  48364. private _effectLayerOptions;
  48365. private _mergeEffect;
  48366. protected _scene: Scene;
  48367. protected _engine: Engine;
  48368. protected _maxSize: number;
  48369. protected _mainTextureDesiredSize: ISize;
  48370. protected _mainTexture: RenderTargetTexture;
  48371. protected _shouldRender: boolean;
  48372. protected _postProcesses: PostProcess[];
  48373. protected _textures: BaseTexture[];
  48374. protected _emissiveTextureAndColor: {
  48375. texture: Nullable<BaseTexture>;
  48376. color: Color4;
  48377. };
  48378. /**
  48379. * The name of the layer
  48380. */
  48381. name: string;
  48382. /**
  48383. * The clear color of the texture used to generate the glow map.
  48384. */
  48385. neutralColor: Color4;
  48386. /**
  48387. * Specifies wether the highlight layer is enabled or not.
  48388. */
  48389. isEnabled: boolean;
  48390. /**
  48391. * Gets the camera attached to the layer.
  48392. */
  48393. readonly camera: Nullable<Camera>;
  48394. /**
  48395. * Gets the rendering group id the layer should render in.
  48396. */
  48397. readonly renderingGroupId: number;
  48398. /**
  48399. * An event triggered when the effect layer has been disposed.
  48400. */
  48401. onDisposeObservable: Observable<EffectLayer>;
  48402. /**
  48403. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  48404. */
  48405. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  48406. /**
  48407. * An event triggered when the generated texture is being merged in the scene.
  48408. */
  48409. onBeforeComposeObservable: Observable<EffectLayer>;
  48410. /**
  48411. * An event triggered when the generated texture has been merged in the scene.
  48412. */
  48413. onAfterComposeObservable: Observable<EffectLayer>;
  48414. /**
  48415. * An event triggered when the efffect layer changes its size.
  48416. */
  48417. onSizeChangedObservable: Observable<EffectLayer>;
  48418. /** @hidden */
  48419. static _SceneComponentInitialization: (scene: Scene) => void;
  48420. /**
  48421. * Instantiates a new effect Layer and references it in the scene.
  48422. * @param name The name of the layer
  48423. * @param scene The scene to use the layer in
  48424. */
  48425. constructor(
  48426. /** The Friendly of the effect in the scene */
  48427. name: string, scene: Scene);
  48428. /**
  48429. * Get the effect name of the layer.
  48430. * @return The effect name
  48431. */
  48432. abstract getEffectName(): string;
  48433. /**
  48434. * Checks for the readiness of the element composing the layer.
  48435. * @param subMesh the mesh to check for
  48436. * @param useInstances specify wether or not to use instances to render the mesh
  48437. * @return true if ready otherwise, false
  48438. */
  48439. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48440. /**
  48441. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48442. * @returns true if the effect requires stencil during the main canvas render pass.
  48443. */
  48444. abstract needStencil(): boolean;
  48445. /**
  48446. * Create the merge effect. This is the shader use to blit the information back
  48447. * to the main canvas at the end of the scene rendering.
  48448. * @returns The effect containing the shader used to merge the effect on the main canvas
  48449. */
  48450. protected abstract _createMergeEffect(): Effect;
  48451. /**
  48452. * Creates the render target textures and post processes used in the effect layer.
  48453. */
  48454. protected abstract _createTextureAndPostProcesses(): void;
  48455. /**
  48456. * Implementation specific of rendering the generating effect on the main canvas.
  48457. * @param effect The effect used to render through
  48458. */
  48459. protected abstract _internalRender(effect: Effect): void;
  48460. /**
  48461. * Sets the required values for both the emissive texture and and the main color.
  48462. */
  48463. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48464. /**
  48465. * Free any resources and references associated to a mesh.
  48466. * Internal use
  48467. * @param mesh The mesh to free.
  48468. */
  48469. abstract _disposeMesh(mesh: Mesh): void;
  48470. /**
  48471. * Serializes this layer (Glow or Highlight for example)
  48472. * @returns a serialized layer object
  48473. */
  48474. abstract serialize?(): any;
  48475. /**
  48476. * Initializes the effect layer with the required options.
  48477. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  48478. */
  48479. protected _init(options: Partial<IEffectLayerOptions>): void;
  48480. /**
  48481. * Generates the index buffer of the full screen quad blending to the main canvas.
  48482. */
  48483. private _generateIndexBuffer;
  48484. /**
  48485. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  48486. */
  48487. private _genrateVertexBuffer;
  48488. /**
  48489. * Sets the main texture desired size which is the closest power of two
  48490. * of the engine canvas size.
  48491. */
  48492. private _setMainTextureSize;
  48493. /**
  48494. * Creates the main texture for the effect layer.
  48495. */
  48496. protected _createMainTexture(): void;
  48497. /**
  48498. * Adds specific effects defines.
  48499. * @param defines The defines to add specifics to.
  48500. */
  48501. protected _addCustomEffectDefines(defines: string[]): void;
  48502. /**
  48503. * Checks for the readiness of the element composing the layer.
  48504. * @param subMesh the mesh to check for
  48505. * @param useInstances specify wether or not to use instances to render the mesh
  48506. * @param emissiveTexture the associated emissive texture used to generate the glow
  48507. * @return true if ready otherwise, false
  48508. */
  48509. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  48510. /**
  48511. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  48512. */
  48513. render(): void;
  48514. /**
  48515. * Determine if a given mesh will be used in the current effect.
  48516. * @param mesh mesh to test
  48517. * @returns true if the mesh will be used
  48518. */
  48519. hasMesh(mesh: AbstractMesh): boolean;
  48520. /**
  48521. * Returns true if the layer contains information to display, otherwise false.
  48522. * @returns true if the glow layer should be rendered
  48523. */
  48524. shouldRender(): boolean;
  48525. /**
  48526. * Returns true if the mesh should render, otherwise false.
  48527. * @param mesh The mesh to render
  48528. * @returns true if it should render otherwise false
  48529. */
  48530. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  48531. /**
  48532. * Returns true if the mesh can be rendered, otherwise false.
  48533. * @param mesh The mesh to render
  48534. * @param material The material used on the mesh
  48535. * @returns true if it can be rendered otherwise false
  48536. */
  48537. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48538. /**
  48539. * Returns true if the mesh should render, otherwise false.
  48540. * @param mesh The mesh to render
  48541. * @returns true if it should render otherwise false
  48542. */
  48543. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  48544. /**
  48545. * Renders the submesh passed in parameter to the generation map.
  48546. */
  48547. protected _renderSubMesh(subMesh: SubMesh): void;
  48548. /**
  48549. * Rebuild the required buffers.
  48550. * @hidden Internal use only.
  48551. */
  48552. _rebuild(): void;
  48553. /**
  48554. * Dispose only the render target textures and post process.
  48555. */
  48556. private _disposeTextureAndPostProcesses;
  48557. /**
  48558. * Dispose the highlight layer and free resources.
  48559. */
  48560. dispose(): void;
  48561. /**
  48562. * Gets the class name of the effect layer
  48563. * @returns the string with the class name of the effect layer
  48564. */
  48565. getClassName(): string;
  48566. /**
  48567. * Creates an effect layer from parsed effect layer data
  48568. * @param parsedEffectLayer defines effect layer data
  48569. * @param scene defines the current scene
  48570. * @param rootUrl defines the root URL containing the effect layer information
  48571. * @returns a parsed effect Layer
  48572. */
  48573. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  48574. }
  48575. }
  48576. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  48577. import { Scene } from "babylonjs/scene";
  48578. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  48579. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  48580. import { AbstractScene } from "babylonjs/abstractScene";
  48581. module "babylonjs/abstractScene" {
  48582. interface AbstractScene {
  48583. /**
  48584. * The list of effect layers (highlights/glow) added to the scene
  48585. * @see http://doc.babylonjs.com/how_to/highlight_layer
  48586. * @see http://doc.babylonjs.com/how_to/glow_layer
  48587. */
  48588. effectLayers: Array<EffectLayer>;
  48589. /**
  48590. * Removes the given effect layer from this scene.
  48591. * @param toRemove defines the effect layer to remove
  48592. * @returns the index of the removed effect layer
  48593. */
  48594. removeEffectLayer(toRemove: EffectLayer): number;
  48595. /**
  48596. * Adds the given effect layer to this scene
  48597. * @param newEffectLayer defines the effect layer to add
  48598. */
  48599. addEffectLayer(newEffectLayer: EffectLayer): void;
  48600. }
  48601. }
  48602. /**
  48603. * Defines the layer scene component responsible to manage any effect layers
  48604. * in a given scene.
  48605. */
  48606. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  48607. /**
  48608. * The component name helpfull to identify the component in the list of scene components.
  48609. */
  48610. readonly name: string;
  48611. /**
  48612. * The scene the component belongs to.
  48613. */
  48614. scene: Scene;
  48615. private _engine;
  48616. private _renderEffects;
  48617. private _needStencil;
  48618. private _previousStencilState;
  48619. /**
  48620. * Creates a new instance of the component for the given scene
  48621. * @param scene Defines the scene to register the component in
  48622. */
  48623. constructor(scene: Scene);
  48624. /**
  48625. * Registers the component in a given scene
  48626. */
  48627. register(): void;
  48628. /**
  48629. * Rebuilds the elements related to this component in case of
  48630. * context lost for instance.
  48631. */
  48632. rebuild(): void;
  48633. /**
  48634. * Serializes the component data to the specified json object
  48635. * @param serializationObject The object to serialize to
  48636. */
  48637. serialize(serializationObject: any): void;
  48638. /**
  48639. * Adds all the element from the container to the scene
  48640. * @param container the container holding the elements
  48641. */
  48642. addFromContainer(container: AbstractScene): void;
  48643. /**
  48644. * Removes all the elements in the container from the scene
  48645. * @param container contains the elements to remove
  48646. * @param dispose if the removed element should be disposed (default: false)
  48647. */
  48648. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48649. /**
  48650. * Disposes the component and the associated ressources.
  48651. */
  48652. dispose(): void;
  48653. private _isReadyForMesh;
  48654. private _renderMainTexture;
  48655. private _setStencil;
  48656. private _setStencilBack;
  48657. private _draw;
  48658. private _drawCamera;
  48659. private _drawRenderingGroup;
  48660. }
  48661. }
  48662. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  48663. /** @hidden */
  48664. export var glowMapMergePixelShader: {
  48665. name: string;
  48666. shader: string;
  48667. };
  48668. }
  48669. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  48670. /** @hidden */
  48671. export var glowMapMergeVertexShader: {
  48672. name: string;
  48673. shader: string;
  48674. };
  48675. }
  48676. declare module "babylonjs/Layers/glowLayer" {
  48677. import { Nullable } from "babylonjs/types";
  48678. import { Camera } from "babylonjs/Cameras/camera";
  48679. import { Scene } from "babylonjs/scene";
  48680. import { Color4 } from "babylonjs/Maths/math";
  48681. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48682. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48683. import { Mesh } from "babylonjs/Meshes/mesh";
  48684. import { Texture } from "babylonjs/Materials/Textures/texture";
  48685. import { Effect } from "babylonjs/Materials/effect";
  48686. import { Material } from "babylonjs/Materials/material";
  48687. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  48688. import "babylonjs/Shaders/glowMapMerge.fragment";
  48689. import "babylonjs/Shaders/glowMapMerge.vertex";
  48690. import "babylonjs/Layers/effectLayerSceneComponent";
  48691. module "babylonjs/abstractScene" {
  48692. interface AbstractScene {
  48693. /**
  48694. * Return a the first highlight layer of the scene with a given name.
  48695. * @param name The name of the highlight layer to look for.
  48696. * @return The highlight layer if found otherwise null.
  48697. */
  48698. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  48699. }
  48700. }
  48701. /**
  48702. * Glow layer options. This helps customizing the behaviour
  48703. * of the glow layer.
  48704. */
  48705. export interface IGlowLayerOptions {
  48706. /**
  48707. * Multiplication factor apply to the canvas size to compute the render target size
  48708. * used to generated the glowing objects (the smaller the faster).
  48709. */
  48710. mainTextureRatio: number;
  48711. /**
  48712. * Enforces a fixed size texture to ensure resize independant blur.
  48713. */
  48714. mainTextureFixedSize?: number;
  48715. /**
  48716. * How big is the kernel of the blur texture.
  48717. */
  48718. blurKernelSize: number;
  48719. /**
  48720. * The camera attached to the layer.
  48721. */
  48722. camera: Nullable<Camera>;
  48723. /**
  48724. * Enable MSAA by chosing the number of samples.
  48725. */
  48726. mainTextureSamples?: number;
  48727. /**
  48728. * The rendering group to draw the layer in.
  48729. */
  48730. renderingGroupId: number;
  48731. }
  48732. /**
  48733. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  48734. *
  48735. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48736. * glowy meshes to your scene.
  48737. *
  48738. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  48739. */
  48740. export class GlowLayer extends EffectLayer {
  48741. /**
  48742. * Effect Name of the layer.
  48743. */
  48744. static readonly EffectName: string;
  48745. /**
  48746. * The default blur kernel size used for the glow.
  48747. */
  48748. static DefaultBlurKernelSize: number;
  48749. /**
  48750. * The default texture size ratio used for the glow.
  48751. */
  48752. static DefaultTextureRatio: number;
  48753. /**
  48754. * Sets the kernel size of the blur.
  48755. */
  48756. /**
  48757. * Gets the kernel size of the blur.
  48758. */
  48759. blurKernelSize: number;
  48760. /**
  48761. * Sets the glow intensity.
  48762. */
  48763. /**
  48764. * Gets the glow intensity.
  48765. */
  48766. intensity: number;
  48767. private _options;
  48768. private _intensity;
  48769. private _horizontalBlurPostprocess1;
  48770. private _verticalBlurPostprocess1;
  48771. private _horizontalBlurPostprocess2;
  48772. private _verticalBlurPostprocess2;
  48773. private _blurTexture1;
  48774. private _blurTexture2;
  48775. private _postProcesses1;
  48776. private _postProcesses2;
  48777. private _includedOnlyMeshes;
  48778. private _excludedMeshes;
  48779. /**
  48780. * Callback used to let the user override the color selection on a per mesh basis
  48781. */
  48782. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  48783. /**
  48784. * Callback used to let the user override the texture selection on a per mesh basis
  48785. */
  48786. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  48787. /**
  48788. * Instantiates a new glow Layer and references it to the scene.
  48789. * @param name The name of the layer
  48790. * @param scene The scene to use the layer in
  48791. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  48792. */
  48793. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  48794. /**
  48795. * Get the effect name of the layer.
  48796. * @return The effect name
  48797. */
  48798. getEffectName(): string;
  48799. /**
  48800. * Create the merge effect. This is the shader use to blit the information back
  48801. * to the main canvas at the end of the scene rendering.
  48802. */
  48803. protected _createMergeEffect(): Effect;
  48804. /**
  48805. * Creates the render target textures and post processes used in the glow layer.
  48806. */
  48807. protected _createTextureAndPostProcesses(): void;
  48808. /**
  48809. * Checks for the readiness of the element composing the layer.
  48810. * @param subMesh the mesh to check for
  48811. * @param useInstances specify wether or not to use instances to render the mesh
  48812. * @param emissiveTexture the associated emissive texture used to generate the glow
  48813. * @return true if ready otherwise, false
  48814. */
  48815. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48816. /**
  48817. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48818. */
  48819. needStencil(): boolean;
  48820. /**
  48821. * Returns true if the mesh can be rendered, otherwise false.
  48822. * @param mesh The mesh to render
  48823. * @param material The material used on the mesh
  48824. * @returns true if it can be rendered otherwise false
  48825. */
  48826. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48827. /**
  48828. * Implementation specific of rendering the generating effect on the main canvas.
  48829. * @param effect The effect used to render through
  48830. */
  48831. protected _internalRender(effect: Effect): void;
  48832. /**
  48833. * Sets the required values for both the emissive texture and and the main color.
  48834. */
  48835. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48836. /**
  48837. * Returns true if the mesh should render, otherwise false.
  48838. * @param mesh The mesh to render
  48839. * @returns true if it should render otherwise false
  48840. */
  48841. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48842. /**
  48843. * Adds specific effects defines.
  48844. * @param defines The defines to add specifics to.
  48845. */
  48846. protected _addCustomEffectDefines(defines: string[]): void;
  48847. /**
  48848. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  48849. * @param mesh The mesh to exclude from the glow layer
  48850. */
  48851. addExcludedMesh(mesh: Mesh): void;
  48852. /**
  48853. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  48854. * @param mesh The mesh to remove
  48855. */
  48856. removeExcludedMesh(mesh: Mesh): void;
  48857. /**
  48858. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  48859. * @param mesh The mesh to include in the glow layer
  48860. */
  48861. addIncludedOnlyMesh(mesh: Mesh): void;
  48862. /**
  48863. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  48864. * @param mesh The mesh to remove
  48865. */
  48866. removeIncludedOnlyMesh(mesh: Mesh): void;
  48867. /**
  48868. * Determine if a given mesh will be used in the glow layer
  48869. * @param mesh The mesh to test
  48870. * @returns true if the mesh will be highlighted by the current glow layer
  48871. */
  48872. hasMesh(mesh: AbstractMesh): boolean;
  48873. /**
  48874. * Free any resources and references associated to a mesh.
  48875. * Internal use
  48876. * @param mesh The mesh to free.
  48877. * @hidden
  48878. */
  48879. _disposeMesh(mesh: Mesh): void;
  48880. /**
  48881. * Gets the class name of the effect layer
  48882. * @returns the string with the class name of the effect layer
  48883. */
  48884. getClassName(): string;
  48885. /**
  48886. * Serializes this glow layer
  48887. * @returns a serialized glow layer object
  48888. */
  48889. serialize(): any;
  48890. /**
  48891. * Creates a Glow Layer from parsed glow layer data
  48892. * @param parsedGlowLayer defines glow layer data
  48893. * @param scene defines the current scene
  48894. * @param rootUrl defines the root URL containing the glow layer information
  48895. * @returns a parsed Glow Layer
  48896. */
  48897. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  48898. }
  48899. }
  48900. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  48901. /** @hidden */
  48902. export var glowBlurPostProcessPixelShader: {
  48903. name: string;
  48904. shader: string;
  48905. };
  48906. }
  48907. declare module "babylonjs/Layers/highlightLayer" {
  48908. import { Observable } from "babylonjs/Misc/observable";
  48909. import { Nullable } from "babylonjs/types";
  48910. import { Camera } from "babylonjs/Cameras/camera";
  48911. import { Scene } from "babylonjs/scene";
  48912. import { Color3, Color4 } from "babylonjs/Maths/math";
  48913. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48914. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48915. import { Mesh } from "babylonjs/Meshes/mesh";
  48916. import { Effect } from "babylonjs/Materials/effect";
  48917. import { Material } from "babylonjs/Materials/material";
  48918. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  48919. import "babylonjs/Shaders/glowMapMerge.fragment";
  48920. import "babylonjs/Shaders/glowMapMerge.vertex";
  48921. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  48922. module "babylonjs/abstractScene" {
  48923. interface AbstractScene {
  48924. /**
  48925. * Return a the first highlight layer of the scene with a given name.
  48926. * @param name The name of the highlight layer to look for.
  48927. * @return The highlight layer if found otherwise null.
  48928. */
  48929. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  48930. }
  48931. }
  48932. /**
  48933. * Highlight layer options. This helps customizing the behaviour
  48934. * of the highlight layer.
  48935. */
  48936. export interface IHighlightLayerOptions {
  48937. /**
  48938. * Multiplication factor apply to the canvas size to compute the render target size
  48939. * used to generated the glowing objects (the smaller the faster).
  48940. */
  48941. mainTextureRatio: number;
  48942. /**
  48943. * Enforces a fixed size texture to ensure resize independant blur.
  48944. */
  48945. mainTextureFixedSize?: number;
  48946. /**
  48947. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  48948. * of the picture to blur (the smaller the faster).
  48949. */
  48950. blurTextureSizeRatio: number;
  48951. /**
  48952. * How big in texel of the blur texture is the vertical blur.
  48953. */
  48954. blurVerticalSize: number;
  48955. /**
  48956. * How big in texel of the blur texture is the horizontal blur.
  48957. */
  48958. blurHorizontalSize: number;
  48959. /**
  48960. * Alpha blending mode used to apply the blur. Default is combine.
  48961. */
  48962. alphaBlendingMode: number;
  48963. /**
  48964. * The camera attached to the layer.
  48965. */
  48966. camera: Nullable<Camera>;
  48967. /**
  48968. * Should we display highlight as a solid stroke?
  48969. */
  48970. isStroke?: boolean;
  48971. /**
  48972. * The rendering group to draw the layer in.
  48973. */
  48974. renderingGroupId: number;
  48975. }
  48976. /**
  48977. * The highlight layer Helps adding a glow effect around a mesh.
  48978. *
  48979. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48980. * glowy meshes to your scene.
  48981. *
  48982. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  48983. */
  48984. export class HighlightLayer extends EffectLayer {
  48985. name: string;
  48986. /**
  48987. * Effect Name of the highlight layer.
  48988. */
  48989. static readonly EffectName: string;
  48990. /**
  48991. * The neutral color used during the preparation of the glow effect.
  48992. * This is black by default as the blend operation is a blend operation.
  48993. */
  48994. static NeutralColor: Color4;
  48995. /**
  48996. * Stencil value used for glowing meshes.
  48997. */
  48998. static GlowingMeshStencilReference: number;
  48999. /**
  49000. * Stencil value used for the other meshes in the scene.
  49001. */
  49002. static NormalMeshStencilReference: number;
  49003. /**
  49004. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49005. */
  49006. innerGlow: boolean;
  49007. /**
  49008. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49009. */
  49010. outerGlow: boolean;
  49011. /**
  49012. * Specifies the horizontal size of the blur.
  49013. */
  49014. /**
  49015. * Gets the horizontal size of the blur.
  49016. */
  49017. blurHorizontalSize: number;
  49018. /**
  49019. * Specifies the vertical size of the blur.
  49020. */
  49021. /**
  49022. * Gets the vertical size of the blur.
  49023. */
  49024. blurVerticalSize: number;
  49025. /**
  49026. * An event triggered when the highlight layer is being blurred.
  49027. */
  49028. onBeforeBlurObservable: Observable<HighlightLayer>;
  49029. /**
  49030. * An event triggered when the highlight layer has been blurred.
  49031. */
  49032. onAfterBlurObservable: Observable<HighlightLayer>;
  49033. private _instanceGlowingMeshStencilReference;
  49034. private _options;
  49035. private _downSamplePostprocess;
  49036. private _horizontalBlurPostprocess;
  49037. private _verticalBlurPostprocess;
  49038. private _blurTexture;
  49039. private _meshes;
  49040. private _excludedMeshes;
  49041. /**
  49042. * Instantiates a new highlight Layer and references it to the scene..
  49043. * @param name The name of the layer
  49044. * @param scene The scene to use the layer in
  49045. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49046. */
  49047. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49048. /**
  49049. * Get the effect name of the layer.
  49050. * @return The effect name
  49051. */
  49052. getEffectName(): string;
  49053. /**
  49054. * Create the merge effect. This is the shader use to blit the information back
  49055. * to the main canvas at the end of the scene rendering.
  49056. */
  49057. protected _createMergeEffect(): Effect;
  49058. /**
  49059. * Creates the render target textures and post processes used in the highlight layer.
  49060. */
  49061. protected _createTextureAndPostProcesses(): void;
  49062. /**
  49063. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49064. */
  49065. needStencil(): boolean;
  49066. /**
  49067. * Checks for the readiness of the element composing the layer.
  49068. * @param subMesh the mesh to check for
  49069. * @param useInstances specify wether or not to use instances to render the mesh
  49070. * @param emissiveTexture the associated emissive texture used to generate the glow
  49071. * @return true if ready otherwise, false
  49072. */
  49073. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49074. /**
  49075. * Implementation specific of rendering the generating effect on the main canvas.
  49076. * @param effect The effect used to render through
  49077. */
  49078. protected _internalRender(effect: Effect): void;
  49079. /**
  49080. * Returns true if the layer contains information to display, otherwise false.
  49081. */
  49082. shouldRender(): boolean;
  49083. /**
  49084. * Returns true if the mesh should render, otherwise false.
  49085. * @param mesh The mesh to render
  49086. * @returns true if it should render otherwise false
  49087. */
  49088. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49089. /**
  49090. * Sets the required values for both the emissive texture and and the main color.
  49091. */
  49092. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49093. /**
  49094. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49095. * @param mesh The mesh to exclude from the highlight layer
  49096. */
  49097. addExcludedMesh(mesh: Mesh): void;
  49098. /**
  49099. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49100. * @param mesh The mesh to highlight
  49101. */
  49102. removeExcludedMesh(mesh: Mesh): void;
  49103. /**
  49104. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49105. * @param mesh mesh to test
  49106. * @returns true if the mesh will be highlighted by the current HighlightLayer
  49107. */
  49108. hasMesh(mesh: AbstractMesh): boolean;
  49109. /**
  49110. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  49111. * @param mesh The mesh to highlight
  49112. * @param color The color of the highlight
  49113. * @param glowEmissiveOnly Extract the glow from the emissive texture
  49114. */
  49115. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  49116. /**
  49117. * Remove a mesh from the highlight layer in order to make it stop glowing.
  49118. * @param mesh The mesh to highlight
  49119. */
  49120. removeMesh(mesh: Mesh): void;
  49121. /**
  49122. * Force the stencil to the normal expected value for none glowing parts
  49123. */
  49124. private _defaultStencilReference;
  49125. /**
  49126. * Free any resources and references associated to a mesh.
  49127. * Internal use
  49128. * @param mesh The mesh to free.
  49129. * @hidden
  49130. */
  49131. _disposeMesh(mesh: Mesh): void;
  49132. /**
  49133. * Dispose the highlight layer and free resources.
  49134. */
  49135. dispose(): void;
  49136. /**
  49137. * Gets the class name of the effect layer
  49138. * @returns the string with the class name of the effect layer
  49139. */
  49140. getClassName(): string;
  49141. /**
  49142. * Serializes this Highlight layer
  49143. * @returns a serialized Highlight layer object
  49144. */
  49145. serialize(): any;
  49146. /**
  49147. * Creates a Highlight layer from parsed Highlight layer data
  49148. * @param parsedHightlightLayer defines the Highlight layer data
  49149. * @param scene defines the current scene
  49150. * @param rootUrl defines the root URL containing the Highlight layer information
  49151. * @returns a parsed Highlight layer
  49152. */
  49153. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  49154. }
  49155. }
  49156. declare module "babylonjs/Layers/index" {
  49157. export * from "babylonjs/Layers/effectLayer";
  49158. export * from "babylonjs/Layers/effectLayerSceneComponent";
  49159. export * from "babylonjs/Layers/glowLayer";
  49160. export * from "babylonjs/Layers/highlightLayer";
  49161. export * from "babylonjs/Layers/layer";
  49162. export * from "babylonjs/Layers/layerSceneComponent";
  49163. }
  49164. declare module "babylonjs/Shaders/lensFlare.fragment" {
  49165. /** @hidden */
  49166. export var lensFlarePixelShader: {
  49167. name: string;
  49168. shader: string;
  49169. };
  49170. }
  49171. declare module "babylonjs/Shaders/lensFlare.vertex" {
  49172. /** @hidden */
  49173. export var lensFlareVertexShader: {
  49174. name: string;
  49175. shader: string;
  49176. };
  49177. }
  49178. declare module "babylonjs/LensFlares/lensFlareSystem" {
  49179. import { Scene } from "babylonjs/scene";
  49180. import { Vector3, Viewport } from "babylonjs/Maths/math";
  49181. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49182. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  49183. import "babylonjs/Shaders/lensFlare.fragment";
  49184. import "babylonjs/Shaders/lensFlare.vertex";
  49185. /**
  49186. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49187. * It is usually composed of several `lensFlare`.
  49188. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49189. */
  49190. export class LensFlareSystem {
  49191. /**
  49192. * Define the name of the lens flare system
  49193. */
  49194. name: string;
  49195. /**
  49196. * List of lens flares used in this system.
  49197. */
  49198. lensFlares: LensFlare[];
  49199. /**
  49200. * Define a limit from the border the lens flare can be visible.
  49201. */
  49202. borderLimit: number;
  49203. /**
  49204. * Define a viewport border we do not want to see the lens flare in.
  49205. */
  49206. viewportBorder: number;
  49207. /**
  49208. * Define a predicate which could limit the list of meshes able to occlude the effect.
  49209. */
  49210. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49211. /**
  49212. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  49213. */
  49214. layerMask: number;
  49215. /**
  49216. * Define the id of the lens flare system in the scene.
  49217. * (equal to name by default)
  49218. */
  49219. id: string;
  49220. private _scene;
  49221. private _emitter;
  49222. private _vertexBuffers;
  49223. private _indexBuffer;
  49224. private _effect;
  49225. private _positionX;
  49226. private _positionY;
  49227. private _isEnabled;
  49228. /** @hidden */
  49229. static _SceneComponentInitialization: (scene: Scene) => void;
  49230. /**
  49231. * Instantiates a lens flare system.
  49232. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49233. * It is usually composed of several `lensFlare`.
  49234. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49235. * @param name Define the name of the lens flare system in the scene
  49236. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  49237. * @param scene Define the scene the lens flare system belongs to
  49238. */
  49239. constructor(
  49240. /**
  49241. * Define the name of the lens flare system
  49242. */
  49243. name: string, emitter: any, scene: Scene);
  49244. /**
  49245. * Define if the lens flare system is enabled.
  49246. */
  49247. isEnabled: boolean;
  49248. /**
  49249. * Get the scene the effects belongs to.
  49250. * @returns the scene holding the lens flare system
  49251. */
  49252. getScene(): Scene;
  49253. /**
  49254. * Get the emitter of the lens flare system.
  49255. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49256. * @returns the emitter of the lens flare system
  49257. */
  49258. getEmitter(): any;
  49259. /**
  49260. * Set the emitter of the lens flare system.
  49261. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49262. * @param newEmitter Define the new emitter of the system
  49263. */
  49264. setEmitter(newEmitter: any): void;
  49265. /**
  49266. * Get the lens flare system emitter position.
  49267. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  49268. * @returns the position
  49269. */
  49270. getEmitterPosition(): Vector3;
  49271. /**
  49272. * @hidden
  49273. */
  49274. computeEffectivePosition(globalViewport: Viewport): boolean;
  49275. /** @hidden */
  49276. _isVisible(): boolean;
  49277. /**
  49278. * @hidden
  49279. */
  49280. render(): boolean;
  49281. /**
  49282. * Dispose and release the lens flare with its associated resources.
  49283. */
  49284. dispose(): void;
  49285. /**
  49286. * Parse a lens flare system from a JSON repressentation
  49287. * @param parsedLensFlareSystem Define the JSON to parse
  49288. * @param scene Define the scene the parsed system should be instantiated in
  49289. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  49290. * @returns the parsed system
  49291. */
  49292. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  49293. /**
  49294. * Serialize the current Lens Flare System into a JSON representation.
  49295. * @returns the serialized JSON
  49296. */
  49297. serialize(): any;
  49298. }
  49299. }
  49300. declare module "babylonjs/LensFlares/lensFlare" {
  49301. import { Nullable } from "babylonjs/types";
  49302. import { Color3 } from "babylonjs/Maths/math";
  49303. import { Texture } from "babylonjs/Materials/Textures/texture";
  49304. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  49305. /**
  49306. * This represents one of the lens effect in a `lensFlareSystem`.
  49307. * It controls one of the indiviual texture used in the effect.
  49308. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49309. */
  49310. export class LensFlare {
  49311. /**
  49312. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49313. */
  49314. size: number;
  49315. /**
  49316. * 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.
  49317. */
  49318. position: number;
  49319. /**
  49320. * Define the lens color.
  49321. */
  49322. color: Color3;
  49323. /**
  49324. * Define the lens texture.
  49325. */
  49326. texture: Nullable<Texture>;
  49327. /**
  49328. * Define the alpha mode to render this particular lens.
  49329. */
  49330. alphaMode: number;
  49331. private _system;
  49332. /**
  49333. * Creates a new Lens Flare.
  49334. * This represents one of the lens effect in a `lensFlareSystem`.
  49335. * It controls one of the indiviual texture used in the effect.
  49336. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49337. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  49338. * @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.
  49339. * @param color Define the lens color
  49340. * @param imgUrl Define the lens texture url
  49341. * @param system Define the `lensFlareSystem` this flare is part of
  49342. * @returns The newly created Lens Flare
  49343. */
  49344. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  49345. /**
  49346. * Instantiates a new Lens Flare.
  49347. * This represents one of the lens effect in a `lensFlareSystem`.
  49348. * It controls one of the indiviual texture used in the effect.
  49349. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49350. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  49351. * @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.
  49352. * @param color Define the lens color
  49353. * @param imgUrl Define the lens texture url
  49354. * @param system Define the `lensFlareSystem` this flare is part of
  49355. */
  49356. constructor(
  49357. /**
  49358. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49359. */
  49360. size: number,
  49361. /**
  49362. * 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.
  49363. */
  49364. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  49365. /**
  49366. * Dispose and release the lens flare with its associated resources.
  49367. */
  49368. dispose(): void;
  49369. }
  49370. }
  49371. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  49372. import { Nullable } from "babylonjs/types";
  49373. import { Scene } from "babylonjs/scene";
  49374. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49375. import { AbstractScene } from "babylonjs/abstractScene";
  49376. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  49377. module "babylonjs/abstractScene" {
  49378. interface AbstractScene {
  49379. /**
  49380. * The list of lens flare system added to the scene
  49381. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49382. */
  49383. lensFlareSystems: Array<LensFlareSystem>;
  49384. /**
  49385. * Removes the given lens flare system from this scene.
  49386. * @param toRemove The lens flare system to remove
  49387. * @returns The index of the removed lens flare system
  49388. */
  49389. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  49390. /**
  49391. * Adds the given lens flare system to this scene
  49392. * @param newLensFlareSystem The lens flare system to add
  49393. */
  49394. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  49395. /**
  49396. * Gets a lens flare system using its name
  49397. * @param name defines the name to look for
  49398. * @returns the lens flare system or null if not found
  49399. */
  49400. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  49401. /**
  49402. * Gets a lens flare system using its id
  49403. * @param id defines the id to look for
  49404. * @returns the lens flare system or null if not found
  49405. */
  49406. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  49407. }
  49408. }
  49409. /**
  49410. * Defines the lens flare scene component responsible to manage any lens flares
  49411. * in a given scene.
  49412. */
  49413. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  49414. /**
  49415. * The component name helpfull to identify the component in the list of scene components.
  49416. */
  49417. readonly name: string;
  49418. /**
  49419. * The scene the component belongs to.
  49420. */
  49421. scene: Scene;
  49422. /**
  49423. * Creates a new instance of the component for the given scene
  49424. * @param scene Defines the scene to register the component in
  49425. */
  49426. constructor(scene: Scene);
  49427. /**
  49428. * Registers the component in a given scene
  49429. */
  49430. register(): void;
  49431. /**
  49432. * Rebuilds the elements related to this component in case of
  49433. * context lost for instance.
  49434. */
  49435. rebuild(): void;
  49436. /**
  49437. * Adds all the element from the container to the scene
  49438. * @param container the container holding the elements
  49439. */
  49440. addFromContainer(container: AbstractScene): void;
  49441. /**
  49442. * Removes all the elements in the container from the scene
  49443. * @param container contains the elements to remove
  49444. * @param dispose if the removed element should be disposed (default: false)
  49445. */
  49446. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49447. /**
  49448. * Serializes the component data to the specified json object
  49449. * @param serializationObject The object to serialize to
  49450. */
  49451. serialize(serializationObject: any): void;
  49452. /**
  49453. * Disposes the component and the associated ressources.
  49454. */
  49455. dispose(): void;
  49456. private _draw;
  49457. }
  49458. }
  49459. declare module "babylonjs/LensFlares/index" {
  49460. export * from "babylonjs/LensFlares/lensFlare";
  49461. export * from "babylonjs/LensFlares/lensFlareSystem";
  49462. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  49463. }
  49464. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  49465. import { Scene } from "babylonjs/scene";
  49466. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49467. import { AbstractScene } from "babylonjs/abstractScene";
  49468. /**
  49469. * Defines the shadow generator component responsible to manage any shadow generators
  49470. * in a given scene.
  49471. */
  49472. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  49473. /**
  49474. * The component name helpfull to identify the component in the list of scene components.
  49475. */
  49476. readonly name: string;
  49477. /**
  49478. * The scene the component belongs to.
  49479. */
  49480. scene: Scene;
  49481. /**
  49482. * Creates a new instance of the component for the given scene
  49483. * @param scene Defines the scene to register the component in
  49484. */
  49485. constructor(scene: Scene);
  49486. /**
  49487. * Registers the component in a given scene
  49488. */
  49489. register(): void;
  49490. /**
  49491. * Rebuilds the elements related to this component in case of
  49492. * context lost for instance.
  49493. */
  49494. rebuild(): void;
  49495. /**
  49496. * Serializes the component data to the specified json object
  49497. * @param serializationObject The object to serialize to
  49498. */
  49499. serialize(serializationObject: any): void;
  49500. /**
  49501. * Adds all the element from the container to the scene
  49502. * @param container the container holding the elements
  49503. */
  49504. addFromContainer(container: AbstractScene): void;
  49505. /**
  49506. * Removes all the elements in the container from the scene
  49507. * @param container contains the elements to remove
  49508. * @param dispose if the removed element should be disposed (default: false)
  49509. */
  49510. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49511. /**
  49512. * Rebuilds the elements related to this component in case of
  49513. * context lost for instance.
  49514. */
  49515. dispose(): void;
  49516. private _gatherRenderTargets;
  49517. }
  49518. }
  49519. declare module "babylonjs/Lights/Shadows/index" {
  49520. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  49521. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  49522. }
  49523. declare module "babylonjs/Lights/pointLight" {
  49524. import { Scene } from "babylonjs/scene";
  49525. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  49526. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49527. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  49528. import { Effect } from "babylonjs/Materials/effect";
  49529. /**
  49530. * A point light is a light defined by an unique point in world space.
  49531. * The light is emitted in every direction from this point.
  49532. * A good example of a point light is a standard light bulb.
  49533. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49534. */
  49535. export class PointLight extends ShadowLight {
  49536. private _shadowAngle;
  49537. /**
  49538. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49539. * This specifies what angle the shadow will use to be created.
  49540. *
  49541. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49542. */
  49543. /**
  49544. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49545. * This specifies what angle the shadow will use to be created.
  49546. *
  49547. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49548. */
  49549. shadowAngle: number;
  49550. /**
  49551. * Gets the direction if it has been set.
  49552. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49553. */
  49554. /**
  49555. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49556. */
  49557. direction: Vector3;
  49558. /**
  49559. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  49560. * A PointLight emits the light in every direction.
  49561. * It can cast shadows.
  49562. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  49563. * ```javascript
  49564. * var pointLight = new PointLight("pl", camera.position, scene);
  49565. * ```
  49566. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49567. * @param name The light friendly name
  49568. * @param position The position of the point light in the scene
  49569. * @param scene The scene the lights belongs to
  49570. */
  49571. constructor(name: string, position: Vector3, scene: Scene);
  49572. /**
  49573. * Returns the string "PointLight"
  49574. * @returns the class name
  49575. */
  49576. getClassName(): string;
  49577. /**
  49578. * Returns the integer 0.
  49579. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49580. */
  49581. getTypeID(): number;
  49582. /**
  49583. * Specifies wether or not the shadowmap should be a cube texture.
  49584. * @returns true if the shadowmap needs to be a cube texture.
  49585. */
  49586. needCube(): boolean;
  49587. /**
  49588. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  49589. * @param faceIndex The index of the face we are computed the direction to generate shadow
  49590. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  49591. */
  49592. getShadowDirection(faceIndex?: number): Vector3;
  49593. /**
  49594. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  49595. * - fov = PI / 2
  49596. * - aspect ratio : 1.0
  49597. * - z-near and far equal to the active camera minZ and maxZ.
  49598. * Returns the PointLight.
  49599. */
  49600. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49601. protected _buildUniformLayout(): void;
  49602. /**
  49603. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  49604. * @param effect The effect to update
  49605. * @param lightIndex The index of the light in the effect to update
  49606. * @returns The point light
  49607. */
  49608. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  49609. /**
  49610. * Prepares the list of defines specific to the light type.
  49611. * @param defines the list of defines
  49612. * @param lightIndex defines the index of the light for the effect
  49613. */
  49614. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49615. }
  49616. }
  49617. declare module "babylonjs/Lights/index" {
  49618. export * from "babylonjs/Lights/light";
  49619. export * from "babylonjs/Lights/shadowLight";
  49620. export * from "babylonjs/Lights/Shadows/index";
  49621. export * from "babylonjs/Lights/directionalLight";
  49622. export * from "babylonjs/Lights/hemisphericLight";
  49623. export * from "babylonjs/Lights/pointLight";
  49624. export * from "babylonjs/Lights/spotLight";
  49625. }
  49626. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  49627. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  49628. /**
  49629. * Header information of HDR texture files.
  49630. */
  49631. export interface HDRInfo {
  49632. /**
  49633. * The height of the texture in pixels.
  49634. */
  49635. height: number;
  49636. /**
  49637. * The width of the texture in pixels.
  49638. */
  49639. width: number;
  49640. /**
  49641. * The index of the beginning of the data in the binary file.
  49642. */
  49643. dataPosition: number;
  49644. }
  49645. /**
  49646. * This groups tools to convert HDR texture to native colors array.
  49647. */
  49648. export class HDRTools {
  49649. private static Ldexp;
  49650. private static Rgbe2float;
  49651. private static readStringLine;
  49652. /**
  49653. * Reads header information from an RGBE texture stored in a native array.
  49654. * More information on this format are available here:
  49655. * https://en.wikipedia.org/wiki/RGBE_image_format
  49656. *
  49657. * @param uint8array The binary file stored in native array.
  49658. * @return The header information.
  49659. */
  49660. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  49661. /**
  49662. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  49663. * This RGBE texture needs to store the information as a panorama.
  49664. *
  49665. * More information on this format are available here:
  49666. * https://en.wikipedia.org/wiki/RGBE_image_format
  49667. *
  49668. * @param buffer The binary file stored in an array buffer.
  49669. * @param size The expected size of the extracted cubemap.
  49670. * @return The Cube Map information.
  49671. */
  49672. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  49673. /**
  49674. * Returns the pixels data extracted from an RGBE texture.
  49675. * This pixels will be stored left to right up to down in the R G B order in one array.
  49676. *
  49677. * More information on this format are available here:
  49678. * https://en.wikipedia.org/wiki/RGBE_image_format
  49679. *
  49680. * @param uint8array The binary file stored in an array buffer.
  49681. * @param hdrInfo The header information of the file.
  49682. * @return The pixels data in RGB right to left up to down order.
  49683. */
  49684. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  49685. private static RGBE_ReadPixels_RLE;
  49686. }
  49687. }
  49688. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  49689. import { Nullable } from "babylonjs/types";
  49690. import { Scene } from "babylonjs/scene";
  49691. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  49692. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49693. /**
  49694. * This represents a texture coming from an HDR input.
  49695. *
  49696. * The only supported format is currently panorama picture stored in RGBE format.
  49697. * Example of such files can be found on HDRLib: http://hdrlib.com/
  49698. */
  49699. export class HDRCubeTexture extends BaseTexture {
  49700. private static _facesMapping;
  49701. private _generateHarmonics;
  49702. private _noMipmap;
  49703. private _textureMatrix;
  49704. private _size;
  49705. private _onLoad;
  49706. private _onError;
  49707. /**
  49708. * The texture URL.
  49709. */
  49710. url: string;
  49711. /**
  49712. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  49713. */
  49714. coordinatesMode: number;
  49715. protected _isBlocking: boolean;
  49716. /**
  49717. * Sets wether or not the texture is blocking during loading.
  49718. */
  49719. /**
  49720. * Gets wether or not the texture is blocking during loading.
  49721. */
  49722. isBlocking: boolean;
  49723. protected _rotationY: number;
  49724. /**
  49725. * Sets texture matrix rotation angle around Y axis in radians.
  49726. */
  49727. /**
  49728. * Gets texture matrix rotation angle around Y axis radians.
  49729. */
  49730. rotationY: number;
  49731. /**
  49732. * Gets or sets the center of the bounding box associated with the cube texture
  49733. * It must define where the camera used to render the texture was set
  49734. */
  49735. boundingBoxPosition: Vector3;
  49736. private _boundingBoxSize;
  49737. /**
  49738. * Gets or sets the size of the bounding box associated with the cube texture
  49739. * When defined, the cubemap will switch to local mode
  49740. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  49741. * @example https://www.babylonjs-playground.com/#RNASML
  49742. */
  49743. boundingBoxSize: Vector3;
  49744. /**
  49745. * Instantiates an HDRTexture from the following parameters.
  49746. *
  49747. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  49748. * @param scene The scene the texture will be used in
  49749. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49750. * @param noMipmap Forces to not generate the mipmap if true
  49751. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  49752. * @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)
  49753. * @param reserved Reserved flag for internal use.
  49754. */
  49755. 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>);
  49756. /**
  49757. * Get the current class name of the texture useful for serialization or dynamic coding.
  49758. * @returns "HDRCubeTexture"
  49759. */
  49760. getClassName(): string;
  49761. /**
  49762. * Occurs when the file is raw .hdr file.
  49763. */
  49764. private loadTexture;
  49765. clone(): HDRCubeTexture;
  49766. delayLoad(): void;
  49767. /**
  49768. * Get the texture reflection matrix used to rotate/transform the reflection.
  49769. * @returns the reflection matrix
  49770. */
  49771. getReflectionTextureMatrix(): Matrix;
  49772. /**
  49773. * Set the texture reflection matrix used to rotate/transform the reflection.
  49774. * @param value Define the reflection matrix to set
  49775. */
  49776. setReflectionTextureMatrix(value: Matrix): void;
  49777. /**
  49778. * Parses a JSON representation of an HDR Texture in order to create the texture
  49779. * @param parsedTexture Define the JSON representation
  49780. * @param scene Define the scene the texture should be created in
  49781. * @param rootUrl Define the root url in case we need to load relative dependencies
  49782. * @returns the newly created texture after parsing
  49783. */
  49784. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  49785. serialize(): any;
  49786. }
  49787. }
  49788. declare module "babylonjs/Physics/physicsEngine" {
  49789. import { Nullable } from "babylonjs/types";
  49790. import { Vector3 } from "babylonjs/Maths/math";
  49791. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  49792. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  49793. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  49794. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49795. /**
  49796. * Class used to control physics engine
  49797. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  49798. */
  49799. export class PhysicsEngine implements IPhysicsEngine {
  49800. private _physicsPlugin;
  49801. /**
  49802. * Global value used to control the smallest number supported by the simulation
  49803. */
  49804. static Epsilon: number;
  49805. private _impostors;
  49806. private _joints;
  49807. /**
  49808. * Gets the gravity vector used by the simulation
  49809. */
  49810. gravity: Vector3;
  49811. /**
  49812. * Factory used to create the default physics plugin.
  49813. * @returns The default physics plugin
  49814. */
  49815. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  49816. /**
  49817. * Creates a new Physics Engine
  49818. * @param gravity defines the gravity vector used by the simulation
  49819. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  49820. */
  49821. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  49822. /**
  49823. * Sets the gravity vector used by the simulation
  49824. * @param gravity defines the gravity vector to use
  49825. */
  49826. setGravity(gravity: Vector3): void;
  49827. /**
  49828. * Set the time step of the physics engine.
  49829. * Default is 1/60.
  49830. * To slow it down, enter 1/600 for example.
  49831. * To speed it up, 1/30
  49832. * @param newTimeStep defines the new timestep to apply to this world.
  49833. */
  49834. setTimeStep(newTimeStep?: number): void;
  49835. /**
  49836. * Get the time step of the physics engine.
  49837. * @returns the current time step
  49838. */
  49839. getTimeStep(): number;
  49840. /**
  49841. * Release all resources
  49842. */
  49843. dispose(): void;
  49844. /**
  49845. * Gets the name of the current physics plugin
  49846. * @returns the name of the plugin
  49847. */
  49848. getPhysicsPluginName(): string;
  49849. /**
  49850. * Adding a new impostor for the impostor tracking.
  49851. * This will be done by the impostor itself.
  49852. * @param impostor the impostor to add
  49853. */
  49854. addImpostor(impostor: PhysicsImpostor): void;
  49855. /**
  49856. * Remove an impostor from the engine.
  49857. * This impostor and its mesh will not longer be updated by the physics engine.
  49858. * @param impostor the impostor to remove
  49859. */
  49860. removeImpostor(impostor: PhysicsImpostor): void;
  49861. /**
  49862. * Add a joint to the physics engine
  49863. * @param mainImpostor defines the main impostor to which the joint is added.
  49864. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  49865. * @param joint defines the joint that will connect both impostors.
  49866. */
  49867. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49868. /**
  49869. * Removes a joint from the simulation
  49870. * @param mainImpostor defines the impostor used with the joint
  49871. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  49872. * @param joint defines the joint to remove
  49873. */
  49874. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49875. /**
  49876. * Called by the scene. No need to call it.
  49877. * @param delta defines the timespam between frames
  49878. */
  49879. _step(delta: number): void;
  49880. /**
  49881. * Gets the current plugin used to run the simulation
  49882. * @returns current plugin
  49883. */
  49884. getPhysicsPlugin(): IPhysicsEnginePlugin;
  49885. /**
  49886. * Gets the list of physic impostors
  49887. * @returns an array of PhysicsImpostor
  49888. */
  49889. getImpostors(): Array<PhysicsImpostor>;
  49890. /**
  49891. * Gets the impostor for a physics enabled object
  49892. * @param object defines the object impersonated by the impostor
  49893. * @returns the PhysicsImpostor or null if not found
  49894. */
  49895. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  49896. /**
  49897. * Gets the impostor for a physics body object
  49898. * @param body defines physics body used by the impostor
  49899. * @returns the PhysicsImpostor or null if not found
  49900. */
  49901. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  49902. /**
  49903. * Does a raycast in the physics world
  49904. * @param from when should the ray start?
  49905. * @param to when should the ray end?
  49906. * @returns PhysicsRaycastResult
  49907. */
  49908. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49909. }
  49910. }
  49911. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  49912. import { Nullable } from "babylonjs/types";
  49913. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  49914. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49915. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  49916. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  49917. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  49918. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49919. /** @hidden */
  49920. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  49921. private _useDeltaForWorldStep;
  49922. world: any;
  49923. name: string;
  49924. private _physicsMaterials;
  49925. private _fixedTimeStep;
  49926. private _cannonRaycastResult;
  49927. private _raycastResult;
  49928. private _removeAfterStep;
  49929. BJSCANNON: any;
  49930. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  49931. setGravity(gravity: Vector3): void;
  49932. setTimeStep(timeStep: number): void;
  49933. getTimeStep(): number;
  49934. executeStep(delta: number): void;
  49935. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49936. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49937. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49938. private _processChildMeshes;
  49939. removePhysicsBody(impostor: PhysicsImpostor): void;
  49940. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49941. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49942. private _addMaterial;
  49943. private _checkWithEpsilon;
  49944. private _createShape;
  49945. private _createHeightmap;
  49946. private _minus90X;
  49947. private _plus90X;
  49948. private _tmpPosition;
  49949. private _tmpDeltaPosition;
  49950. private _tmpUnityRotation;
  49951. private _updatePhysicsBodyTransformation;
  49952. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49953. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49954. isSupported(): boolean;
  49955. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49956. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49957. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49958. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49959. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49960. getBodyMass(impostor: PhysicsImpostor): number;
  49961. getBodyFriction(impostor: PhysicsImpostor): number;
  49962. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49963. getBodyRestitution(impostor: PhysicsImpostor): number;
  49964. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49965. sleepBody(impostor: PhysicsImpostor): void;
  49966. wakeUpBody(impostor: PhysicsImpostor): void;
  49967. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  49968. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49969. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49970. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49971. getRadius(impostor: PhysicsImpostor): number;
  49972. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49973. dispose(): void;
  49974. private _extendNamespace;
  49975. /**
  49976. * Does a raycast in the physics world
  49977. * @param from when should the ray start?
  49978. * @param to when should the ray end?
  49979. * @returns PhysicsRaycastResult
  49980. */
  49981. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49982. }
  49983. }
  49984. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  49985. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  49986. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  49987. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  49988. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49989. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  49990. import { Nullable } from "babylonjs/types";
  49991. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49992. /** @hidden */
  49993. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  49994. world: any;
  49995. name: string;
  49996. BJSOIMO: any;
  49997. private _raycastResult;
  49998. constructor(iterations?: number, oimoInjection?: any);
  49999. setGravity(gravity: Vector3): void;
  50000. setTimeStep(timeStep: number): void;
  50001. getTimeStep(): number;
  50002. private _tmpImpostorsArray;
  50003. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50004. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50005. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50006. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50007. private _tmpPositionVector;
  50008. removePhysicsBody(impostor: PhysicsImpostor): void;
  50009. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50010. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50011. isSupported(): boolean;
  50012. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50013. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50014. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50015. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50016. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50017. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50018. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50019. getBodyMass(impostor: PhysicsImpostor): number;
  50020. getBodyFriction(impostor: PhysicsImpostor): number;
  50021. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50022. getBodyRestitution(impostor: PhysicsImpostor): number;
  50023. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50024. sleepBody(impostor: PhysicsImpostor): void;
  50025. wakeUpBody(impostor: PhysicsImpostor): void;
  50026. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50027. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  50028. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  50029. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50030. getRadius(impostor: PhysicsImpostor): number;
  50031. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50032. dispose(): void;
  50033. /**
  50034. * Does a raycast in the physics world
  50035. * @param from when should the ray start?
  50036. * @param to when should the ray end?
  50037. * @returns PhysicsRaycastResult
  50038. */
  50039. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50040. }
  50041. }
  50042. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  50043. import { Nullable } from "babylonjs/types";
  50044. import { Scene } from "babylonjs/scene";
  50045. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  50046. import { Mesh } from "babylonjs/Meshes/mesh";
  50047. /**
  50048. * Class containing static functions to help procedurally build meshes
  50049. */
  50050. export class RibbonBuilder {
  50051. /**
  50052. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50053. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50054. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50055. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50056. * * 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
  50057. * * 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
  50058. * * 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
  50059. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50060. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50061. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50062. * * 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
  50063. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50064. * * 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
  50065. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50066. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50067. * @param name defines the name of the mesh
  50068. * @param options defines the options used to create the mesh
  50069. * @param scene defines the hosting scene
  50070. * @returns the ribbon mesh
  50071. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50072. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50073. */
  50074. static CreateRibbon(name: string, options: {
  50075. pathArray: Vector3[][];
  50076. closeArray?: boolean;
  50077. closePath?: boolean;
  50078. offset?: number;
  50079. updatable?: boolean;
  50080. sideOrientation?: number;
  50081. frontUVs?: Vector4;
  50082. backUVs?: Vector4;
  50083. instance?: Mesh;
  50084. invertUV?: boolean;
  50085. uvs?: Vector2[];
  50086. colors?: Color4[];
  50087. }, scene?: Nullable<Scene>): Mesh;
  50088. }
  50089. }
  50090. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  50091. import { Nullable } from "babylonjs/types";
  50092. import { Scene } from "babylonjs/scene";
  50093. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50094. import { Mesh } from "babylonjs/Meshes/mesh";
  50095. /**
  50096. * Class containing static functions to help procedurally build meshes
  50097. */
  50098. export class ShapeBuilder {
  50099. /**
  50100. * 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.
  50101. * * 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.
  50102. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50103. * * 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.
  50104. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50105. * * 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
  50106. * * 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
  50107. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50108. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50109. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50110. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50111. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50112. * @param name defines the name of the mesh
  50113. * @param options defines the options used to create the mesh
  50114. * @param scene defines the hosting scene
  50115. * @returns the extruded shape mesh
  50116. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50117. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50118. */
  50119. static ExtrudeShape(name: string, options: {
  50120. shape: Vector3[];
  50121. path: Vector3[];
  50122. scale?: number;
  50123. rotation?: number;
  50124. cap?: number;
  50125. updatable?: boolean;
  50126. sideOrientation?: number;
  50127. frontUVs?: Vector4;
  50128. backUVs?: Vector4;
  50129. instance?: Mesh;
  50130. invertUV?: boolean;
  50131. }, scene?: Nullable<Scene>): Mesh;
  50132. /**
  50133. * Creates an custom extruded shape mesh.
  50134. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50135. * * 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.
  50136. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50137. * * 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
  50138. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50139. * * 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
  50140. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50141. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50142. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50143. * * 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
  50144. * * 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
  50145. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50146. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50147. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50148. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50149. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50150. * @param name defines the name of the mesh
  50151. * @param options defines the options used to create the mesh
  50152. * @param scene defines the hosting scene
  50153. * @returns the custom extruded shape mesh
  50154. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50155. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50156. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50157. */
  50158. static ExtrudeShapeCustom(name: string, options: {
  50159. shape: Vector3[];
  50160. path: Vector3[];
  50161. scaleFunction?: any;
  50162. rotationFunction?: any;
  50163. ribbonCloseArray?: boolean;
  50164. ribbonClosePath?: boolean;
  50165. cap?: number;
  50166. updatable?: boolean;
  50167. sideOrientation?: number;
  50168. frontUVs?: Vector4;
  50169. backUVs?: Vector4;
  50170. instance?: Mesh;
  50171. invertUV?: boolean;
  50172. }, scene?: Nullable<Scene>): Mesh;
  50173. private static _ExtrudeShapeGeneric;
  50174. }
  50175. }
  50176. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  50177. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  50178. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50179. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50180. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50181. import { Nullable } from "babylonjs/types";
  50182. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50183. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50184. /**
  50185. * AmmoJS Physics plugin
  50186. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50187. * @see https://github.com/kripken/ammo.js/
  50188. */
  50189. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  50190. private _useDeltaForWorldStep;
  50191. /**
  50192. * Reference to the Ammo library
  50193. */
  50194. bjsAMMO: any;
  50195. /**
  50196. * Created ammoJS world which physics bodies are added to
  50197. */
  50198. world: any;
  50199. /**
  50200. * Name of the plugin
  50201. */
  50202. name: string;
  50203. private _timeStep;
  50204. private _fixedTimeStep;
  50205. private _maxSteps;
  50206. private _tmpQuaternion;
  50207. private _tmpAmmoTransform;
  50208. private _tmpAmmoQuaternion;
  50209. private _tmpAmmoConcreteContactResultCallback;
  50210. private _collisionConfiguration;
  50211. private _dispatcher;
  50212. private _overlappingPairCache;
  50213. private _solver;
  50214. private _softBodySolver;
  50215. private _tmpAmmoVectorA;
  50216. private _tmpAmmoVectorB;
  50217. private _tmpAmmoVectorC;
  50218. private _tmpAmmoVectorD;
  50219. private _tmpContactCallbackResult;
  50220. private _tmpAmmoVectorRCA;
  50221. private _tmpAmmoVectorRCB;
  50222. private _raycastResult;
  50223. private static readonly DISABLE_COLLISION_FLAG;
  50224. private static readonly KINEMATIC_FLAG;
  50225. private static readonly DISABLE_DEACTIVATION_FLAG;
  50226. /**
  50227. * Initializes the ammoJS plugin
  50228. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  50229. * @param ammoInjection can be used to inject your own ammo reference
  50230. */
  50231. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  50232. /**
  50233. * Sets the gravity of the physics world (m/(s^2))
  50234. * @param gravity Gravity to set
  50235. */
  50236. setGravity(gravity: Vector3): void;
  50237. /**
  50238. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  50239. * @param timeStep timestep to use in seconds
  50240. */
  50241. setTimeStep(timeStep: number): void;
  50242. /**
  50243. * 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)
  50244. * @param fixedTimeStep fixedTimeStep to use in seconds
  50245. */
  50246. setFixedTimeStep(fixedTimeStep: number): void;
  50247. /**
  50248. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  50249. * @param maxSteps the maximum number of steps by the physics engine per frame
  50250. */
  50251. setMaxSteps(maxSteps: number): void;
  50252. /**
  50253. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  50254. * @returns the current timestep in seconds
  50255. */
  50256. getTimeStep(): number;
  50257. private _isImpostorInContact;
  50258. private _isImpostorPairInContact;
  50259. private _stepSimulation;
  50260. /**
  50261. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  50262. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  50263. * After the step the babylon meshes are set to the position of the physics imposters
  50264. * @param delta amount of time to step forward
  50265. * @param impostors array of imposters to update before/after the step
  50266. */
  50267. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50268. /**
  50269. * Update babylon mesh to match physics world object
  50270. * @param impostor imposter to match
  50271. */
  50272. private _afterSoftStep;
  50273. /**
  50274. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50275. * @param impostor imposter to match
  50276. */
  50277. private _ropeStep;
  50278. /**
  50279. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50280. * @param impostor imposter to match
  50281. */
  50282. private _softbodyOrClothStep;
  50283. private _tmpVector;
  50284. private _tmpMatrix;
  50285. /**
  50286. * Applies an impulse on the imposter
  50287. * @param impostor imposter to apply impulse to
  50288. * @param force amount of force to be applied to the imposter
  50289. * @param contactPoint the location to apply the impulse on the imposter
  50290. */
  50291. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50292. /**
  50293. * Applies a force on the imposter
  50294. * @param impostor imposter to apply force
  50295. * @param force amount of force to be applied to the imposter
  50296. * @param contactPoint the location to apply the force on the imposter
  50297. */
  50298. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50299. /**
  50300. * Creates a physics body using the plugin
  50301. * @param impostor the imposter to create the physics body on
  50302. */
  50303. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50304. /**
  50305. * Removes the physics body from the imposter and disposes of the body's memory
  50306. * @param impostor imposter to remove the physics body from
  50307. */
  50308. removePhysicsBody(impostor: PhysicsImpostor): void;
  50309. /**
  50310. * Generates a joint
  50311. * @param impostorJoint the imposter joint to create the joint with
  50312. */
  50313. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50314. /**
  50315. * Removes a joint
  50316. * @param impostorJoint the imposter joint to remove the joint from
  50317. */
  50318. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50319. private _addMeshVerts;
  50320. /**
  50321. * Initialise the soft body vertices to match its object's (mesh) vertices
  50322. * Softbody vertices (nodes) are in world space and to match this
  50323. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  50324. * @param impostor to create the softbody for
  50325. */
  50326. private _softVertexData;
  50327. /**
  50328. * Create an impostor's soft body
  50329. * @param impostor to create the softbody for
  50330. */
  50331. private _createSoftbody;
  50332. /**
  50333. * Create cloth for an impostor
  50334. * @param impostor to create the softbody for
  50335. */
  50336. private _createCloth;
  50337. /**
  50338. * Create rope for an impostor
  50339. * @param impostor to create the softbody for
  50340. */
  50341. private _createRope;
  50342. private _addHullVerts;
  50343. private _createShape;
  50344. /**
  50345. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50346. * @param impostor imposter containing the physics body and babylon object
  50347. */
  50348. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50349. /**
  50350. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50351. * @param impostor imposter containing the physics body and babylon object
  50352. * @param newPosition new position
  50353. * @param newRotation new rotation
  50354. */
  50355. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50356. /**
  50357. * If this plugin is supported
  50358. * @returns true if its supported
  50359. */
  50360. isSupported(): boolean;
  50361. /**
  50362. * Sets the linear velocity of the physics body
  50363. * @param impostor imposter to set the velocity on
  50364. * @param velocity velocity to set
  50365. */
  50366. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50367. /**
  50368. * Sets the angular velocity of the physics body
  50369. * @param impostor imposter to set the velocity on
  50370. * @param velocity velocity to set
  50371. */
  50372. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50373. /**
  50374. * gets the linear velocity
  50375. * @param impostor imposter to get linear velocity from
  50376. * @returns linear velocity
  50377. */
  50378. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50379. /**
  50380. * gets the angular velocity
  50381. * @param impostor imposter to get angular velocity from
  50382. * @returns angular velocity
  50383. */
  50384. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50385. /**
  50386. * Sets the mass of physics body
  50387. * @param impostor imposter to set the mass on
  50388. * @param mass mass to set
  50389. */
  50390. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50391. /**
  50392. * Gets the mass of the physics body
  50393. * @param impostor imposter to get the mass from
  50394. * @returns mass
  50395. */
  50396. getBodyMass(impostor: PhysicsImpostor): number;
  50397. /**
  50398. * Gets friction of the impostor
  50399. * @param impostor impostor to get friction from
  50400. * @returns friction value
  50401. */
  50402. getBodyFriction(impostor: PhysicsImpostor): number;
  50403. /**
  50404. * Sets friction of the impostor
  50405. * @param impostor impostor to set friction on
  50406. * @param friction friction value
  50407. */
  50408. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50409. /**
  50410. * Gets restitution of the impostor
  50411. * @param impostor impostor to get restitution from
  50412. * @returns restitution value
  50413. */
  50414. getBodyRestitution(impostor: PhysicsImpostor): number;
  50415. /**
  50416. * Sets resitution of the impostor
  50417. * @param impostor impostor to set resitution on
  50418. * @param restitution resitution value
  50419. */
  50420. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50421. /**
  50422. * Gets pressure inside the impostor
  50423. * @param impostor impostor to get pressure from
  50424. * @returns pressure value
  50425. */
  50426. getBodyPressure(impostor: PhysicsImpostor): number;
  50427. /**
  50428. * Sets pressure inside a soft body impostor
  50429. * Cloth and rope must remain 0 pressure
  50430. * @param impostor impostor to set pressure on
  50431. * @param pressure pressure value
  50432. */
  50433. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  50434. /**
  50435. * Gets stiffness of the impostor
  50436. * @param impostor impostor to get stiffness from
  50437. * @returns pressure value
  50438. */
  50439. getBodyStiffness(impostor: PhysicsImpostor): number;
  50440. /**
  50441. * Sets stiffness of the impostor
  50442. * @param impostor impostor to set stiffness on
  50443. * @param stiffness stiffness value from 0 to 1
  50444. */
  50445. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  50446. /**
  50447. * Gets velocityIterations of the impostor
  50448. * @param impostor impostor to get velocity iterations from
  50449. * @returns velocityIterations value
  50450. */
  50451. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  50452. /**
  50453. * Sets velocityIterations of the impostor
  50454. * @param impostor impostor to set velocity iterations on
  50455. * @param velocityIterations velocityIterations value
  50456. */
  50457. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  50458. /**
  50459. * Gets positionIterations of the impostor
  50460. * @param impostor impostor to get position iterations from
  50461. * @returns positionIterations value
  50462. */
  50463. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  50464. /**
  50465. * Sets positionIterations of the impostor
  50466. * @param impostor impostor to set position on
  50467. * @param positionIterations positionIterations value
  50468. */
  50469. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  50470. /**
  50471. * Append an anchor to a cloth object
  50472. * @param impostor is the cloth impostor to add anchor to
  50473. * @param otherImpostor is the rigid impostor to anchor to
  50474. * @param width ratio across width from 0 to 1
  50475. * @param height ratio up height from 0 to 1
  50476. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  50477. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50478. */
  50479. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50480. /**
  50481. * Append an hook to a rope object
  50482. * @param impostor is the rope impostor to add hook to
  50483. * @param otherImpostor is the rigid impostor to hook to
  50484. * @param length ratio along the rope from 0 to 1
  50485. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  50486. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50487. */
  50488. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50489. /**
  50490. * Sleeps the physics body and stops it from being active
  50491. * @param impostor impostor to sleep
  50492. */
  50493. sleepBody(impostor: PhysicsImpostor): void;
  50494. /**
  50495. * Activates the physics body
  50496. * @param impostor impostor to activate
  50497. */
  50498. wakeUpBody(impostor: PhysicsImpostor): void;
  50499. /**
  50500. * Updates the distance parameters of the joint
  50501. * @param joint joint to update
  50502. * @param maxDistance maximum distance of the joint
  50503. * @param minDistance minimum distance of the joint
  50504. */
  50505. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50506. /**
  50507. * Sets a motor on the joint
  50508. * @param joint joint to set motor on
  50509. * @param speed speed of the motor
  50510. * @param maxForce maximum force of the motor
  50511. * @param motorIndex index of the motor
  50512. */
  50513. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50514. /**
  50515. * Sets the motors limit
  50516. * @param joint joint to set limit on
  50517. * @param upperLimit upper limit
  50518. * @param lowerLimit lower limit
  50519. */
  50520. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50521. /**
  50522. * Syncs the position and rotation of a mesh with the impostor
  50523. * @param mesh mesh to sync
  50524. * @param impostor impostor to update the mesh with
  50525. */
  50526. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50527. /**
  50528. * Gets the radius of the impostor
  50529. * @param impostor impostor to get radius from
  50530. * @returns the radius
  50531. */
  50532. getRadius(impostor: PhysicsImpostor): number;
  50533. /**
  50534. * Gets the box size of the impostor
  50535. * @param impostor impostor to get box size from
  50536. * @param result the resulting box size
  50537. */
  50538. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50539. /**
  50540. * Disposes of the impostor
  50541. */
  50542. dispose(): void;
  50543. /**
  50544. * Does a raycast in the physics world
  50545. * @param from when should the ray start?
  50546. * @param to when should the ray end?
  50547. * @returns PhysicsRaycastResult
  50548. */
  50549. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50550. }
  50551. }
  50552. declare module "babylonjs/Probes/reflectionProbe" {
  50553. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50554. import { Vector3 } from "babylonjs/Maths/math";
  50555. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50556. import { Nullable } from "babylonjs/types";
  50557. import { Scene } from "babylonjs/scene";
  50558. module "babylonjs/abstractScene" {
  50559. interface AbstractScene {
  50560. /**
  50561. * The list of reflection probes added to the scene
  50562. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50563. */
  50564. reflectionProbes: Array<ReflectionProbe>;
  50565. /**
  50566. * Removes the given reflection probe from this scene.
  50567. * @param toRemove The reflection probe to remove
  50568. * @returns The index of the removed reflection probe
  50569. */
  50570. removeReflectionProbe(toRemove: ReflectionProbe): number;
  50571. /**
  50572. * Adds the given reflection probe to this scene.
  50573. * @param newReflectionProbe The reflection probe to add
  50574. */
  50575. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  50576. }
  50577. }
  50578. /**
  50579. * Class used to generate realtime reflection / refraction cube textures
  50580. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50581. */
  50582. export class ReflectionProbe {
  50583. /** defines the name of the probe */
  50584. name: string;
  50585. private _scene;
  50586. private _renderTargetTexture;
  50587. private _projectionMatrix;
  50588. private _viewMatrix;
  50589. private _target;
  50590. private _add;
  50591. private _attachedMesh;
  50592. private _invertYAxis;
  50593. /** Gets or sets probe position (center of the cube map) */
  50594. position: Vector3;
  50595. /**
  50596. * Creates a new reflection probe
  50597. * @param name defines the name of the probe
  50598. * @param size defines the texture resolution (for each face)
  50599. * @param scene defines the hosting scene
  50600. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  50601. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  50602. */
  50603. constructor(
  50604. /** defines the name of the probe */
  50605. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  50606. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  50607. samples: number;
  50608. /** Gets or sets the refresh rate to use (on every frame by default) */
  50609. refreshRate: number;
  50610. /**
  50611. * Gets the hosting scene
  50612. * @returns a Scene
  50613. */
  50614. getScene(): Scene;
  50615. /** Gets the internal CubeTexture used to render to */
  50616. readonly cubeTexture: RenderTargetTexture;
  50617. /** Gets the list of meshes to render */
  50618. readonly renderList: Nullable<AbstractMesh[]>;
  50619. /**
  50620. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  50621. * @param mesh defines the mesh to attach to
  50622. */
  50623. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50624. /**
  50625. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  50626. * @param renderingGroupId The rendering group id corresponding to its index
  50627. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  50628. */
  50629. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  50630. /**
  50631. * Clean all associated resources
  50632. */
  50633. dispose(): void;
  50634. /**
  50635. * Converts the reflection probe information to a readable string for debug purpose.
  50636. * @param fullDetails Supports for multiple levels of logging within scene loading
  50637. * @returns the human readable reflection probe info
  50638. */
  50639. toString(fullDetails?: boolean): string;
  50640. /**
  50641. * Get the class name of the relfection probe.
  50642. * @returns "ReflectionProbe"
  50643. */
  50644. getClassName(): string;
  50645. /**
  50646. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  50647. * @returns The JSON representation of the texture
  50648. */
  50649. serialize(): any;
  50650. /**
  50651. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  50652. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  50653. * @param scene Define the scene the parsed reflection probe should be instantiated in
  50654. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  50655. * @returns The parsed reflection probe if successful
  50656. */
  50657. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  50658. }
  50659. }
  50660. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  50661. /** @hidden */
  50662. export var _BabylonLoaderRegistered: boolean;
  50663. }
  50664. declare module "babylonjs/Loading/Plugins/index" {
  50665. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  50666. }
  50667. declare module "babylonjs/Loading/index" {
  50668. export * from "babylonjs/Loading/loadingScreen";
  50669. export * from "babylonjs/Loading/Plugins/index";
  50670. export * from "babylonjs/Loading/sceneLoader";
  50671. export * from "babylonjs/Loading/sceneLoaderFlags";
  50672. }
  50673. declare module "babylonjs/Materials/Background/index" {
  50674. export * from "babylonjs/Materials/Background/backgroundMaterial";
  50675. }
  50676. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  50677. import { Scene } from "babylonjs/scene";
  50678. import { Color3 } from "babylonjs/Maths/math";
  50679. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50680. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50681. /**
  50682. * The Physically based simple base material of BJS.
  50683. *
  50684. * This enables better naming and convention enforcements on top of the pbrMaterial.
  50685. * It is used as the base class for both the specGloss and metalRough conventions.
  50686. */
  50687. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  50688. /**
  50689. * Number of Simultaneous lights allowed on the material.
  50690. */
  50691. maxSimultaneousLights: number;
  50692. /**
  50693. * If sets to true, disables all the lights affecting the material.
  50694. */
  50695. disableLighting: boolean;
  50696. /**
  50697. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  50698. */
  50699. environmentTexture: BaseTexture;
  50700. /**
  50701. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50702. */
  50703. invertNormalMapX: boolean;
  50704. /**
  50705. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50706. */
  50707. invertNormalMapY: boolean;
  50708. /**
  50709. * Normal map used in the model.
  50710. */
  50711. normalTexture: BaseTexture;
  50712. /**
  50713. * Emissivie color used to self-illuminate the model.
  50714. */
  50715. emissiveColor: Color3;
  50716. /**
  50717. * Emissivie texture used to self-illuminate the model.
  50718. */
  50719. emissiveTexture: BaseTexture;
  50720. /**
  50721. * Occlusion Channel Strenght.
  50722. */
  50723. occlusionStrength: number;
  50724. /**
  50725. * Occlusion Texture of the material (adding extra occlusion effects).
  50726. */
  50727. occlusionTexture: BaseTexture;
  50728. /**
  50729. * Defines the alpha limits in alpha test mode.
  50730. */
  50731. alphaCutOff: number;
  50732. /**
  50733. * Gets the current double sided mode.
  50734. */
  50735. /**
  50736. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50737. */
  50738. doubleSided: boolean;
  50739. /**
  50740. * Stores the pre-calculated light information of a mesh in a texture.
  50741. */
  50742. lightmapTexture: BaseTexture;
  50743. /**
  50744. * If true, the light map contains occlusion information instead of lighting info.
  50745. */
  50746. useLightmapAsShadowmap: boolean;
  50747. /**
  50748. * Instantiates a new PBRMaterial instance.
  50749. *
  50750. * @param name The material name
  50751. * @param scene The scene the material will be use in.
  50752. */
  50753. constructor(name: string, scene: Scene);
  50754. getClassName(): string;
  50755. }
  50756. }
  50757. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  50758. import { Scene } from "babylonjs/scene";
  50759. import { Color3 } from "babylonjs/Maths/math";
  50760. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50761. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  50762. /**
  50763. * The PBR material of BJS following the metal roughness convention.
  50764. *
  50765. * This fits to the PBR convention in the GLTF definition:
  50766. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  50767. */
  50768. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  50769. /**
  50770. * The base color has two different interpretations depending on the value of metalness.
  50771. * When the material is a metal, the base color is the specific measured reflectance value
  50772. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  50773. * of the material.
  50774. */
  50775. baseColor: Color3;
  50776. /**
  50777. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  50778. * well as opacity information in the alpha channel.
  50779. */
  50780. baseTexture: BaseTexture;
  50781. /**
  50782. * Specifies the metallic scalar value of the material.
  50783. * Can also be used to scale the metalness values of the metallic texture.
  50784. */
  50785. metallic: number;
  50786. /**
  50787. * Specifies the roughness scalar value of the material.
  50788. * Can also be used to scale the roughness values of the metallic texture.
  50789. */
  50790. roughness: number;
  50791. /**
  50792. * Texture containing both the metallic value in the B channel and the
  50793. * roughness value in the G channel to keep better precision.
  50794. */
  50795. metallicRoughnessTexture: BaseTexture;
  50796. /**
  50797. * Instantiates a new PBRMetalRoughnessMaterial instance.
  50798. *
  50799. * @param name The material name
  50800. * @param scene The scene the material will be use in.
  50801. */
  50802. constructor(name: string, scene: Scene);
  50803. /**
  50804. * Return the currrent class name of the material.
  50805. */
  50806. getClassName(): string;
  50807. /**
  50808. * Makes a duplicate of the current material.
  50809. * @param name - name to use for the new material.
  50810. */
  50811. clone(name: string): PBRMetallicRoughnessMaterial;
  50812. /**
  50813. * Serialize the material to a parsable JSON object.
  50814. */
  50815. serialize(): any;
  50816. /**
  50817. * Parses a JSON object correponding to the serialize function.
  50818. */
  50819. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  50820. }
  50821. }
  50822. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  50823. import { Scene } from "babylonjs/scene";
  50824. import { Color3 } from "babylonjs/Maths/math";
  50825. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50826. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  50827. /**
  50828. * The PBR material of BJS following the specular glossiness convention.
  50829. *
  50830. * This fits to the PBR convention in the GLTF definition:
  50831. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  50832. */
  50833. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  50834. /**
  50835. * Specifies the diffuse color of the material.
  50836. */
  50837. diffuseColor: Color3;
  50838. /**
  50839. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  50840. * channel.
  50841. */
  50842. diffuseTexture: BaseTexture;
  50843. /**
  50844. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  50845. */
  50846. specularColor: Color3;
  50847. /**
  50848. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  50849. */
  50850. glossiness: number;
  50851. /**
  50852. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  50853. */
  50854. specularGlossinessTexture: BaseTexture;
  50855. /**
  50856. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  50857. *
  50858. * @param name The material name
  50859. * @param scene The scene the material will be use in.
  50860. */
  50861. constructor(name: string, scene: Scene);
  50862. /**
  50863. * Return the currrent class name of the material.
  50864. */
  50865. getClassName(): string;
  50866. /**
  50867. * Makes a duplicate of the current material.
  50868. * @param name - name to use for the new material.
  50869. */
  50870. clone(name: string): PBRSpecularGlossinessMaterial;
  50871. /**
  50872. * Serialize the material to a parsable JSON object.
  50873. */
  50874. serialize(): any;
  50875. /**
  50876. * Parses a JSON object correponding to the serialize function.
  50877. */
  50878. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  50879. }
  50880. }
  50881. declare module "babylonjs/Materials/PBR/index" {
  50882. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50883. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  50884. export * from "babylonjs/Materials/PBR/pbrMaterial";
  50885. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  50886. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  50887. }
  50888. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  50889. import { Nullable } from "babylonjs/types";
  50890. import { Scene } from "babylonjs/scene";
  50891. import { Matrix } from "babylonjs/Maths/math";
  50892. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50893. /**
  50894. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  50895. * It can help converting any input color in a desired output one. This can then be used to create effects
  50896. * from sepia, black and white to sixties or futuristic rendering...
  50897. *
  50898. * The only supported format is currently 3dl.
  50899. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  50900. */
  50901. export class ColorGradingTexture extends BaseTexture {
  50902. /**
  50903. * The current texture matrix. (will always be identity in color grading texture)
  50904. */
  50905. private _textureMatrix;
  50906. /**
  50907. * The texture URL.
  50908. */
  50909. url: string;
  50910. /**
  50911. * Empty line regex stored for GC.
  50912. */
  50913. private static _noneEmptyLineRegex;
  50914. private _engine;
  50915. /**
  50916. * Instantiates a ColorGradingTexture from the following parameters.
  50917. *
  50918. * @param url The location of the color gradind data (currently only supporting 3dl)
  50919. * @param scene The scene the texture will be used in
  50920. */
  50921. constructor(url: string, scene: Scene);
  50922. /**
  50923. * Returns the texture matrix used in most of the material.
  50924. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  50925. */
  50926. getTextureMatrix(): Matrix;
  50927. /**
  50928. * Occurs when the file being loaded is a .3dl LUT file.
  50929. */
  50930. private load3dlTexture;
  50931. /**
  50932. * Starts the loading process of the texture.
  50933. */
  50934. private loadTexture;
  50935. /**
  50936. * Clones the color gradind texture.
  50937. */
  50938. clone(): ColorGradingTexture;
  50939. /**
  50940. * Called during delayed load for textures.
  50941. */
  50942. delayLoad(): void;
  50943. /**
  50944. * Parses a color grading texture serialized by Babylon.
  50945. * @param parsedTexture The texture information being parsedTexture
  50946. * @param scene The scene to load the texture in
  50947. * @param rootUrl The root url of the data assets to load
  50948. * @return A color gradind texture
  50949. */
  50950. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  50951. /**
  50952. * Serializes the LUT texture to json format.
  50953. */
  50954. serialize(): any;
  50955. }
  50956. }
  50957. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  50958. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50959. import { Scene } from "babylonjs/scene";
  50960. import { Nullable } from "babylonjs/types";
  50961. /**
  50962. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  50963. */
  50964. export class EquiRectangularCubeTexture extends BaseTexture {
  50965. /** The six faces of the cube. */
  50966. private static _FacesMapping;
  50967. private _noMipmap;
  50968. private _onLoad;
  50969. private _onError;
  50970. /** The size of the cubemap. */
  50971. private _size;
  50972. /** The buffer of the image. */
  50973. private _buffer;
  50974. /** The width of the input image. */
  50975. private _width;
  50976. /** The height of the input image. */
  50977. private _height;
  50978. /** The URL to the image. */
  50979. url: string;
  50980. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  50981. coordinatesMode: number;
  50982. /**
  50983. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  50984. * @param url The location of the image
  50985. * @param scene The scene the texture will be used in
  50986. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50987. * @param noMipmap Forces to not generate the mipmap if true
  50988. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  50989. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  50990. * @param onLoad — defines a callback called when texture is loaded
  50991. * @param onError — defines a callback called if there is an error
  50992. */
  50993. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  50994. /**
  50995. * Load the image data, by putting the image on a canvas and extracting its buffer.
  50996. */
  50997. private loadImage;
  50998. /**
  50999. * Convert the image buffer into a cubemap and create a CubeTexture.
  51000. */
  51001. private loadTexture;
  51002. /**
  51003. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  51004. * @param buffer The ArrayBuffer that should be converted.
  51005. * @returns The buffer as Float32Array.
  51006. */
  51007. private getFloat32ArrayFromArrayBuffer;
  51008. /**
  51009. * Get the current class name of the texture useful for serialization or dynamic coding.
  51010. * @returns "EquiRectangularCubeTexture"
  51011. */
  51012. getClassName(): string;
  51013. /**
  51014. * Create a clone of the current EquiRectangularCubeTexture and return it.
  51015. * @returns A clone of the current EquiRectangularCubeTexture.
  51016. */
  51017. clone(): EquiRectangularCubeTexture;
  51018. }
  51019. }
  51020. declare module "babylonjs/Misc/tga" {
  51021. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51022. /**
  51023. * Based on jsTGALoader - Javascript loader for TGA file
  51024. * By Vincent Thibault
  51025. * @see http://blog.robrowser.com/javascript-tga-loader.html
  51026. */
  51027. export class TGATools {
  51028. private static _TYPE_INDEXED;
  51029. private static _TYPE_RGB;
  51030. private static _TYPE_GREY;
  51031. private static _TYPE_RLE_INDEXED;
  51032. private static _TYPE_RLE_RGB;
  51033. private static _TYPE_RLE_GREY;
  51034. private static _ORIGIN_MASK;
  51035. private static _ORIGIN_SHIFT;
  51036. private static _ORIGIN_BL;
  51037. private static _ORIGIN_BR;
  51038. private static _ORIGIN_UL;
  51039. private static _ORIGIN_UR;
  51040. /**
  51041. * Gets the header of a TGA file
  51042. * @param data defines the TGA data
  51043. * @returns the header
  51044. */
  51045. static GetTGAHeader(data: Uint8Array): any;
  51046. /**
  51047. * Uploads TGA content to a Babylon Texture
  51048. * @hidden
  51049. */
  51050. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  51051. /** @hidden */
  51052. 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;
  51053. /** @hidden */
  51054. 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;
  51055. /** @hidden */
  51056. 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;
  51057. /** @hidden */
  51058. 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;
  51059. /** @hidden */
  51060. 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;
  51061. /** @hidden */
  51062. 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;
  51063. }
  51064. }
  51065. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  51066. import { Nullable } from "babylonjs/types";
  51067. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51068. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51069. /**
  51070. * Implementation of the TGA Texture Loader.
  51071. * @hidden
  51072. */
  51073. export class _TGATextureLoader implements IInternalTextureLoader {
  51074. /**
  51075. * Defines wether the loader supports cascade loading the different faces.
  51076. */
  51077. readonly supportCascades: boolean;
  51078. /**
  51079. * This returns if the loader support the current file information.
  51080. * @param extension defines the file extension of the file being loaded
  51081. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51082. * @param fallback defines the fallback internal texture if any
  51083. * @param isBase64 defines whether the texture is encoded as a base64
  51084. * @param isBuffer defines whether the texture data are stored as a buffer
  51085. * @returns true if the loader can load the specified file
  51086. */
  51087. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51088. /**
  51089. * Transform the url before loading if required.
  51090. * @param rootUrl the url of the texture
  51091. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51092. * @returns the transformed texture
  51093. */
  51094. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51095. /**
  51096. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51097. * @param rootUrl the url of the texture
  51098. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51099. * @returns the fallback texture
  51100. */
  51101. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51102. /**
  51103. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51104. * @param data contains the texture data
  51105. * @param texture defines the BabylonJS internal texture
  51106. * @param createPolynomials will be true if polynomials have been requested
  51107. * @param onLoad defines the callback to trigger once the texture is ready
  51108. * @param onError defines the callback to trigger in case of error
  51109. */
  51110. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51111. /**
  51112. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51113. * @param data contains the texture data
  51114. * @param texture defines the BabylonJS internal texture
  51115. * @param callback defines the method to call once ready to upload
  51116. */
  51117. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51118. }
  51119. }
  51120. declare module "babylonjs/Materials/Textures/Loaders/index" {
  51121. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  51122. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  51123. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  51124. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  51125. }
  51126. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  51127. import { Scene } from "babylonjs/scene";
  51128. import { Texture } from "babylonjs/Materials/Textures/texture";
  51129. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51130. /**
  51131. * 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.
  51132. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51133. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51134. */
  51135. export class CustomProceduralTexture extends ProceduralTexture {
  51136. private _animate;
  51137. private _time;
  51138. private _config;
  51139. private _texturePath;
  51140. /**
  51141. * Instantiates a new Custom Procedural Texture.
  51142. * 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.
  51143. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51144. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51145. * @param name Define the name of the texture
  51146. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  51147. * @param size Define the size of the texture to create
  51148. * @param scene Define the scene the texture belongs to
  51149. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  51150. * @param generateMipMaps Define if the texture should creates mip maps or not
  51151. */
  51152. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51153. private _loadJson;
  51154. /**
  51155. * Is the texture ready to be used ? (rendered at least once)
  51156. * @returns true if ready, otherwise, false.
  51157. */
  51158. isReady(): boolean;
  51159. /**
  51160. * Render the texture to its associated render target.
  51161. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  51162. */
  51163. render(useCameraPostProcess?: boolean): void;
  51164. /**
  51165. * Update the list of dependant textures samplers in the shader.
  51166. */
  51167. updateTextures(): void;
  51168. /**
  51169. * Update the uniform values of the procedural texture in the shader.
  51170. */
  51171. updateShaderUniforms(): void;
  51172. /**
  51173. * Define if the texture animates or not.
  51174. */
  51175. animate: boolean;
  51176. }
  51177. }
  51178. declare module "babylonjs/Shaders/noise.fragment" {
  51179. /** @hidden */
  51180. export var noisePixelShader: {
  51181. name: string;
  51182. shader: string;
  51183. };
  51184. }
  51185. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  51186. import { Nullable } from "babylonjs/types";
  51187. import { Scene } from "babylonjs/scene";
  51188. import { Texture } from "babylonjs/Materials/Textures/texture";
  51189. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51190. import "babylonjs/Shaders/noise.fragment";
  51191. /**
  51192. * Class used to generate noise procedural textures
  51193. */
  51194. export class NoiseProceduralTexture extends ProceduralTexture {
  51195. private _time;
  51196. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  51197. brightness: number;
  51198. /** Defines the number of octaves to process */
  51199. octaves: number;
  51200. /** Defines the level of persistence (0.8 by default) */
  51201. persistence: number;
  51202. /** Gets or sets animation speed factor (default is 1) */
  51203. animationSpeedFactor: number;
  51204. /**
  51205. * Creates a new NoiseProceduralTexture
  51206. * @param name defines the name fo the texture
  51207. * @param size defines the size of the texture (default is 256)
  51208. * @param scene defines the hosting scene
  51209. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  51210. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  51211. */
  51212. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51213. private _updateShaderUniforms;
  51214. protected _getDefines(): string;
  51215. /** Generate the current state of the procedural texture */
  51216. render(useCameraPostProcess?: boolean): void;
  51217. /**
  51218. * Serializes this noise procedural texture
  51219. * @returns a serialized noise procedural texture object
  51220. */
  51221. serialize(): any;
  51222. /**
  51223. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  51224. * @param parsedTexture defines parsed texture data
  51225. * @param scene defines the current scene
  51226. * @param rootUrl defines the root URL containing noise procedural texture information
  51227. * @returns a parsed NoiseProceduralTexture
  51228. */
  51229. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  51230. }
  51231. }
  51232. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  51233. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  51234. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  51235. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51236. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  51237. }
  51238. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  51239. import { Nullable } from "babylonjs/types";
  51240. import { Scene } from "babylonjs/scene";
  51241. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  51242. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51243. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  51244. /**
  51245. * Raw cube texture where the raw buffers are passed in
  51246. */
  51247. export class RawCubeTexture extends CubeTexture {
  51248. /**
  51249. * Creates a cube texture where the raw buffers are passed in.
  51250. * @param scene defines the scene the texture is attached to
  51251. * @param data defines the array of data to use to create each face
  51252. * @param size defines the size of the textures
  51253. * @param format defines the format of the data
  51254. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  51255. * @param generateMipMaps defines if the engine should generate the mip levels
  51256. * @param invertY defines if data must be stored with Y axis inverted
  51257. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  51258. * @param compression defines the compression used (null by default)
  51259. */
  51260. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  51261. /**
  51262. * Updates the raw cube texture.
  51263. * @param data defines the data to store
  51264. * @param format defines the data format
  51265. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  51266. * @param invertY defines if data must be stored with Y axis inverted
  51267. * @param compression defines the compression used (null by default)
  51268. * @param level defines which level of the texture to update
  51269. */
  51270. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  51271. /**
  51272. * Updates a raw cube texture with RGBD encoded data.
  51273. * @param data defines the array of data [mipmap][face] to use to create each face
  51274. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  51275. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51276. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51277. * @returns a promsie that resolves when the operation is complete
  51278. */
  51279. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  51280. /**
  51281. * Clones the raw cube texture.
  51282. * @return a new cube texture
  51283. */
  51284. clone(): CubeTexture;
  51285. /** @hidden */
  51286. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51287. }
  51288. }
  51289. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  51290. import { Scene } from "babylonjs/scene";
  51291. import { Texture } from "babylonjs/Materials/Textures/texture";
  51292. /**
  51293. * Class used to store 3D textures containing user data
  51294. */
  51295. export class RawTexture3D extends Texture {
  51296. /** Gets or sets the texture format to use */
  51297. format: number;
  51298. private _engine;
  51299. /**
  51300. * Create a new RawTexture3D
  51301. * @param data defines the data of the texture
  51302. * @param width defines the width of the texture
  51303. * @param height defines the height of the texture
  51304. * @param depth defines the depth of the texture
  51305. * @param format defines the texture format to use
  51306. * @param scene defines the hosting scene
  51307. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  51308. * @param invertY defines if texture must be stored with Y axis inverted
  51309. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  51310. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  51311. */
  51312. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  51313. /** Gets or sets the texture format to use */
  51314. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  51315. /**
  51316. * Update the texture with new data
  51317. * @param data defines the data to store in the texture
  51318. */
  51319. update(data: ArrayBufferView): void;
  51320. }
  51321. }
  51322. declare module "babylonjs/Materials/Textures/refractionTexture" {
  51323. import { Scene } from "babylonjs/scene";
  51324. import { Plane } from "babylonjs/Maths/math";
  51325. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51326. /**
  51327. * Creates a refraction texture used by refraction channel of the standard material.
  51328. * It is like a mirror but to see through a material.
  51329. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51330. */
  51331. export class RefractionTexture extends RenderTargetTexture {
  51332. /**
  51333. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  51334. * 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.
  51335. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51336. */
  51337. refractionPlane: Plane;
  51338. /**
  51339. * Define how deep under the surface we should see.
  51340. */
  51341. depth: number;
  51342. /**
  51343. * Creates a refraction texture used by refraction channel of the standard material.
  51344. * It is like a mirror but to see through a material.
  51345. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51346. * @param name Define the texture name
  51347. * @param size Define the size of the underlying texture
  51348. * @param scene Define the scene the refraction belongs to
  51349. * @param generateMipMaps Define if we need to generate mips level for the refraction
  51350. */
  51351. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  51352. /**
  51353. * Clone the refraction texture.
  51354. * @returns the cloned texture
  51355. */
  51356. clone(): RefractionTexture;
  51357. /**
  51358. * Serialize the texture to a JSON representation you could use in Parse later on
  51359. * @returns the serialized JSON representation
  51360. */
  51361. serialize(): any;
  51362. }
  51363. }
  51364. declare module "babylonjs/Materials/Textures/index" {
  51365. export * from "babylonjs/Materials/Textures/baseTexture";
  51366. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  51367. export * from "babylonjs/Materials/Textures/cubeTexture";
  51368. export * from "babylonjs/Materials/Textures/dynamicTexture";
  51369. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  51370. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  51371. export * from "babylonjs/Materials/Textures/internalTexture";
  51372. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  51373. export * from "babylonjs/Materials/Textures/Loaders/index";
  51374. export * from "babylonjs/Materials/Textures/mirrorTexture";
  51375. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  51376. export * from "babylonjs/Materials/Textures/Procedurals/index";
  51377. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  51378. export * from "babylonjs/Materials/Textures/rawTexture";
  51379. export * from "babylonjs/Materials/Textures/rawTexture3D";
  51380. export * from "babylonjs/Materials/Textures/refractionTexture";
  51381. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  51382. export * from "babylonjs/Materials/Textures/texture";
  51383. export * from "babylonjs/Materials/Textures/videoTexture";
  51384. }
  51385. declare module "babylonjs/Materials/index" {
  51386. export * from "babylonjs/Materials/Background/index";
  51387. export * from "babylonjs/Materials/colorCurves";
  51388. export * from "babylonjs/Materials/effect";
  51389. export * from "babylonjs/Materials/fresnelParameters";
  51390. export * from "babylonjs/Materials/imageProcessingConfiguration";
  51391. export * from "babylonjs/Materials/material";
  51392. export * from "babylonjs/Materials/materialDefines";
  51393. export * from "babylonjs/Materials/materialHelper";
  51394. export * from "babylonjs/Materials/multiMaterial";
  51395. export * from "babylonjs/Materials/PBR/index";
  51396. export * from "babylonjs/Materials/pushMaterial";
  51397. export * from "babylonjs/Materials/shaderMaterial";
  51398. export * from "babylonjs/Materials/standardMaterial";
  51399. export * from "babylonjs/Materials/Textures/index";
  51400. export * from "babylonjs/Materials/uniformBuffer";
  51401. export * from "babylonjs/Materials/materialFlags";
  51402. }
  51403. declare module "babylonjs/Maths/index" {
  51404. export * from "babylonjs/Maths/math.scalar";
  51405. export * from "babylonjs/Maths/math";
  51406. export * from "babylonjs/Maths/sphericalPolynomial";
  51407. }
  51408. declare module "babylonjs/Misc/workerPool" {
  51409. import { IDisposable } from "babylonjs/scene";
  51410. /**
  51411. * Helper class to push actions to a pool of workers.
  51412. */
  51413. export class WorkerPool implements IDisposable {
  51414. private _workerInfos;
  51415. private _pendingActions;
  51416. /**
  51417. * Constructor
  51418. * @param workers Array of workers to use for actions
  51419. */
  51420. constructor(workers: Array<Worker>);
  51421. /**
  51422. * Terminates all workers and clears any pending actions.
  51423. */
  51424. dispose(): void;
  51425. /**
  51426. * Pushes an action to the worker pool. If all the workers are active, the action will be
  51427. * pended until a worker has completed its action.
  51428. * @param action The action to perform. Call onComplete when the action is complete.
  51429. */
  51430. push(action: (worker: Worker, onComplete: () => void) => void): void;
  51431. private _execute;
  51432. }
  51433. }
  51434. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  51435. import { IDisposable } from "babylonjs/scene";
  51436. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  51437. /**
  51438. * Configuration for Draco compression
  51439. */
  51440. export interface IDracoCompressionConfiguration {
  51441. /**
  51442. * Configuration for the decoder.
  51443. */
  51444. decoder?: {
  51445. /**
  51446. * The url to the WebAssembly module.
  51447. */
  51448. wasmUrl?: string;
  51449. /**
  51450. * The url to the WebAssembly binary.
  51451. */
  51452. wasmBinaryUrl?: string;
  51453. /**
  51454. * The url to the fallback JavaScript module.
  51455. */
  51456. fallbackUrl?: string;
  51457. };
  51458. }
  51459. /**
  51460. * Draco compression (https://google.github.io/draco/)
  51461. *
  51462. * This class wraps the Draco module.
  51463. *
  51464. * **Encoder**
  51465. *
  51466. * The encoder is not currently implemented.
  51467. *
  51468. * **Decoder**
  51469. *
  51470. * 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.
  51471. *
  51472. * To update the configuration, use the following code:
  51473. * ```javascript
  51474. * DracoCompression.Configuration = {
  51475. * decoder: {
  51476. * wasmUrl: "<url to the WebAssembly library>",
  51477. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  51478. * fallbackUrl: "<url to the fallback JavaScript library>",
  51479. * }
  51480. * };
  51481. * ```
  51482. *
  51483. * 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.
  51484. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  51485. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  51486. *
  51487. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  51488. * ```javascript
  51489. * var dracoCompression = new DracoCompression();
  51490. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  51491. * [VertexBuffer.PositionKind]: 0
  51492. * });
  51493. * ```
  51494. *
  51495. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  51496. */
  51497. export class DracoCompression implements IDisposable {
  51498. private _workerPoolPromise;
  51499. /**
  51500. * The configuration. Defaults to the following urls:
  51501. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  51502. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  51503. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  51504. */
  51505. static Configuration: IDracoCompressionConfiguration;
  51506. /**
  51507. * Returns true if the decoder is available.
  51508. */
  51509. static readonly DecoderAvailable: boolean;
  51510. /**
  51511. * Default number of workers to create when creating the draco compression object.
  51512. */
  51513. static DefaultNumWorkers: number;
  51514. private static GetDefaultNumWorkers;
  51515. /**
  51516. * Constructor
  51517. * @param numWorkers The number of workers for async operations
  51518. */
  51519. constructor(numWorkers?: number);
  51520. /**
  51521. * Stop all async operations and release resources.
  51522. */
  51523. dispose(): void;
  51524. /**
  51525. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  51526. * @returns a promise that resolves when ready
  51527. */
  51528. whenReadyAsync(): Promise<void>;
  51529. /**
  51530. * Decode Draco compressed mesh data to vertex data.
  51531. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  51532. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  51533. * @returns A promise that resolves with the decoded vertex data
  51534. */
  51535. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  51536. [kind: string]: number;
  51537. }): Promise<VertexData>;
  51538. /**
  51539. * The worker function that gets converted to a blob url to pass into a worker.
  51540. */
  51541. private static _Worker;
  51542. private _loadDecoderWasmBinaryAsync;
  51543. }
  51544. }
  51545. declare module "babylonjs/Meshes/Compression/index" {
  51546. export * from "babylonjs/Meshes/Compression/dracoCompression";
  51547. }
  51548. declare module "babylonjs/Meshes/csg" {
  51549. import { Nullable } from "babylonjs/types";
  51550. import { Scene } from "babylonjs/scene";
  51551. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  51552. import { Mesh } from "babylonjs/Meshes/mesh";
  51553. import { Material } from "babylonjs/Materials/material";
  51554. /**
  51555. * Class for building Constructive Solid Geometry
  51556. */
  51557. export class CSG {
  51558. private polygons;
  51559. /**
  51560. * The world matrix
  51561. */
  51562. matrix: Matrix;
  51563. /**
  51564. * Stores the position
  51565. */
  51566. position: Vector3;
  51567. /**
  51568. * Stores the rotation
  51569. */
  51570. rotation: Vector3;
  51571. /**
  51572. * Stores the rotation quaternion
  51573. */
  51574. rotationQuaternion: Nullable<Quaternion>;
  51575. /**
  51576. * Stores the scaling vector
  51577. */
  51578. scaling: Vector3;
  51579. /**
  51580. * Convert the Mesh to CSG
  51581. * @param mesh The Mesh to convert to CSG
  51582. * @returns A new CSG from the Mesh
  51583. */
  51584. static FromMesh(mesh: Mesh): CSG;
  51585. /**
  51586. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  51587. * @param polygons Polygons used to construct a CSG solid
  51588. */
  51589. private static FromPolygons;
  51590. /**
  51591. * Clones, or makes a deep copy, of the CSG
  51592. * @returns A new CSG
  51593. */
  51594. clone(): CSG;
  51595. /**
  51596. * Unions this CSG with another CSG
  51597. * @param csg The CSG to union against this CSG
  51598. * @returns The unioned CSG
  51599. */
  51600. union(csg: CSG): CSG;
  51601. /**
  51602. * Unions this CSG with another CSG in place
  51603. * @param csg The CSG to union against this CSG
  51604. */
  51605. unionInPlace(csg: CSG): void;
  51606. /**
  51607. * Subtracts this CSG with another CSG
  51608. * @param csg The CSG to subtract against this CSG
  51609. * @returns A new CSG
  51610. */
  51611. subtract(csg: CSG): CSG;
  51612. /**
  51613. * Subtracts this CSG with another CSG in place
  51614. * @param csg The CSG to subtact against this CSG
  51615. */
  51616. subtractInPlace(csg: CSG): void;
  51617. /**
  51618. * Intersect this CSG with another CSG
  51619. * @param csg The CSG to intersect against this CSG
  51620. * @returns A new CSG
  51621. */
  51622. intersect(csg: CSG): CSG;
  51623. /**
  51624. * Intersects this CSG with another CSG in place
  51625. * @param csg The CSG to intersect against this CSG
  51626. */
  51627. intersectInPlace(csg: CSG): void;
  51628. /**
  51629. * Return a new CSG solid with solid and empty space switched. This solid is
  51630. * not modified.
  51631. * @returns A new CSG solid with solid and empty space switched
  51632. */
  51633. inverse(): CSG;
  51634. /**
  51635. * Inverses the CSG in place
  51636. */
  51637. inverseInPlace(): void;
  51638. /**
  51639. * This is used to keep meshes transformations so they can be restored
  51640. * when we build back a Babylon Mesh
  51641. * NB : All CSG operations are performed in world coordinates
  51642. * @param csg The CSG to copy the transform attributes from
  51643. * @returns This CSG
  51644. */
  51645. copyTransformAttributes(csg: CSG): CSG;
  51646. /**
  51647. * Build Raw mesh from CSG
  51648. * Coordinates here are in world space
  51649. * @param name The name of the mesh geometry
  51650. * @param scene The Scene
  51651. * @param keepSubMeshes Specifies if the submeshes should be kept
  51652. * @returns A new Mesh
  51653. */
  51654. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  51655. /**
  51656. * Build Mesh from CSG taking material and transforms into account
  51657. * @param name The name of the Mesh
  51658. * @param material The material of the Mesh
  51659. * @param scene The Scene
  51660. * @param keepSubMeshes Specifies if submeshes should be kept
  51661. * @returns The new Mesh
  51662. */
  51663. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  51664. }
  51665. }
  51666. declare module "babylonjs/Meshes/trailMesh" {
  51667. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51668. import { Mesh } from "babylonjs/Meshes/mesh";
  51669. import { Scene } from "babylonjs/scene";
  51670. /**
  51671. * Class used to create a trail following a mesh
  51672. */
  51673. export class TrailMesh extends Mesh {
  51674. private _generator;
  51675. private _autoStart;
  51676. private _running;
  51677. private _diameter;
  51678. private _length;
  51679. private _sectionPolygonPointsCount;
  51680. private _sectionVectors;
  51681. private _sectionNormalVectors;
  51682. private _beforeRenderObserver;
  51683. /**
  51684. * @constructor
  51685. * @param name The value used by scene.getMeshByName() to do a lookup.
  51686. * @param generator The mesh to generate a trail.
  51687. * @param scene The scene to add this mesh to.
  51688. * @param diameter Diameter of trailing mesh. Default is 1.
  51689. * @param length Length of trailing mesh. Default is 60.
  51690. * @param autoStart Automatically start trailing mesh. Default true.
  51691. */
  51692. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  51693. /**
  51694. * "TrailMesh"
  51695. * @returns "TrailMesh"
  51696. */
  51697. getClassName(): string;
  51698. private _createMesh;
  51699. /**
  51700. * Start trailing mesh.
  51701. */
  51702. start(): void;
  51703. /**
  51704. * Stop trailing mesh.
  51705. */
  51706. stop(): void;
  51707. /**
  51708. * Update trailing mesh geometry.
  51709. */
  51710. update(): void;
  51711. /**
  51712. * Returns a new TrailMesh object.
  51713. * @param name is a string, the name given to the new mesh
  51714. * @param newGenerator use new generator object for cloned trail mesh
  51715. * @returns a new mesh
  51716. */
  51717. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  51718. /**
  51719. * Serializes this trail mesh
  51720. * @param serializationObject object to write serialization to
  51721. */
  51722. serialize(serializationObject: any): void;
  51723. /**
  51724. * Parses a serialized trail mesh
  51725. * @param parsedMesh the serialized mesh
  51726. * @param scene the scene to create the trail mesh in
  51727. * @returns the created trail mesh
  51728. */
  51729. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  51730. }
  51731. }
  51732. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  51733. import { Vector4 } from "babylonjs/Maths/math";
  51734. import { Mesh } from "babylonjs/Meshes/mesh";
  51735. /**
  51736. * Class containing static functions to help procedurally build meshes
  51737. */
  51738. export class TorusKnotBuilder {
  51739. /**
  51740. * Creates a torus knot mesh
  51741. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  51742. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  51743. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  51744. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  51745. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51746. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51747. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51748. * @param name defines the name of the mesh
  51749. * @param options defines the options used to create the mesh
  51750. * @param scene defines the hosting scene
  51751. * @returns the torus knot mesh
  51752. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  51753. */
  51754. static CreateTorusKnot(name: string, options: {
  51755. radius?: number;
  51756. tube?: number;
  51757. radialSegments?: number;
  51758. tubularSegments?: number;
  51759. p?: number;
  51760. q?: number;
  51761. updatable?: boolean;
  51762. sideOrientation?: number;
  51763. frontUVs?: Vector4;
  51764. backUVs?: Vector4;
  51765. }, scene: any): Mesh;
  51766. }
  51767. }
  51768. declare module "babylonjs/Meshes/polygonMesh" {
  51769. import { Scene } from "babylonjs/scene";
  51770. import { Vector2, Path2 } from "babylonjs/Maths/math";
  51771. import { Mesh } from "babylonjs/Meshes/mesh";
  51772. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  51773. /**
  51774. * Polygon
  51775. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  51776. */
  51777. export class Polygon {
  51778. /**
  51779. * Creates a rectangle
  51780. * @param xmin bottom X coord
  51781. * @param ymin bottom Y coord
  51782. * @param xmax top X coord
  51783. * @param ymax top Y coord
  51784. * @returns points that make the resulting rectation
  51785. */
  51786. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  51787. /**
  51788. * Creates a circle
  51789. * @param radius radius of circle
  51790. * @param cx scale in x
  51791. * @param cy scale in y
  51792. * @param numberOfSides number of sides that make up the circle
  51793. * @returns points that make the resulting circle
  51794. */
  51795. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  51796. /**
  51797. * Creates a polygon from input string
  51798. * @param input Input polygon data
  51799. * @returns the parsed points
  51800. */
  51801. static Parse(input: string): Vector2[];
  51802. /**
  51803. * Starts building a polygon from x and y coordinates
  51804. * @param x x coordinate
  51805. * @param y y coordinate
  51806. * @returns the started path2
  51807. */
  51808. static StartingAt(x: number, y: number): Path2;
  51809. }
  51810. /**
  51811. * Builds a polygon
  51812. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  51813. */
  51814. export class PolygonMeshBuilder {
  51815. private _points;
  51816. private _outlinepoints;
  51817. private _holes;
  51818. private _name;
  51819. private _scene;
  51820. private _epoints;
  51821. private _eholes;
  51822. private _addToepoint;
  51823. /**
  51824. * Babylon reference to the earcut plugin.
  51825. */
  51826. bjsEarcut: any;
  51827. /**
  51828. * Creates a PolygonMeshBuilder
  51829. * @param name name of the builder
  51830. * @param contours Path of the polygon
  51831. * @param scene scene to add to when creating the mesh
  51832. * @param earcutInjection can be used to inject your own earcut reference
  51833. */
  51834. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  51835. /**
  51836. * Adds a whole within the polygon
  51837. * @param hole Array of points defining the hole
  51838. * @returns this
  51839. */
  51840. addHole(hole: Vector2[]): PolygonMeshBuilder;
  51841. /**
  51842. * Creates the polygon
  51843. * @param updatable If the mesh should be updatable
  51844. * @param depth The depth of the mesh created
  51845. * @returns the created mesh
  51846. */
  51847. build(updatable?: boolean, depth?: number): Mesh;
  51848. /**
  51849. * Creates the polygon
  51850. * @param depth The depth of the mesh created
  51851. * @returns the created VertexData
  51852. */
  51853. buildVertexData(depth?: number): VertexData;
  51854. /**
  51855. * Adds a side to the polygon
  51856. * @param positions points that make the polygon
  51857. * @param normals normals of the polygon
  51858. * @param uvs uvs of the polygon
  51859. * @param indices indices of the polygon
  51860. * @param bounds bounds of the polygon
  51861. * @param points points of the polygon
  51862. * @param depth depth of the polygon
  51863. * @param flip flip of the polygon
  51864. */
  51865. private addSide;
  51866. }
  51867. }
  51868. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  51869. import { Scene } from "babylonjs/scene";
  51870. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  51871. import { Mesh } from "babylonjs/Meshes/mesh";
  51872. import { Nullable } from "babylonjs/types";
  51873. /**
  51874. * Class containing static functions to help procedurally build meshes
  51875. */
  51876. export class PolygonBuilder {
  51877. /**
  51878. * Creates a polygon mesh
  51879. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  51880. * * 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
  51881. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  51882. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51883. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  51884. * * Remember you can only change the shape positions, not their number when updating a polygon
  51885. * @param name defines the name of the mesh
  51886. * @param options defines the options used to create the mesh
  51887. * @param scene defines the hosting scene
  51888. * @param earcutInjection can be used to inject your own earcut reference
  51889. * @returns the polygon mesh
  51890. */
  51891. static CreatePolygon(name: string, options: {
  51892. shape: Vector3[];
  51893. holes?: Vector3[][];
  51894. depth?: number;
  51895. faceUV?: Vector4[];
  51896. faceColors?: Color4[];
  51897. updatable?: boolean;
  51898. sideOrientation?: number;
  51899. frontUVs?: Vector4;
  51900. backUVs?: Vector4;
  51901. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  51902. /**
  51903. * Creates an extruded polygon mesh, with depth in the Y direction.
  51904. * * 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)
  51905. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51906. * @param name defines the name of the mesh
  51907. * @param options defines the options used to create the mesh
  51908. * @param scene defines the hosting scene
  51909. * @param earcutInjection can be used to inject your own earcut reference
  51910. * @returns the polygon mesh
  51911. */
  51912. static ExtrudePolygon(name: string, options: {
  51913. shape: Vector3[];
  51914. holes?: Vector3[][];
  51915. depth?: number;
  51916. faceUV?: Vector4[];
  51917. faceColors?: Color4[];
  51918. updatable?: boolean;
  51919. sideOrientation?: number;
  51920. frontUVs?: Vector4;
  51921. backUVs?: Vector4;
  51922. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  51923. }
  51924. }
  51925. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  51926. import { Scene } from "babylonjs/scene";
  51927. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  51928. import { Mesh } from "babylonjs/Meshes/mesh";
  51929. import { Nullable } from "babylonjs/types";
  51930. /**
  51931. * Class containing static functions to help procedurally build meshes
  51932. */
  51933. export class LatheBuilder {
  51934. /**
  51935. * Creates lathe mesh.
  51936. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  51937. * * 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
  51938. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  51939. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  51940. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  51941. * * 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
  51942. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  51943. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  51944. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51945. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51946. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51947. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51948. * @param name defines the name of the mesh
  51949. * @param options defines the options used to create the mesh
  51950. * @param scene defines the hosting scene
  51951. * @returns the lathe mesh
  51952. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  51953. */
  51954. static CreateLathe(name: string, options: {
  51955. shape: Vector3[];
  51956. radius?: number;
  51957. tessellation?: number;
  51958. clip?: number;
  51959. arc?: number;
  51960. closed?: boolean;
  51961. updatable?: boolean;
  51962. sideOrientation?: number;
  51963. frontUVs?: Vector4;
  51964. backUVs?: Vector4;
  51965. cap?: number;
  51966. invertUV?: boolean;
  51967. }, scene?: Nullable<Scene>): Mesh;
  51968. }
  51969. }
  51970. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  51971. import { Nullable } from "babylonjs/types";
  51972. import { Scene } from "babylonjs/scene";
  51973. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  51974. import { Mesh } from "babylonjs/Meshes/mesh";
  51975. /**
  51976. * Class containing static functions to help procedurally build meshes
  51977. */
  51978. export class TubeBuilder {
  51979. /**
  51980. * Creates a tube mesh.
  51981. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51982. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  51983. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  51984. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  51985. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  51986. * * 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)
  51987. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  51988. * * 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
  51989. * * 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
  51990. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51991. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51992. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51993. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51994. * @param name defines the name of the mesh
  51995. * @param options defines the options used to create the mesh
  51996. * @param scene defines the hosting scene
  51997. * @returns the tube mesh
  51998. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51999. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  52000. */
  52001. static CreateTube(name: string, options: {
  52002. path: Vector3[];
  52003. radius?: number;
  52004. tessellation?: number;
  52005. radiusFunction?: {
  52006. (i: number, distance: number): number;
  52007. };
  52008. cap?: number;
  52009. arc?: number;
  52010. updatable?: boolean;
  52011. sideOrientation?: number;
  52012. frontUVs?: Vector4;
  52013. backUVs?: Vector4;
  52014. instance?: Mesh;
  52015. invertUV?: boolean;
  52016. }, scene?: Nullable<Scene>): Mesh;
  52017. }
  52018. }
  52019. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  52020. import { Scene } from "babylonjs/scene";
  52021. import { Vector4 } from "babylonjs/Maths/math";
  52022. import { Mesh } from "babylonjs/Meshes/mesh";
  52023. import { Nullable } from "babylonjs/types";
  52024. /**
  52025. * Class containing static functions to help procedurally build meshes
  52026. */
  52027. export class IcoSphereBuilder {
  52028. /**
  52029. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52030. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52031. * * 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`)
  52032. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52033. * * 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
  52034. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52035. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52036. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52037. * @param name defines the name of the mesh
  52038. * @param options defines the options used to create the mesh
  52039. * @param scene defines the hosting scene
  52040. * @returns the icosahedron mesh
  52041. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52042. */
  52043. static CreateIcoSphere(name: string, options: {
  52044. radius?: number;
  52045. radiusX?: number;
  52046. radiusY?: number;
  52047. radiusZ?: number;
  52048. flat?: boolean;
  52049. subdivisions?: number;
  52050. sideOrientation?: number;
  52051. frontUVs?: Vector4;
  52052. backUVs?: Vector4;
  52053. updatable?: boolean;
  52054. }, scene?: Nullable<Scene>): Mesh;
  52055. }
  52056. }
  52057. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  52058. import { Vector3 } from "babylonjs/Maths/math";
  52059. import { Mesh } from "babylonjs/Meshes/mesh";
  52060. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52061. /**
  52062. * Class containing static functions to help procedurally build meshes
  52063. */
  52064. export class DecalBuilder {
  52065. /**
  52066. * Creates a decal mesh.
  52067. * 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
  52068. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  52069. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  52070. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  52071. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  52072. * @param name defines the name of the mesh
  52073. * @param sourceMesh defines the mesh where the decal must be applied
  52074. * @param options defines the options used to create the mesh
  52075. * @param scene defines the hosting scene
  52076. * @returns the decal mesh
  52077. * @see https://doc.babylonjs.com/how_to/decals
  52078. */
  52079. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  52080. position?: Vector3;
  52081. normal?: Vector3;
  52082. size?: Vector3;
  52083. angle?: number;
  52084. }): Mesh;
  52085. }
  52086. }
  52087. declare module "babylonjs/Meshes/meshBuilder" {
  52088. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  52089. import { Nullable } from "babylonjs/types";
  52090. import { Scene } from "babylonjs/scene";
  52091. import { Mesh } from "babylonjs/Meshes/mesh";
  52092. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  52093. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  52094. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52095. /**
  52096. * Class containing static functions to help procedurally build meshes
  52097. */
  52098. export class MeshBuilder {
  52099. /**
  52100. * Creates a box mesh
  52101. * * The parameter `size` sets the size (float) of each box side (default 1)
  52102. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  52103. * * 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)
  52104. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52105. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52106. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52107. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52108. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52109. * @param name defines the name of the mesh
  52110. * @param options defines the options used to create the mesh
  52111. * @param scene defines the hosting scene
  52112. * @returns the box mesh
  52113. */
  52114. static CreateBox(name: string, options: {
  52115. size?: number;
  52116. width?: number;
  52117. height?: number;
  52118. depth?: number;
  52119. faceUV?: Vector4[];
  52120. faceColors?: Color4[];
  52121. sideOrientation?: number;
  52122. frontUVs?: Vector4;
  52123. backUVs?: Vector4;
  52124. updatable?: boolean;
  52125. }, scene?: Nullable<Scene>): Mesh;
  52126. /**
  52127. * Creates a sphere mesh
  52128. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  52129. * * 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`)
  52130. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  52131. * * 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
  52132. * * 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)
  52133. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52134. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52135. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52136. * @param name defines the name of the mesh
  52137. * @param options defines the options used to create the mesh
  52138. * @param scene defines the hosting scene
  52139. * @returns the sphere mesh
  52140. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  52141. */
  52142. static CreateSphere(name: string, options: {
  52143. segments?: number;
  52144. diameter?: number;
  52145. diameterX?: number;
  52146. diameterY?: number;
  52147. diameterZ?: number;
  52148. arc?: number;
  52149. slice?: number;
  52150. sideOrientation?: number;
  52151. frontUVs?: Vector4;
  52152. backUVs?: Vector4;
  52153. updatable?: boolean;
  52154. }, scene?: Nullable<Scene>): Mesh;
  52155. /**
  52156. * Creates a plane polygonal mesh. By default, this is a disc
  52157. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  52158. * * 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
  52159. * * 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
  52160. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52161. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52162. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52163. * @param name defines the name of the mesh
  52164. * @param options defines the options used to create the mesh
  52165. * @param scene defines the hosting scene
  52166. * @returns the plane polygonal mesh
  52167. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  52168. */
  52169. static CreateDisc(name: string, options: {
  52170. radius?: number;
  52171. tessellation?: number;
  52172. arc?: number;
  52173. updatable?: boolean;
  52174. sideOrientation?: number;
  52175. frontUVs?: Vector4;
  52176. backUVs?: Vector4;
  52177. }, scene?: Nullable<Scene>): Mesh;
  52178. /**
  52179. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52180. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52181. * * 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`)
  52182. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52183. * * 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
  52184. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52185. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52186. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52187. * @param name defines the name of the mesh
  52188. * @param options defines the options used to create the mesh
  52189. * @param scene defines the hosting scene
  52190. * @returns the icosahedron mesh
  52191. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52192. */
  52193. static CreateIcoSphere(name: string, options: {
  52194. radius?: number;
  52195. radiusX?: number;
  52196. radiusY?: number;
  52197. radiusZ?: number;
  52198. flat?: boolean;
  52199. subdivisions?: number;
  52200. sideOrientation?: number;
  52201. frontUVs?: Vector4;
  52202. backUVs?: Vector4;
  52203. updatable?: boolean;
  52204. }, scene?: Nullable<Scene>): Mesh;
  52205. /**
  52206. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52207. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52208. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52209. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52210. * * 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
  52211. * * 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
  52212. * * 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
  52213. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52214. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52215. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52216. * * 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
  52217. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52218. * * 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
  52219. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52220. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52221. * @param name defines the name of the mesh
  52222. * @param options defines the options used to create the mesh
  52223. * @param scene defines the hosting scene
  52224. * @returns the ribbon mesh
  52225. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52226. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52227. */
  52228. static CreateRibbon(name: string, options: {
  52229. pathArray: Vector3[][];
  52230. closeArray?: boolean;
  52231. closePath?: boolean;
  52232. offset?: number;
  52233. updatable?: boolean;
  52234. sideOrientation?: number;
  52235. frontUVs?: Vector4;
  52236. backUVs?: Vector4;
  52237. instance?: Mesh;
  52238. invertUV?: boolean;
  52239. uvs?: Vector2[];
  52240. colors?: Color4[];
  52241. }, scene?: Nullable<Scene>): Mesh;
  52242. /**
  52243. * Creates a cylinder or a cone mesh
  52244. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  52245. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  52246. * * 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.
  52247. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  52248. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  52249. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  52250. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  52251. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  52252. * * 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).
  52253. * * 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
  52254. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  52255. * * 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
  52256. * * 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.
  52257. * * If `enclose` is false, a ring surface is one element.
  52258. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  52259. * * 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
  52260. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52261. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52262. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52263. * @param name defines the name of the mesh
  52264. * @param options defines the options used to create the mesh
  52265. * @param scene defines the hosting scene
  52266. * @returns the cylinder mesh
  52267. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  52268. */
  52269. static CreateCylinder(name: string, options: {
  52270. height?: number;
  52271. diameterTop?: number;
  52272. diameterBottom?: number;
  52273. diameter?: number;
  52274. tessellation?: number;
  52275. subdivisions?: number;
  52276. arc?: number;
  52277. faceColors?: Color4[];
  52278. faceUV?: Vector4[];
  52279. updatable?: boolean;
  52280. hasRings?: boolean;
  52281. enclose?: boolean;
  52282. sideOrientation?: number;
  52283. frontUVs?: Vector4;
  52284. backUVs?: Vector4;
  52285. }, scene?: Nullable<Scene>): Mesh;
  52286. /**
  52287. * Creates a torus mesh
  52288. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  52289. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  52290. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  52291. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52292. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52293. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52294. * @param name defines the name of the mesh
  52295. * @param options defines the options used to create the mesh
  52296. * @param scene defines the hosting scene
  52297. * @returns the torus mesh
  52298. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  52299. */
  52300. static CreateTorus(name: string, options: {
  52301. diameter?: number;
  52302. thickness?: number;
  52303. tessellation?: number;
  52304. updatable?: boolean;
  52305. sideOrientation?: number;
  52306. frontUVs?: Vector4;
  52307. backUVs?: Vector4;
  52308. }, scene?: Nullable<Scene>): Mesh;
  52309. /**
  52310. * Creates a torus knot mesh
  52311. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52312. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52313. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52314. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52315. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52316. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52317. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52318. * @param name defines the name of the mesh
  52319. * @param options defines the options used to create the mesh
  52320. * @param scene defines the hosting scene
  52321. * @returns the torus knot mesh
  52322. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52323. */
  52324. static CreateTorusKnot(name: string, options: {
  52325. radius?: number;
  52326. tube?: number;
  52327. radialSegments?: number;
  52328. tubularSegments?: number;
  52329. p?: number;
  52330. q?: number;
  52331. updatable?: boolean;
  52332. sideOrientation?: number;
  52333. frontUVs?: Vector4;
  52334. backUVs?: Vector4;
  52335. }, scene?: Nullable<Scene>): Mesh;
  52336. /**
  52337. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52338. * * 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
  52339. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52340. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52341. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52342. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52343. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52344. * * 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
  52345. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52346. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52347. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52348. * @param name defines the name of the new line system
  52349. * @param options defines the options used to create the line system
  52350. * @param scene defines the hosting scene
  52351. * @returns a new line system mesh
  52352. */
  52353. static CreateLineSystem(name: string, options: {
  52354. lines: Vector3[][];
  52355. updatable?: boolean;
  52356. instance?: Nullable<LinesMesh>;
  52357. colors?: Nullable<Color4[][]>;
  52358. useVertexAlpha?: boolean;
  52359. }, scene: Nullable<Scene>): LinesMesh;
  52360. /**
  52361. * Creates a line mesh
  52362. * 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
  52363. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52364. * * The parameter `points` is an array successive Vector3
  52365. * * 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
  52366. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52367. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52368. * * When updating an instance, remember that only point positions can change, not the number of points
  52369. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52370. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52371. * @param name defines the name of the new line system
  52372. * @param options defines the options used to create the line system
  52373. * @param scene defines the hosting scene
  52374. * @returns a new line mesh
  52375. */
  52376. static CreateLines(name: string, options: {
  52377. points: Vector3[];
  52378. updatable?: boolean;
  52379. instance?: Nullable<LinesMesh>;
  52380. colors?: Color4[];
  52381. useVertexAlpha?: boolean;
  52382. }, scene?: Nullable<Scene>): LinesMesh;
  52383. /**
  52384. * Creates a dashed line mesh
  52385. * * 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
  52386. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52387. * * The parameter `points` is an array successive Vector3
  52388. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52389. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52390. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52391. * * 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
  52392. * * When updating an instance, remember that only point positions can change, not the number of points
  52393. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52394. * @param name defines the name of the mesh
  52395. * @param options defines the options used to create the mesh
  52396. * @param scene defines the hosting scene
  52397. * @returns the dashed line mesh
  52398. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52399. */
  52400. static CreateDashedLines(name: string, options: {
  52401. points: Vector3[];
  52402. dashSize?: number;
  52403. gapSize?: number;
  52404. dashNb?: number;
  52405. updatable?: boolean;
  52406. instance?: LinesMesh;
  52407. }, scene?: Nullable<Scene>): LinesMesh;
  52408. /**
  52409. * 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.
  52410. * * 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.
  52411. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52412. * * 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.
  52413. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52414. * * 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
  52415. * * 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
  52416. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52417. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52418. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52419. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52420. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52421. * @param name defines the name of the mesh
  52422. * @param options defines the options used to create the mesh
  52423. * @param scene defines the hosting scene
  52424. * @returns the extruded shape mesh
  52425. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52426. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52427. */
  52428. static ExtrudeShape(name: string, options: {
  52429. shape: Vector3[];
  52430. path: Vector3[];
  52431. scale?: number;
  52432. rotation?: number;
  52433. cap?: number;
  52434. updatable?: boolean;
  52435. sideOrientation?: number;
  52436. frontUVs?: Vector4;
  52437. backUVs?: Vector4;
  52438. instance?: Mesh;
  52439. invertUV?: boolean;
  52440. }, scene?: Nullable<Scene>): Mesh;
  52441. /**
  52442. * Creates an custom extruded shape mesh.
  52443. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52444. * * 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.
  52445. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52446. * * 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
  52447. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52448. * * 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
  52449. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52450. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52451. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52452. * * 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
  52453. * * 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
  52454. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52455. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52456. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52457. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52458. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52459. * @param name defines the name of the mesh
  52460. * @param options defines the options used to create the mesh
  52461. * @param scene defines the hosting scene
  52462. * @returns the custom extruded shape mesh
  52463. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52464. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52465. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52466. */
  52467. static ExtrudeShapeCustom(name: string, options: {
  52468. shape: Vector3[];
  52469. path: Vector3[];
  52470. scaleFunction?: any;
  52471. rotationFunction?: any;
  52472. ribbonCloseArray?: boolean;
  52473. ribbonClosePath?: boolean;
  52474. cap?: number;
  52475. updatable?: boolean;
  52476. sideOrientation?: number;
  52477. frontUVs?: Vector4;
  52478. backUVs?: Vector4;
  52479. instance?: Mesh;
  52480. invertUV?: boolean;
  52481. }, scene?: Nullable<Scene>): Mesh;
  52482. /**
  52483. * Creates lathe mesh.
  52484. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  52485. * * 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
  52486. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  52487. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  52488. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  52489. * * 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
  52490. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  52491. * * 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
  52492. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52493. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52494. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52495. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52496. * @param name defines the name of the mesh
  52497. * @param options defines the options used to create the mesh
  52498. * @param scene defines the hosting scene
  52499. * @returns the lathe mesh
  52500. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  52501. */
  52502. static CreateLathe(name: string, options: {
  52503. shape: Vector3[];
  52504. radius?: number;
  52505. tessellation?: number;
  52506. clip?: number;
  52507. arc?: number;
  52508. closed?: boolean;
  52509. updatable?: boolean;
  52510. sideOrientation?: number;
  52511. frontUVs?: Vector4;
  52512. backUVs?: Vector4;
  52513. cap?: number;
  52514. invertUV?: boolean;
  52515. }, scene?: Nullable<Scene>): Mesh;
  52516. /**
  52517. * Creates a plane mesh
  52518. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  52519. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  52520. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  52521. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52522. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52523. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52524. * @param name defines the name of the mesh
  52525. * @param options defines the options used to create the mesh
  52526. * @param scene defines the hosting scene
  52527. * @returns the plane mesh
  52528. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  52529. */
  52530. static CreatePlane(name: string, options: {
  52531. size?: number;
  52532. width?: number;
  52533. height?: number;
  52534. sideOrientation?: number;
  52535. frontUVs?: Vector4;
  52536. backUVs?: Vector4;
  52537. updatable?: boolean;
  52538. sourcePlane?: Plane;
  52539. }, scene?: Nullable<Scene>): Mesh;
  52540. /**
  52541. * Creates a ground mesh
  52542. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  52543. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  52544. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52545. * @param name defines the name of the mesh
  52546. * @param options defines the options used to create the mesh
  52547. * @param scene defines the hosting scene
  52548. * @returns the ground mesh
  52549. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  52550. */
  52551. static CreateGround(name: string, options: {
  52552. width?: number;
  52553. height?: number;
  52554. subdivisions?: number;
  52555. subdivisionsX?: number;
  52556. subdivisionsY?: number;
  52557. updatable?: boolean;
  52558. }, scene?: Nullable<Scene>): Mesh;
  52559. /**
  52560. * Creates a tiled ground mesh
  52561. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  52562. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  52563. * * 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
  52564. * * 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
  52565. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52566. * @param name defines the name of the mesh
  52567. * @param options defines the options used to create the mesh
  52568. * @param scene defines the hosting scene
  52569. * @returns the tiled ground mesh
  52570. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  52571. */
  52572. static CreateTiledGround(name: string, options: {
  52573. xmin: number;
  52574. zmin: number;
  52575. xmax: number;
  52576. zmax: number;
  52577. subdivisions?: {
  52578. w: number;
  52579. h: number;
  52580. };
  52581. precision?: {
  52582. w: number;
  52583. h: number;
  52584. };
  52585. updatable?: boolean;
  52586. }, scene?: Nullable<Scene>): Mesh;
  52587. /**
  52588. * Creates a ground mesh from a height map
  52589. * * The parameter `url` sets the URL of the height map image resource.
  52590. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  52591. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  52592. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  52593. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  52594. * * 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.
  52595. * * 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).
  52596. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  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 url defines the url to the height map
  52600. * @param options defines the options used to create the mesh
  52601. * @param scene defines the hosting scene
  52602. * @returns the ground mesh
  52603. * @see https://doc.babylonjs.com/babylon101/height_map
  52604. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  52605. */
  52606. static CreateGroundFromHeightMap(name: string, url: string, options: {
  52607. width?: number;
  52608. height?: number;
  52609. subdivisions?: number;
  52610. minHeight?: number;
  52611. maxHeight?: number;
  52612. colorFilter?: Color3;
  52613. alphaFilter?: number;
  52614. updatable?: boolean;
  52615. onReady?: (mesh: GroundMesh) => void;
  52616. }, scene?: Nullable<Scene>): GroundMesh;
  52617. /**
  52618. * Creates a polygon mesh
  52619. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  52620. * * 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
  52621. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52622. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  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)
  52624. * * Remember you can only change the shape positions, not their number when updating a polygon
  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. * @param earcutInjection can be used to inject your own earcut reference
  52629. * @returns the polygon mesh
  52630. */
  52631. static CreatePolygon(name: string, options: {
  52632. shape: Vector3[];
  52633. holes?: Vector3[][];
  52634. depth?: number;
  52635. faceUV?: Vector4[];
  52636. faceColors?: Color4[];
  52637. updatable?: boolean;
  52638. sideOrientation?: number;
  52639. frontUVs?: Vector4;
  52640. backUVs?: Vector4;
  52641. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52642. /**
  52643. * Creates an extruded polygon mesh, with depth in the Y direction.
  52644. * * 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)
  52645. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52646. * @param name defines the name of the mesh
  52647. * @param options defines the options used to create the mesh
  52648. * @param scene defines the hosting scene
  52649. * @param earcutInjection can be used to inject your own earcut reference
  52650. * @returns the polygon mesh
  52651. */
  52652. static ExtrudePolygon(name: string, options: {
  52653. shape: Vector3[];
  52654. holes?: Vector3[][];
  52655. depth?: number;
  52656. faceUV?: Vector4[];
  52657. faceColors?: Color4[];
  52658. updatable?: boolean;
  52659. sideOrientation?: number;
  52660. frontUVs?: Vector4;
  52661. backUVs?: Vector4;
  52662. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52663. /**
  52664. * Creates a tube mesh.
  52665. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52666. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  52667. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  52668. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  52669. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  52670. * * 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)
  52671. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  52672. * * 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
  52673. * * 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
  52674. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52675. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52676. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52677. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52678. * @param name defines the name of the mesh
  52679. * @param options defines the options used to create the mesh
  52680. * @param scene defines the hosting scene
  52681. * @returns the tube mesh
  52682. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52683. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  52684. */
  52685. static CreateTube(name: string, options: {
  52686. path: Vector3[];
  52687. radius?: number;
  52688. tessellation?: number;
  52689. radiusFunction?: {
  52690. (i: number, distance: number): number;
  52691. };
  52692. cap?: number;
  52693. arc?: number;
  52694. updatable?: boolean;
  52695. sideOrientation?: number;
  52696. frontUVs?: Vector4;
  52697. backUVs?: Vector4;
  52698. instance?: Mesh;
  52699. invertUV?: boolean;
  52700. }, scene?: Nullable<Scene>): Mesh;
  52701. /**
  52702. * Creates a polyhedron mesh
  52703. * * 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
  52704. * * The parameter `size` (positive float, default 1) sets the polygon size
  52705. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  52706. * * 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`
  52707. * * 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
  52708. * * 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)`)
  52709. * * 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
  52710. * * 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
  52711. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52712. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52713. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52714. * @param name defines the name of the mesh
  52715. * @param options defines the options used to create the mesh
  52716. * @param scene defines the hosting scene
  52717. * @returns the polyhedron mesh
  52718. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  52719. */
  52720. static CreatePolyhedron(name: string, options: {
  52721. type?: number;
  52722. size?: number;
  52723. sizeX?: number;
  52724. sizeY?: number;
  52725. sizeZ?: number;
  52726. custom?: any;
  52727. faceUV?: Vector4[];
  52728. faceColors?: Color4[];
  52729. flat?: boolean;
  52730. updatable?: boolean;
  52731. sideOrientation?: number;
  52732. frontUVs?: Vector4;
  52733. backUVs?: Vector4;
  52734. }, scene?: Nullable<Scene>): Mesh;
  52735. /**
  52736. * Creates a decal mesh.
  52737. * 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
  52738. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  52739. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  52740. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  52741. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  52742. * @param name defines the name of the mesh
  52743. * @param sourceMesh defines the mesh where the decal must be applied
  52744. * @param options defines the options used to create the mesh
  52745. * @param scene defines the hosting scene
  52746. * @returns the decal mesh
  52747. * @see https://doc.babylonjs.com/how_to/decals
  52748. */
  52749. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  52750. position?: Vector3;
  52751. normal?: Vector3;
  52752. size?: Vector3;
  52753. angle?: number;
  52754. }): Mesh;
  52755. }
  52756. }
  52757. declare module "babylonjs/Meshes/meshSimplification" {
  52758. import { Mesh } from "babylonjs/Meshes/mesh";
  52759. /**
  52760. * A simplifier interface for future simplification implementations
  52761. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52762. */
  52763. export interface ISimplifier {
  52764. /**
  52765. * Simplification of a given mesh according to the given settings.
  52766. * Since this requires computation, it is assumed that the function runs async.
  52767. * @param settings The settings of the simplification, including quality and distance
  52768. * @param successCallback A callback that will be called after the mesh was simplified.
  52769. * @param errorCallback in case of an error, this callback will be called. optional.
  52770. */
  52771. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  52772. }
  52773. /**
  52774. * Expected simplification settings.
  52775. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  52776. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52777. */
  52778. export interface ISimplificationSettings {
  52779. /**
  52780. * Gets or sets the expected quality
  52781. */
  52782. quality: number;
  52783. /**
  52784. * Gets or sets the distance when this optimized version should be used
  52785. */
  52786. distance: number;
  52787. /**
  52788. * Gets an already optimized mesh
  52789. */
  52790. optimizeMesh?: boolean;
  52791. }
  52792. /**
  52793. * Class used to specify simplification options
  52794. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52795. */
  52796. export class SimplificationSettings implements ISimplificationSettings {
  52797. /** expected quality */
  52798. quality: number;
  52799. /** distance when this optimized version should be used */
  52800. distance: number;
  52801. /** already optimized mesh */
  52802. optimizeMesh?: boolean | undefined;
  52803. /**
  52804. * Creates a SimplificationSettings
  52805. * @param quality expected quality
  52806. * @param distance distance when this optimized version should be used
  52807. * @param optimizeMesh already optimized mesh
  52808. */
  52809. constructor(
  52810. /** expected quality */
  52811. quality: number,
  52812. /** distance when this optimized version should be used */
  52813. distance: number,
  52814. /** already optimized mesh */
  52815. optimizeMesh?: boolean | undefined);
  52816. }
  52817. /**
  52818. * Interface used to define a simplification task
  52819. */
  52820. export interface ISimplificationTask {
  52821. /**
  52822. * Array of settings
  52823. */
  52824. settings: Array<ISimplificationSettings>;
  52825. /**
  52826. * Simplification type
  52827. */
  52828. simplificationType: SimplificationType;
  52829. /**
  52830. * Mesh to simplify
  52831. */
  52832. mesh: Mesh;
  52833. /**
  52834. * Callback called on success
  52835. */
  52836. successCallback?: () => void;
  52837. /**
  52838. * Defines if parallel processing can be used
  52839. */
  52840. parallelProcessing: boolean;
  52841. }
  52842. /**
  52843. * Queue used to order the simplification tasks
  52844. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52845. */
  52846. export class SimplificationQueue {
  52847. private _simplificationArray;
  52848. /**
  52849. * Gets a boolean indicating that the process is still running
  52850. */
  52851. running: boolean;
  52852. /**
  52853. * Creates a new queue
  52854. */
  52855. constructor();
  52856. /**
  52857. * Adds a new simplification task
  52858. * @param task defines a task to add
  52859. */
  52860. addTask(task: ISimplificationTask): void;
  52861. /**
  52862. * Execute next task
  52863. */
  52864. executeNext(): void;
  52865. /**
  52866. * Execute a simplification task
  52867. * @param task defines the task to run
  52868. */
  52869. runSimplification(task: ISimplificationTask): void;
  52870. private getSimplifier;
  52871. }
  52872. /**
  52873. * The implemented types of simplification
  52874. * At the moment only Quadratic Error Decimation is implemented
  52875. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52876. */
  52877. export enum SimplificationType {
  52878. /** Quadratic error decimation */
  52879. QUADRATIC = 0
  52880. }
  52881. }
  52882. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  52883. import { Scene } from "babylonjs/scene";
  52884. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  52885. import { ISceneComponent } from "babylonjs/sceneComponent";
  52886. module "babylonjs/scene" {
  52887. interface Scene {
  52888. /** @hidden (Backing field) */
  52889. _simplificationQueue: SimplificationQueue;
  52890. /**
  52891. * Gets or sets the simplification queue attached to the scene
  52892. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52893. */
  52894. simplificationQueue: SimplificationQueue;
  52895. }
  52896. }
  52897. module "babylonjs/Meshes/mesh" {
  52898. interface Mesh {
  52899. /**
  52900. * Simplify the mesh according to the given array of settings.
  52901. * Function will return immediately and will simplify async
  52902. * @param settings a collection of simplification settings
  52903. * @param parallelProcessing should all levels calculate parallel or one after the other
  52904. * @param simplificationType the type of simplification to run
  52905. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  52906. * @returns the current mesh
  52907. */
  52908. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  52909. }
  52910. }
  52911. /**
  52912. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  52913. * created in a scene
  52914. */
  52915. export class SimplicationQueueSceneComponent implements ISceneComponent {
  52916. /**
  52917. * The component name helpfull to identify the component in the list of scene components.
  52918. */
  52919. readonly name: string;
  52920. /**
  52921. * The scene the component belongs to.
  52922. */
  52923. scene: Scene;
  52924. /**
  52925. * Creates a new instance of the component for the given scene
  52926. * @param scene Defines the scene to register the component in
  52927. */
  52928. constructor(scene: Scene);
  52929. /**
  52930. * Registers the component in a given scene
  52931. */
  52932. register(): void;
  52933. /**
  52934. * Rebuilds the elements related to this component in case of
  52935. * context lost for instance.
  52936. */
  52937. rebuild(): void;
  52938. /**
  52939. * Disposes the component and the associated ressources
  52940. */
  52941. dispose(): void;
  52942. private _beforeCameraUpdate;
  52943. }
  52944. }
  52945. declare module "babylonjs/Meshes/Builders/index" {
  52946. export * from "babylonjs/Meshes/Builders/boxBuilder";
  52947. export * from "babylonjs/Meshes/Builders/discBuilder";
  52948. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  52949. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  52950. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  52951. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  52952. export * from "babylonjs/Meshes/Builders/torusBuilder";
  52953. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  52954. export * from "babylonjs/Meshes/Builders/linesBuilder";
  52955. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  52956. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  52957. export * from "babylonjs/Meshes/Builders/latheBuilder";
  52958. export * from "babylonjs/Meshes/Builders/planeBuilder";
  52959. export * from "babylonjs/Meshes/Builders/groundBuilder";
  52960. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  52961. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  52962. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  52963. export * from "babylonjs/Meshes/Builders/decalBuilder";
  52964. }
  52965. declare module "babylonjs/Meshes/index" {
  52966. export * from "babylonjs/Meshes/abstractMesh";
  52967. export * from "babylonjs/Meshes/buffer";
  52968. export * from "babylonjs/Meshes/Compression/index";
  52969. export * from "babylonjs/Meshes/csg";
  52970. export * from "babylonjs/Meshes/geometry";
  52971. export * from "babylonjs/Meshes/groundMesh";
  52972. export * from "babylonjs/Meshes/trailMesh";
  52973. export * from "babylonjs/Meshes/instancedMesh";
  52974. export * from "babylonjs/Meshes/linesMesh";
  52975. export * from "babylonjs/Meshes/mesh";
  52976. export * from "babylonjs/Meshes/mesh.vertexData";
  52977. export * from "babylonjs/Meshes/meshBuilder";
  52978. export * from "babylonjs/Meshes/meshSimplification";
  52979. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  52980. export * from "babylonjs/Meshes/polygonMesh";
  52981. export * from "babylonjs/Meshes/subMesh";
  52982. export * from "babylonjs/Meshes/transformNode";
  52983. export * from "babylonjs/Meshes/Builders/index";
  52984. }
  52985. declare module "babylonjs/Morph/index" {
  52986. export * from "babylonjs/Morph/morphTarget";
  52987. export * from "babylonjs/Morph/morphTargetManager";
  52988. }
  52989. declare module "babylonjs/Offline/database" {
  52990. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  52991. /**
  52992. * Class used to enable access to IndexedDB
  52993. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  52994. */
  52995. export class Database implements IOfflineProvider {
  52996. private _callbackManifestChecked;
  52997. private _currentSceneUrl;
  52998. private _db;
  52999. private _enableSceneOffline;
  53000. private _enableTexturesOffline;
  53001. private _manifestVersionFound;
  53002. private _mustUpdateRessources;
  53003. private _hasReachedQuota;
  53004. private _isSupported;
  53005. private _idbFactory;
  53006. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  53007. private static IsUASupportingBlobStorage;
  53008. /**
  53009. * Gets a boolean indicating if Database storate is enabled (off by default)
  53010. */
  53011. static IDBStorageEnabled: boolean;
  53012. /**
  53013. * Gets a boolean indicating if scene must be saved in the database
  53014. */
  53015. readonly enableSceneOffline: boolean;
  53016. /**
  53017. * Gets a boolean indicating if textures must be saved in the database
  53018. */
  53019. readonly enableTexturesOffline: boolean;
  53020. /**
  53021. * Creates a new Database
  53022. * @param urlToScene defines the url to load the scene
  53023. * @param callbackManifestChecked defines the callback to use when manifest is checked
  53024. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  53025. */
  53026. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  53027. private static _ParseURL;
  53028. private static _ReturnFullUrlLocation;
  53029. private _checkManifestFile;
  53030. /**
  53031. * Open the database and make it available
  53032. * @param successCallback defines the callback to call on success
  53033. * @param errorCallback defines the callback to call on error
  53034. */
  53035. open(successCallback: () => void, errorCallback: () => void): void;
  53036. /**
  53037. * Loads an image from the database
  53038. * @param url defines the url to load from
  53039. * @param image defines the target DOM image
  53040. */
  53041. loadImage(url: string, image: HTMLImageElement): void;
  53042. private _loadImageFromDBAsync;
  53043. private _saveImageIntoDBAsync;
  53044. private _checkVersionFromDB;
  53045. private _loadVersionFromDBAsync;
  53046. private _saveVersionIntoDBAsync;
  53047. /**
  53048. * Loads a file from database
  53049. * @param url defines the URL to load from
  53050. * @param sceneLoaded defines a callback to call on success
  53051. * @param progressCallBack defines a callback to call when progress changed
  53052. * @param errorCallback defines a callback to call on error
  53053. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  53054. */
  53055. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  53056. private _loadFileAsync;
  53057. private _saveFileAsync;
  53058. /**
  53059. * Validates if xhr data is correct
  53060. * @param xhr defines the request to validate
  53061. * @param dataType defines the expected data type
  53062. * @returns true if data is correct
  53063. */
  53064. private static _ValidateXHRData;
  53065. }
  53066. }
  53067. declare module "babylonjs/Offline/index" {
  53068. export * from "babylonjs/Offline/database";
  53069. export * from "babylonjs/Offline/IOfflineProvider";
  53070. }
  53071. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  53072. /** @hidden */
  53073. export var gpuUpdateParticlesPixelShader: {
  53074. name: string;
  53075. shader: string;
  53076. };
  53077. }
  53078. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  53079. /** @hidden */
  53080. export var gpuUpdateParticlesVertexShader: {
  53081. name: string;
  53082. shader: string;
  53083. };
  53084. }
  53085. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  53086. /** @hidden */
  53087. export var clipPlaneFragmentDeclaration2: {
  53088. name: string;
  53089. shader: string;
  53090. };
  53091. }
  53092. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  53093. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  53094. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  53095. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53096. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  53097. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  53098. /** @hidden */
  53099. export var gpuRenderParticlesPixelShader: {
  53100. name: string;
  53101. shader: string;
  53102. };
  53103. }
  53104. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  53105. /** @hidden */
  53106. export var clipPlaneVertexDeclaration2: {
  53107. name: string;
  53108. shader: string;
  53109. };
  53110. }
  53111. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  53112. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  53113. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  53114. /** @hidden */
  53115. export var gpuRenderParticlesVertexShader: {
  53116. name: string;
  53117. shader: string;
  53118. };
  53119. }
  53120. declare module "babylonjs/Particles/gpuParticleSystem" {
  53121. import { Nullable } from "babylonjs/types";
  53122. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  53123. import { Observable } from "babylonjs/Misc/observable";
  53124. import { Color4, Color3 } from "babylonjs/Maths/math";
  53125. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53126. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  53127. import { Scene, IDisposable } from "babylonjs/scene";
  53128. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  53129. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  53130. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  53131. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  53132. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  53133. /**
  53134. * This represents a GPU particle system in Babylon
  53135. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  53136. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  53137. */
  53138. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  53139. /**
  53140. * The layer mask we are rendering the particles through.
  53141. */
  53142. layerMask: number;
  53143. private _capacity;
  53144. private _activeCount;
  53145. private _currentActiveCount;
  53146. private _accumulatedCount;
  53147. private _renderEffect;
  53148. private _updateEffect;
  53149. private _buffer0;
  53150. private _buffer1;
  53151. private _spriteBuffer;
  53152. private _updateVAO;
  53153. private _renderVAO;
  53154. private _targetIndex;
  53155. private _sourceBuffer;
  53156. private _targetBuffer;
  53157. private _engine;
  53158. private _currentRenderId;
  53159. private _started;
  53160. private _stopped;
  53161. private _timeDelta;
  53162. private _randomTexture;
  53163. private _randomTexture2;
  53164. private _attributesStrideSize;
  53165. private _updateEffectOptions;
  53166. private _randomTextureSize;
  53167. private _actualFrame;
  53168. private readonly _rawTextureWidth;
  53169. /**
  53170. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  53171. */
  53172. static readonly IsSupported: boolean;
  53173. /**
  53174. * An event triggered when the system is disposed.
  53175. */
  53176. onDisposeObservable: Observable<GPUParticleSystem>;
  53177. /**
  53178. * Gets the maximum number of particles active at the same time.
  53179. * @returns The max number of active particles.
  53180. */
  53181. getCapacity(): number;
  53182. /**
  53183. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  53184. * to override the particles.
  53185. */
  53186. forceDepthWrite: boolean;
  53187. /**
  53188. * Gets or set the number of active particles
  53189. */
  53190. activeParticleCount: number;
  53191. private _preWarmDone;
  53192. /**
  53193. * Is this system ready to be used/rendered
  53194. * @return true if the system is ready
  53195. */
  53196. isReady(): boolean;
  53197. /**
  53198. * Gets if the system has been started. (Note: this will still be true after stop is called)
  53199. * @returns True if it has been started, otherwise false.
  53200. */
  53201. isStarted(): boolean;
  53202. /**
  53203. * Starts the particle system and begins to emit
  53204. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  53205. */
  53206. start(delay?: number): void;
  53207. /**
  53208. * Stops the particle system.
  53209. */
  53210. stop(): void;
  53211. /**
  53212. * Remove all active particles
  53213. */
  53214. reset(): void;
  53215. /**
  53216. * Returns the string "GPUParticleSystem"
  53217. * @returns a string containing the class name
  53218. */
  53219. getClassName(): string;
  53220. private _colorGradientsTexture;
  53221. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  53222. /**
  53223. * Adds a new color gradient
  53224. * @param gradient defines the gradient to use (between 0 and 1)
  53225. * @param color1 defines the color to affect to the specified gradient
  53226. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  53227. * @returns the current particle system
  53228. */
  53229. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  53230. /**
  53231. * Remove a specific color gradient
  53232. * @param gradient defines the gradient to remove
  53233. * @returns the current particle system
  53234. */
  53235. removeColorGradient(gradient: number): GPUParticleSystem;
  53236. private _angularSpeedGradientsTexture;
  53237. private _sizeGradientsTexture;
  53238. private _velocityGradientsTexture;
  53239. private _limitVelocityGradientsTexture;
  53240. private _dragGradientsTexture;
  53241. private _addFactorGradient;
  53242. /**
  53243. * Adds a new size gradient
  53244. * @param gradient defines the gradient to use (between 0 and 1)
  53245. * @param factor defines the size factor to affect to the specified gradient
  53246. * @returns the current particle system
  53247. */
  53248. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  53249. /**
  53250. * Remove a specific size gradient
  53251. * @param gradient defines the gradient to remove
  53252. * @returns the current particle system
  53253. */
  53254. removeSizeGradient(gradient: number): GPUParticleSystem;
  53255. /**
  53256. * Adds a new angular speed gradient
  53257. * @param gradient defines the gradient to use (between 0 and 1)
  53258. * @param factor defines the angular speed to affect to the specified gradient
  53259. * @returns the current particle system
  53260. */
  53261. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  53262. /**
  53263. * Remove a specific angular speed gradient
  53264. * @param gradient defines the gradient to remove
  53265. * @returns the current particle system
  53266. */
  53267. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  53268. /**
  53269. * Adds a new velocity gradient
  53270. * @param gradient defines the gradient to use (between 0 and 1)
  53271. * @param factor defines the velocity to affect to the specified gradient
  53272. * @returns the current particle system
  53273. */
  53274. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53275. /**
  53276. * Remove a specific velocity gradient
  53277. * @param gradient defines the gradient to remove
  53278. * @returns the current particle system
  53279. */
  53280. removeVelocityGradient(gradient: number): GPUParticleSystem;
  53281. /**
  53282. * Adds a new limit velocity gradient
  53283. * @param gradient defines the gradient to use (between 0 and 1)
  53284. * @param factor defines the limit velocity value to affect to the specified gradient
  53285. * @returns the current particle system
  53286. */
  53287. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53288. /**
  53289. * Remove a specific limit velocity gradient
  53290. * @param gradient defines the gradient to remove
  53291. * @returns the current particle system
  53292. */
  53293. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  53294. /**
  53295. * Adds a new drag gradient
  53296. * @param gradient defines the gradient to use (between 0 and 1)
  53297. * @param factor defines the drag value to affect to the specified gradient
  53298. * @returns the current particle system
  53299. */
  53300. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  53301. /**
  53302. * Remove a specific drag gradient
  53303. * @param gradient defines the gradient to remove
  53304. * @returns the current particle system
  53305. */
  53306. removeDragGradient(gradient: number): GPUParticleSystem;
  53307. /**
  53308. * Not supported by GPUParticleSystem
  53309. * @param gradient defines the gradient to use (between 0 and 1)
  53310. * @param factor defines the emit rate value to affect to the specified gradient
  53311. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53312. * @returns the current particle system
  53313. */
  53314. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53315. /**
  53316. * Not supported by GPUParticleSystem
  53317. * @param gradient defines the gradient to remove
  53318. * @returns the current particle system
  53319. */
  53320. removeEmitRateGradient(gradient: number): IParticleSystem;
  53321. /**
  53322. * Not supported by GPUParticleSystem
  53323. * @param gradient defines the gradient to use (between 0 and 1)
  53324. * @param factor defines the start size value to affect to the specified gradient
  53325. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53326. * @returns the current particle system
  53327. */
  53328. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53329. /**
  53330. * Not supported by GPUParticleSystem
  53331. * @param gradient defines the gradient to remove
  53332. * @returns the current particle system
  53333. */
  53334. removeStartSizeGradient(gradient: number): IParticleSystem;
  53335. /**
  53336. * Not supported by GPUParticleSystem
  53337. * @param gradient defines the gradient to use (between 0 and 1)
  53338. * @param min defines the color remap minimal range
  53339. * @param max defines the color remap maximal range
  53340. * @returns the current particle system
  53341. */
  53342. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53343. /**
  53344. * Not supported by GPUParticleSystem
  53345. * @param gradient defines the gradient to remove
  53346. * @returns the current particle system
  53347. */
  53348. removeColorRemapGradient(): IParticleSystem;
  53349. /**
  53350. * Not supported by GPUParticleSystem
  53351. * @param gradient defines the gradient to use (between 0 and 1)
  53352. * @param min defines the alpha remap minimal range
  53353. * @param max defines the alpha remap maximal range
  53354. * @returns the current particle system
  53355. */
  53356. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53357. /**
  53358. * Not supported by GPUParticleSystem
  53359. * @param gradient defines the gradient to remove
  53360. * @returns the current particle system
  53361. */
  53362. removeAlphaRemapGradient(): IParticleSystem;
  53363. /**
  53364. * Not supported by GPUParticleSystem
  53365. * @param gradient defines the gradient to use (between 0 and 1)
  53366. * @param color defines the color to affect to the specified gradient
  53367. * @returns the current particle system
  53368. */
  53369. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  53370. /**
  53371. * Not supported by GPUParticleSystem
  53372. * @param gradient defines the gradient to remove
  53373. * @returns the current particle system
  53374. */
  53375. removeRampGradient(): IParticleSystem;
  53376. /**
  53377. * Not supported by GPUParticleSystem
  53378. * @returns the list of ramp gradients
  53379. */
  53380. getRampGradients(): Nullable<Array<Color3Gradient>>;
  53381. /**
  53382. * Not supported by GPUParticleSystem
  53383. * Gets or sets a boolean indicating that ramp gradients must be used
  53384. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  53385. */
  53386. useRampGradients: boolean;
  53387. /**
  53388. * Not supported by GPUParticleSystem
  53389. * @param gradient defines the gradient to use (between 0 and 1)
  53390. * @param factor defines the life time factor to affect to the specified gradient
  53391. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53392. * @returns the current particle system
  53393. */
  53394. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53395. /**
  53396. * Not supported by GPUParticleSystem
  53397. * @param gradient defines the gradient to remove
  53398. * @returns the current particle system
  53399. */
  53400. removeLifeTimeGradient(gradient: number): IParticleSystem;
  53401. /**
  53402. * Instantiates a GPU particle system.
  53403. * 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.
  53404. * @param name The name of the particle system
  53405. * @param options The options used to create the system
  53406. * @param scene The scene the particle system belongs to
  53407. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  53408. */
  53409. constructor(name: string, options: Partial<{
  53410. capacity: number;
  53411. randomTextureSize: number;
  53412. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  53413. protected _reset(): void;
  53414. private _createUpdateVAO;
  53415. private _createRenderVAO;
  53416. private _initialize;
  53417. /** @hidden */
  53418. _recreateUpdateEffect(): void;
  53419. /** @hidden */
  53420. _recreateRenderEffect(): void;
  53421. /**
  53422. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  53423. * @param preWarm defines if we are in the pre-warmimg phase
  53424. */
  53425. animate(preWarm?: boolean): void;
  53426. private _createFactorGradientTexture;
  53427. private _createSizeGradientTexture;
  53428. private _createAngularSpeedGradientTexture;
  53429. private _createVelocityGradientTexture;
  53430. private _createLimitVelocityGradientTexture;
  53431. private _createDragGradientTexture;
  53432. private _createColorGradientTexture;
  53433. /**
  53434. * Renders the particle system in its current state
  53435. * @param preWarm defines if the system should only update the particles but not render them
  53436. * @returns the current number of particles
  53437. */
  53438. render(preWarm?: boolean): number;
  53439. /**
  53440. * Rebuilds the particle system
  53441. */
  53442. rebuild(): void;
  53443. private _releaseBuffers;
  53444. private _releaseVAOs;
  53445. /**
  53446. * Disposes the particle system and free the associated resources
  53447. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  53448. */
  53449. dispose(disposeTexture?: boolean): void;
  53450. /**
  53451. * Clones the particle system.
  53452. * @param name The name of the cloned object
  53453. * @param newEmitter The new emitter to use
  53454. * @returns the cloned particle system
  53455. */
  53456. clone(name: string, newEmitter: any): GPUParticleSystem;
  53457. /**
  53458. * Serializes the particle system to a JSON object.
  53459. * @returns the JSON object
  53460. */
  53461. serialize(): any;
  53462. /**
  53463. * Parses a JSON object to create a GPU particle system.
  53464. * @param parsedParticleSystem The JSON object to parse
  53465. * @param scene The scene to create the particle system in
  53466. * @param rootUrl The root url to use to load external dependencies like texture
  53467. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  53468. * @returns the parsed GPU particle system
  53469. */
  53470. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  53471. }
  53472. }
  53473. declare module "babylonjs/Particles/particleSystemSet" {
  53474. import { Nullable } from "babylonjs/types";
  53475. import { Color3 } from "babylonjs/Maths/math";
  53476. import { TransformNode } from "babylonjs/Meshes/transformNode";
  53477. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53478. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53479. import { Scene, IDisposable } from "babylonjs/scene";
  53480. /**
  53481. * Represents a set of particle systems working together to create a specific effect
  53482. */
  53483. export class ParticleSystemSet implements IDisposable {
  53484. private _emitterCreationOptions;
  53485. private _emitterNode;
  53486. /**
  53487. * Gets the particle system list
  53488. */
  53489. systems: IParticleSystem[];
  53490. /**
  53491. * Gets the emitter node used with this set
  53492. */
  53493. readonly emitterNode: Nullable<TransformNode>;
  53494. /**
  53495. * Creates a new emitter mesh as a sphere
  53496. * @param options defines the options used to create the sphere
  53497. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  53498. * @param scene defines the hosting scene
  53499. */
  53500. setEmitterAsSphere(options: {
  53501. diameter: number;
  53502. segments: number;
  53503. color: Color3;
  53504. }, renderingGroupId: number, scene: Scene): void;
  53505. /**
  53506. * Starts all particle systems of the set
  53507. * @param emitter defines an optional mesh to use as emitter for the particle systems
  53508. */
  53509. start(emitter?: AbstractMesh): void;
  53510. /**
  53511. * Release all associated resources
  53512. */
  53513. dispose(): void;
  53514. /**
  53515. * Serialize the set into a JSON compatible object
  53516. * @returns a JSON compatible representation of the set
  53517. */
  53518. serialize(): any;
  53519. /**
  53520. * Parse a new ParticleSystemSet from a serialized source
  53521. * @param data defines a JSON compatible representation of the set
  53522. * @param scene defines the hosting scene
  53523. * @param gpu defines if we want GPU particles or CPU particles
  53524. * @returns a new ParticleSystemSet
  53525. */
  53526. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  53527. }
  53528. }
  53529. declare module "babylonjs/Particles/particleHelper" {
  53530. import { Nullable } from "babylonjs/types";
  53531. import { Scene } from "babylonjs/scene";
  53532. import { Vector3 } from "babylonjs/Maths/math";
  53533. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53534. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53535. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  53536. /**
  53537. * This class is made for on one-liner static method to help creating particle system set.
  53538. */
  53539. export class ParticleHelper {
  53540. /**
  53541. * Gets or sets base Assets URL
  53542. */
  53543. static BaseAssetsUrl: string;
  53544. /**
  53545. * Create a default particle system that you can tweak
  53546. * @param emitter defines the emitter to use
  53547. * @param capacity defines the system capacity (default is 500 particles)
  53548. * @param scene defines the hosting scene
  53549. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  53550. * @returns the new Particle system
  53551. */
  53552. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  53553. /**
  53554. * This is the main static method (one-liner) of this helper to create different particle systems
  53555. * @param type This string represents the type to the particle system to create
  53556. * @param scene The scene where the particle system should live
  53557. * @param gpu If the system will use gpu
  53558. * @returns the ParticleSystemSet created
  53559. */
  53560. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  53561. /**
  53562. * Static function used to export a particle system to a ParticleSystemSet variable.
  53563. * Please note that the emitter shape is not exported
  53564. * @param systems defines the particle systems to export
  53565. * @returns the created particle system set
  53566. */
  53567. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  53568. }
  53569. }
  53570. declare module "babylonjs/Particles/particleSystemComponent" {
  53571. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53572. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  53573. import "babylonjs/Shaders/particles.vertex";
  53574. module "babylonjs/Engines/engine" {
  53575. interface Engine {
  53576. /**
  53577. * Create an effect to use with particle systems.
  53578. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  53579. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  53580. * @param uniformsNames defines a list of attribute names
  53581. * @param samplers defines an array of string used to represent textures
  53582. * @param defines defines the string containing the defines to use to compile the shaders
  53583. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  53584. * @param onCompiled defines a function to call when the effect creation is successful
  53585. * @param onError defines a function to call when the effect creation has failed
  53586. * @returns the new Effect
  53587. */
  53588. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  53589. }
  53590. }
  53591. module "babylonjs/Meshes/mesh" {
  53592. interface Mesh {
  53593. /**
  53594. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  53595. * @returns an array of IParticleSystem
  53596. */
  53597. getEmittedParticleSystems(): IParticleSystem[];
  53598. /**
  53599. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  53600. * @returns an array of IParticleSystem
  53601. */
  53602. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  53603. }
  53604. }
  53605. /**
  53606. * @hidden
  53607. */
  53608. export var _IDoNeedToBeInTheBuild: number;
  53609. }
  53610. declare module "babylonjs/Particles/index" {
  53611. export * from "babylonjs/Particles/baseParticleSystem";
  53612. export * from "babylonjs/Particles/EmitterTypes/index";
  53613. export * from "babylonjs/Particles/gpuParticleSystem";
  53614. export * from "babylonjs/Particles/IParticleSystem";
  53615. export * from "babylonjs/Particles/particle";
  53616. export * from "babylonjs/Particles/particleHelper";
  53617. export * from "babylonjs/Particles/particleSystem";
  53618. export * from "babylonjs/Particles/particleSystemComponent";
  53619. export * from "babylonjs/Particles/particleSystemSet";
  53620. export * from "babylonjs/Particles/solidParticle";
  53621. export * from "babylonjs/Particles/solidParticleSystem";
  53622. export * from "babylonjs/Particles/subEmitter";
  53623. }
  53624. declare module "babylonjs/Physics/physicsEngineComponent" {
  53625. import { Nullable } from "babylonjs/types";
  53626. import { Observable, Observer } from "babylonjs/Misc/observable";
  53627. import { Vector3 } from "babylonjs/Maths/math";
  53628. import { Mesh } from "babylonjs/Meshes/mesh";
  53629. import { ISceneComponent } from "babylonjs/sceneComponent";
  53630. import { Scene } from "babylonjs/scene";
  53631. import { Node } from "babylonjs/node";
  53632. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53633. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53634. module "babylonjs/scene" {
  53635. interface Scene {
  53636. /** @hidden (Backing field) */
  53637. _physicsEngine: Nullable<IPhysicsEngine>;
  53638. /**
  53639. * Gets the current physics engine
  53640. * @returns a IPhysicsEngine or null if none attached
  53641. */
  53642. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  53643. /**
  53644. * Enables physics to the current scene
  53645. * @param gravity defines the scene's gravity for the physics engine
  53646. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  53647. * @return a boolean indicating if the physics engine was initialized
  53648. */
  53649. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  53650. /**
  53651. * Disables and disposes the physics engine associated with the scene
  53652. */
  53653. disablePhysicsEngine(): void;
  53654. /**
  53655. * Gets a boolean indicating if there is an active physics engine
  53656. * @returns a boolean indicating if there is an active physics engine
  53657. */
  53658. isPhysicsEnabled(): boolean;
  53659. /**
  53660. * Deletes a physics compound impostor
  53661. * @param compound defines the compound to delete
  53662. */
  53663. deleteCompoundImpostor(compound: any): void;
  53664. /**
  53665. * An event triggered when physic simulation is about to be run
  53666. */
  53667. onBeforePhysicsObservable: Observable<Scene>;
  53668. /**
  53669. * An event triggered when physic simulation has been done
  53670. */
  53671. onAfterPhysicsObservable: Observable<Scene>;
  53672. }
  53673. }
  53674. module "babylonjs/Meshes/abstractMesh" {
  53675. interface AbstractMesh {
  53676. /** @hidden */
  53677. _physicsImpostor: Nullable<PhysicsImpostor>;
  53678. /**
  53679. * Gets or sets impostor used for physic simulation
  53680. * @see http://doc.babylonjs.com/features/physics_engine
  53681. */
  53682. physicsImpostor: Nullable<PhysicsImpostor>;
  53683. /**
  53684. * Gets the current physics impostor
  53685. * @see http://doc.babylonjs.com/features/physics_engine
  53686. * @returns a physics impostor or null
  53687. */
  53688. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  53689. /** Apply a physic impulse to the mesh
  53690. * @param force defines the force to apply
  53691. * @param contactPoint defines where to apply the force
  53692. * @returns the current mesh
  53693. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53694. */
  53695. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  53696. /**
  53697. * Creates a physic joint between two meshes
  53698. * @param otherMesh defines the other mesh to use
  53699. * @param pivot1 defines the pivot to use on this mesh
  53700. * @param pivot2 defines the pivot to use on the other mesh
  53701. * @param options defines additional options (can be plugin dependent)
  53702. * @returns the current mesh
  53703. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  53704. */
  53705. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  53706. /** @hidden */
  53707. _disposePhysicsObserver: Nullable<Observer<Node>>;
  53708. }
  53709. }
  53710. /**
  53711. * Defines the physics engine scene component responsible to manage a physics engine
  53712. */
  53713. export class PhysicsEngineSceneComponent implements ISceneComponent {
  53714. /**
  53715. * The component name helpful to identify the component in the list of scene components.
  53716. */
  53717. readonly name: string;
  53718. /**
  53719. * The scene the component belongs to.
  53720. */
  53721. scene: Scene;
  53722. /**
  53723. * Creates a new instance of the component for the given scene
  53724. * @param scene Defines the scene to register the component in
  53725. */
  53726. constructor(scene: Scene);
  53727. /**
  53728. * Registers the component in a given scene
  53729. */
  53730. register(): void;
  53731. /**
  53732. * Rebuilds the elements related to this component in case of
  53733. * context lost for instance.
  53734. */
  53735. rebuild(): void;
  53736. /**
  53737. * Disposes the component and the associated ressources
  53738. */
  53739. dispose(): void;
  53740. }
  53741. }
  53742. declare module "babylonjs/Physics/physicsHelper" {
  53743. import { Nullable } from "babylonjs/types";
  53744. import { Vector3 } from "babylonjs/Maths/math";
  53745. import { Mesh } from "babylonjs/Meshes/mesh";
  53746. import { Scene } from "babylonjs/scene";
  53747. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53748. /**
  53749. * A helper for physics simulations
  53750. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53751. */
  53752. export class PhysicsHelper {
  53753. private _scene;
  53754. private _physicsEngine;
  53755. /**
  53756. * Initializes the Physics helper
  53757. * @param scene Babylon.js scene
  53758. */
  53759. constructor(scene: Scene);
  53760. /**
  53761. * Applies a radial explosion impulse
  53762. * @param origin the origin of the explosion
  53763. * @param radiusOrEventOptions the radius or the options of radial explosion
  53764. * @param strength the explosion strength
  53765. * @param falloff possible options: Constant & Linear. Defaults to Constant
  53766. * @returns A physics radial explosion event, or null
  53767. */
  53768. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  53769. /**
  53770. * Applies a radial explosion force
  53771. * @param origin the origin of the explosion
  53772. * @param radiusOrEventOptions the radius or the options of radial explosion
  53773. * @param strength the explosion strength
  53774. * @param falloff possible options: Constant & Linear. Defaults to Constant
  53775. * @returns A physics radial explosion event, or null
  53776. */
  53777. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  53778. /**
  53779. * Creates a gravitational field
  53780. * @param origin the origin of the explosion
  53781. * @param radiusOrEventOptions the radius or the options of radial explosion
  53782. * @param strength the explosion strength
  53783. * @param falloff possible options: Constant & Linear. Defaults to Constant
  53784. * @returns A physics gravitational field event, or null
  53785. */
  53786. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  53787. /**
  53788. * Creates a physics updraft event
  53789. * @param origin the origin of the updraft
  53790. * @param radiusOrEventOptions the radius or the options of the updraft
  53791. * @param strength the strength of the updraft
  53792. * @param height the height of the updraft
  53793. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  53794. * @returns A physics updraft event, or null
  53795. */
  53796. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  53797. /**
  53798. * Creates a physics vortex event
  53799. * @param origin the of the vortex
  53800. * @param radiusOrEventOptions the radius or the options of the vortex
  53801. * @param strength the strength of the vortex
  53802. * @param height the height of the vortex
  53803. * @returns a Physics vortex event, or null
  53804. * A physics vortex event or null
  53805. */
  53806. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  53807. }
  53808. /**
  53809. * Represents a physics radial explosion event
  53810. */
  53811. class PhysicsRadialExplosionEvent {
  53812. private _scene;
  53813. private _options;
  53814. private _sphere;
  53815. private _dataFetched;
  53816. /**
  53817. * Initializes a radial explosioin event
  53818. * @param _scene BabylonJS scene
  53819. * @param _options The options for the vortex event
  53820. */
  53821. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  53822. /**
  53823. * Returns the data related to the radial explosion event (sphere).
  53824. * @returns The radial explosion event data
  53825. */
  53826. getData(): PhysicsRadialExplosionEventData;
  53827. /**
  53828. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  53829. * @param impostor A physics imposter
  53830. * @param origin the origin of the explosion
  53831. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  53832. */
  53833. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  53834. /**
  53835. * Triggers affecterd impostors callbacks
  53836. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  53837. */
  53838. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  53839. /**
  53840. * Disposes the sphere.
  53841. * @param force Specifies if the sphere should be disposed by force
  53842. */
  53843. dispose(force?: boolean): void;
  53844. /*** Helpers ***/
  53845. private _prepareSphere;
  53846. private _intersectsWithSphere;
  53847. }
  53848. /**
  53849. * Represents a gravitational field event
  53850. */
  53851. class PhysicsGravitationalFieldEvent {
  53852. private _physicsHelper;
  53853. private _scene;
  53854. private _origin;
  53855. private _options;
  53856. private _tickCallback;
  53857. private _sphere;
  53858. private _dataFetched;
  53859. /**
  53860. * Initializes the physics gravitational field event
  53861. * @param _physicsHelper A physics helper
  53862. * @param _scene BabylonJS scene
  53863. * @param _origin The origin position of the gravitational field event
  53864. * @param _options The options for the vortex event
  53865. */
  53866. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  53867. /**
  53868. * Returns the data related to the gravitational field event (sphere).
  53869. * @returns A gravitational field event
  53870. */
  53871. getData(): PhysicsGravitationalFieldEventData;
  53872. /**
  53873. * Enables the gravitational field.
  53874. */
  53875. enable(): void;
  53876. /**
  53877. * Disables the gravitational field.
  53878. */
  53879. disable(): void;
  53880. /**
  53881. * Disposes the sphere.
  53882. * @param force The force to dispose from the gravitational field event
  53883. */
  53884. dispose(force?: boolean): void;
  53885. private _tick;
  53886. }
  53887. /**
  53888. * Represents a physics updraft event
  53889. */
  53890. class PhysicsUpdraftEvent {
  53891. private _scene;
  53892. private _origin;
  53893. private _options;
  53894. private _physicsEngine;
  53895. private _originTop;
  53896. private _originDirection;
  53897. private _tickCallback;
  53898. private _cylinder;
  53899. private _cylinderPosition;
  53900. private _dataFetched;
  53901. /**
  53902. * Initializes the physics updraft event
  53903. * @param _scene BabylonJS scene
  53904. * @param _origin The origin position of the updraft
  53905. * @param _options The options for the updraft event
  53906. */
  53907. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  53908. /**
  53909. * Returns the data related to the updraft event (cylinder).
  53910. * @returns A physics updraft event
  53911. */
  53912. getData(): PhysicsUpdraftEventData;
  53913. /**
  53914. * Enables the updraft.
  53915. */
  53916. enable(): void;
  53917. /**
  53918. * Disables the updraft.
  53919. */
  53920. disable(): void;
  53921. /**
  53922. * Disposes the cylinder.
  53923. * @param force Specifies if the updraft should be disposed by force
  53924. */
  53925. dispose(force?: boolean): void;
  53926. private getImpostorHitData;
  53927. private _tick;
  53928. /*** Helpers ***/
  53929. private _prepareCylinder;
  53930. private _intersectsWithCylinder;
  53931. }
  53932. /**
  53933. * Represents a physics vortex event
  53934. */
  53935. class PhysicsVortexEvent {
  53936. private _scene;
  53937. private _origin;
  53938. private _options;
  53939. private _physicsEngine;
  53940. private _originTop;
  53941. private _tickCallback;
  53942. private _cylinder;
  53943. private _cylinderPosition;
  53944. private _dataFetched;
  53945. /**
  53946. * Initializes the physics vortex event
  53947. * @param _scene The BabylonJS scene
  53948. * @param _origin The origin position of the vortex
  53949. * @param _options The options for the vortex event
  53950. */
  53951. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  53952. /**
  53953. * Returns the data related to the vortex event (cylinder).
  53954. * @returns The physics vortex event data
  53955. */
  53956. getData(): PhysicsVortexEventData;
  53957. /**
  53958. * Enables the vortex.
  53959. */
  53960. enable(): void;
  53961. /**
  53962. * Disables the cortex.
  53963. */
  53964. disable(): void;
  53965. /**
  53966. * Disposes the sphere.
  53967. * @param force
  53968. */
  53969. dispose(force?: boolean): void;
  53970. private getImpostorHitData;
  53971. private _tick;
  53972. /*** Helpers ***/
  53973. private _prepareCylinder;
  53974. private _intersectsWithCylinder;
  53975. }
  53976. /**
  53977. * Options fot the radial explosion event
  53978. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53979. */
  53980. export class PhysicsRadialExplosionEventOptions {
  53981. /**
  53982. * The radius of the sphere for the radial explosion.
  53983. */
  53984. radius: number;
  53985. /**
  53986. * The strenth of the explosion.
  53987. */
  53988. strength: number;
  53989. /**
  53990. * The strenght of the force in correspondence to the distance of the affected object
  53991. */
  53992. falloff: PhysicsRadialImpulseFalloff;
  53993. /**
  53994. * Sphere options for the radial explosion.
  53995. */
  53996. sphere: {
  53997. segments: number;
  53998. diameter: number;
  53999. };
  54000. /**
  54001. * Sphere options for the radial explosion.
  54002. */
  54003. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  54004. }
  54005. /**
  54006. * Options fot the updraft event
  54007. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54008. */
  54009. export class PhysicsUpdraftEventOptions {
  54010. /**
  54011. * The radius of the cylinder for the vortex
  54012. */
  54013. radius: number;
  54014. /**
  54015. * The strenth of the updraft.
  54016. */
  54017. strength: number;
  54018. /**
  54019. * The height of the cylinder for the updraft.
  54020. */
  54021. height: number;
  54022. /**
  54023. * The mode for the the updraft.
  54024. */
  54025. updraftMode: PhysicsUpdraftMode;
  54026. }
  54027. /**
  54028. * Options fot the vortex event
  54029. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54030. */
  54031. export class PhysicsVortexEventOptions {
  54032. /**
  54033. * The radius of the cylinder for the vortex
  54034. */
  54035. radius: number;
  54036. /**
  54037. * The strenth of the vortex.
  54038. */
  54039. strength: number;
  54040. /**
  54041. * The height of the cylinder for the vortex.
  54042. */
  54043. height: number;
  54044. /**
  54045. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  54046. */
  54047. centripetalForceThreshold: number;
  54048. /**
  54049. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  54050. */
  54051. centripetalForceMultiplier: number;
  54052. /**
  54053. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  54054. */
  54055. centrifugalForceMultiplier: number;
  54056. /**
  54057. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  54058. */
  54059. updraftForceMultiplier: number;
  54060. }
  54061. /**
  54062. * The strenght of the force in correspondence to the distance of the affected object
  54063. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54064. */
  54065. export enum PhysicsRadialImpulseFalloff {
  54066. /** Defines that impulse is constant in strength across it's whole radius */
  54067. Constant = 0,
  54068. /** Defines that impulse gets weaker if it's further from the origin */
  54069. Linear = 1
  54070. }
  54071. /**
  54072. * The strength of the force in correspondence to the distance of the affected object
  54073. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54074. */
  54075. export enum PhysicsUpdraftMode {
  54076. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  54077. Center = 0,
  54078. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  54079. Perpendicular = 1
  54080. }
  54081. /**
  54082. * Interface for a physics hit data
  54083. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54084. */
  54085. export interface PhysicsHitData {
  54086. /**
  54087. * The force applied at the contact point
  54088. */
  54089. force: Vector3;
  54090. /**
  54091. * The contact point
  54092. */
  54093. contactPoint: Vector3;
  54094. /**
  54095. * The distance from the origin to the contact point
  54096. */
  54097. distanceFromOrigin: number;
  54098. }
  54099. /**
  54100. * Interface for radial explosion event data
  54101. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54102. */
  54103. export interface PhysicsRadialExplosionEventData {
  54104. /**
  54105. * A sphere used for the radial explosion event
  54106. */
  54107. sphere: Mesh;
  54108. }
  54109. /**
  54110. * Interface for gravitational field event data
  54111. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54112. */
  54113. export interface PhysicsGravitationalFieldEventData {
  54114. /**
  54115. * A sphere mesh used for the gravitational field event
  54116. */
  54117. sphere: Mesh;
  54118. }
  54119. /**
  54120. * Interface for updraft event data
  54121. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54122. */
  54123. export interface PhysicsUpdraftEventData {
  54124. /**
  54125. * A cylinder used for the updraft event
  54126. */
  54127. cylinder: Mesh;
  54128. }
  54129. /**
  54130. * Interface for vortex event data
  54131. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54132. */
  54133. export interface PhysicsVortexEventData {
  54134. /**
  54135. * A cylinder used for the vortex event
  54136. */
  54137. cylinder: Mesh;
  54138. }
  54139. /**
  54140. * Interface for an affected physics impostor
  54141. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54142. */
  54143. export interface PhysicsAffectedImpostorWithData {
  54144. /**
  54145. * The impostor affected by the effect
  54146. */
  54147. impostor: PhysicsImpostor;
  54148. /**
  54149. * The data about the hit/horce from the explosion
  54150. */
  54151. hitData: PhysicsHitData;
  54152. }
  54153. }
  54154. declare module "babylonjs/Physics/Plugins/index" {
  54155. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  54156. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  54157. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  54158. }
  54159. declare module "babylonjs/Physics/index" {
  54160. export * from "babylonjs/Physics/IPhysicsEngine";
  54161. export * from "babylonjs/Physics/physicsEngine";
  54162. export * from "babylonjs/Physics/physicsEngineComponent";
  54163. export * from "babylonjs/Physics/physicsHelper";
  54164. export * from "babylonjs/Physics/physicsImpostor";
  54165. export * from "babylonjs/Physics/physicsJoint";
  54166. export * from "babylonjs/Physics/Plugins/index";
  54167. }
  54168. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  54169. /** @hidden */
  54170. export var blackAndWhitePixelShader: {
  54171. name: string;
  54172. shader: string;
  54173. };
  54174. }
  54175. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  54176. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54177. import { Camera } from "babylonjs/Cameras/camera";
  54178. import { Engine } from "babylonjs/Engines/engine";
  54179. import "babylonjs/Shaders/blackAndWhite.fragment";
  54180. /**
  54181. * Post process used to render in black and white
  54182. */
  54183. export class BlackAndWhitePostProcess extends PostProcess {
  54184. /**
  54185. * Linear about to convert he result to black and white (default: 1)
  54186. */
  54187. degree: number;
  54188. /**
  54189. * Creates a black and white post process
  54190. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  54191. * @param name The name of the effect.
  54192. * @param options The required width/height ratio to downsize to before computing the render pass.
  54193. * @param camera The camera to apply the render pass to.
  54194. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54195. * @param engine The engine which the post process will be applied. (default: current engine)
  54196. * @param reusable If the post process can be reused on the same frame. (default: false)
  54197. */
  54198. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54199. }
  54200. }
  54201. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  54202. import { Nullable } from "babylonjs/types";
  54203. import { Camera } from "babylonjs/Cameras/camera";
  54204. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54205. import { Engine } from "babylonjs/Engines/engine";
  54206. /**
  54207. * This represents a set of one or more post processes in Babylon.
  54208. * A post process can be used to apply a shader to a texture after it is rendered.
  54209. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54210. */
  54211. export class PostProcessRenderEffect {
  54212. private _postProcesses;
  54213. private _getPostProcesses;
  54214. private _singleInstance;
  54215. private _cameras;
  54216. private _indicesForCamera;
  54217. /**
  54218. * Name of the effect
  54219. * @hidden
  54220. */
  54221. _name: string;
  54222. /**
  54223. * Instantiates a post process render effect.
  54224. * A post process can be used to apply a shader to a texture after it is rendered.
  54225. * @param engine The engine the effect is tied to
  54226. * @param name The name of the effect
  54227. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  54228. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  54229. */
  54230. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  54231. /**
  54232. * Checks if all the post processes in the effect are supported.
  54233. */
  54234. readonly isSupported: boolean;
  54235. /**
  54236. * Updates the current state of the effect
  54237. * @hidden
  54238. */
  54239. _update(): void;
  54240. /**
  54241. * Attaches the effect on cameras
  54242. * @param cameras The camera to attach to.
  54243. * @hidden
  54244. */
  54245. _attachCameras(cameras: Camera): void;
  54246. /**
  54247. * Attaches the effect on cameras
  54248. * @param cameras The camera to attach to.
  54249. * @hidden
  54250. */
  54251. _attachCameras(cameras: Camera[]): void;
  54252. /**
  54253. * Detatches the effect on cameras
  54254. * @param cameras The camera to detatch from.
  54255. * @hidden
  54256. */
  54257. _detachCameras(cameras: Camera): void;
  54258. /**
  54259. * Detatches the effect on cameras
  54260. * @param cameras The camera to detatch from.
  54261. * @hidden
  54262. */
  54263. _detachCameras(cameras: Camera[]): void;
  54264. /**
  54265. * Enables the effect on given cameras
  54266. * @param cameras The camera to enable.
  54267. * @hidden
  54268. */
  54269. _enable(cameras: Camera): void;
  54270. /**
  54271. * Enables the effect on given cameras
  54272. * @param cameras The camera to enable.
  54273. * @hidden
  54274. */
  54275. _enable(cameras: Nullable<Camera[]>): void;
  54276. /**
  54277. * Disables the effect on the given cameras
  54278. * @param cameras The camera to disable.
  54279. * @hidden
  54280. */
  54281. _disable(cameras: Camera): void;
  54282. /**
  54283. * Disables the effect on the given cameras
  54284. * @param cameras The camera to disable.
  54285. * @hidden
  54286. */
  54287. _disable(cameras: Nullable<Camera[]>): void;
  54288. /**
  54289. * Gets a list of the post processes contained in the effect.
  54290. * @param camera The camera to get the post processes on.
  54291. * @returns The list of the post processes in the effect.
  54292. */
  54293. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  54294. }
  54295. }
  54296. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  54297. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54298. /** @hidden */
  54299. export var extractHighlightsPixelShader: {
  54300. name: string;
  54301. shader: string;
  54302. };
  54303. }
  54304. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  54305. import { Nullable } from "babylonjs/types";
  54306. import { Camera } from "babylonjs/Cameras/camera";
  54307. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54308. import { Engine } from "babylonjs/Engines/engine";
  54309. import "babylonjs/Shaders/extractHighlights.fragment";
  54310. /**
  54311. * 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.
  54312. */
  54313. export class ExtractHighlightsPostProcess extends PostProcess {
  54314. /**
  54315. * The luminance threshold, pixels below this value will be set to black.
  54316. */
  54317. threshold: number;
  54318. /** @hidden */
  54319. _exposure: number;
  54320. /**
  54321. * Post process which has the input texture to be used when performing highlight extraction
  54322. * @hidden
  54323. */
  54324. _inputPostProcess: Nullable<PostProcess>;
  54325. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54326. }
  54327. }
  54328. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  54329. /** @hidden */
  54330. export var bloomMergePixelShader: {
  54331. name: string;
  54332. shader: string;
  54333. };
  54334. }
  54335. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  54336. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54337. import { Nullable } from "babylonjs/types";
  54338. import { Engine } from "babylonjs/Engines/engine";
  54339. import { Camera } from "babylonjs/Cameras/camera";
  54340. import "babylonjs/Shaders/bloomMerge.fragment";
  54341. /**
  54342. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  54343. */
  54344. export class BloomMergePostProcess extends PostProcess {
  54345. /** Weight of the bloom to be added to the original input. */
  54346. weight: number;
  54347. /**
  54348. * Creates a new instance of @see BloomMergePostProcess
  54349. * @param name The name of the effect.
  54350. * @param originalFromInput Post process which's input will be used for the merge.
  54351. * @param blurred Blurred highlights post process which's output will be used.
  54352. * @param weight Weight of the bloom to be added to the original input.
  54353. * @param options The required width/height ratio to downsize to before computing the render pass.
  54354. * @param camera The camera to apply the render pass to.
  54355. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54356. * @param engine The engine which the post process will be applied. (default: current engine)
  54357. * @param reusable If the post process can be reused on the same frame. (default: false)
  54358. * @param textureType Type of textures used when performing the post process. (default: 0)
  54359. * @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)
  54360. */
  54361. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  54362. /** Weight of the bloom to be added to the original input. */
  54363. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54364. }
  54365. }
  54366. declare module "babylonjs/PostProcesses/bloomEffect" {
  54367. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54368. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54369. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  54370. import { Camera } from "babylonjs/Cameras/camera";
  54371. import { Scene } from "babylonjs/scene";
  54372. /**
  54373. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  54374. */
  54375. export class BloomEffect extends PostProcessRenderEffect {
  54376. private bloomScale;
  54377. /**
  54378. * @hidden Internal
  54379. */
  54380. _effects: Array<PostProcess>;
  54381. /**
  54382. * @hidden Internal
  54383. */
  54384. _downscale: ExtractHighlightsPostProcess;
  54385. private _blurX;
  54386. private _blurY;
  54387. private _merge;
  54388. /**
  54389. * The luminance threshold to find bright areas of the image to bloom.
  54390. */
  54391. threshold: number;
  54392. /**
  54393. * The strength of the bloom.
  54394. */
  54395. weight: number;
  54396. /**
  54397. * Specifies the size of the bloom blur kernel, relative to the final output size
  54398. */
  54399. kernel: number;
  54400. /**
  54401. * Creates a new instance of @see BloomEffect
  54402. * @param scene The scene the effect belongs to.
  54403. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  54404. * @param bloomKernel The size of the kernel to be used when applying the blur.
  54405. * @param bloomWeight The the strength of bloom.
  54406. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  54407. * @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)
  54408. */
  54409. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  54410. /**
  54411. * Disposes each of the internal effects for a given camera.
  54412. * @param camera The camera to dispose the effect on.
  54413. */
  54414. disposeEffects(camera: Camera): void;
  54415. /**
  54416. * @hidden Internal
  54417. */
  54418. _updateEffects(): void;
  54419. /**
  54420. * Internal
  54421. * @returns if all the contained post processes are ready.
  54422. * @hidden
  54423. */
  54424. _isReady(): boolean;
  54425. }
  54426. }
  54427. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  54428. /** @hidden */
  54429. export var chromaticAberrationPixelShader: {
  54430. name: string;
  54431. shader: string;
  54432. };
  54433. }
  54434. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  54435. import { Vector2 } from "babylonjs/Maths/math";
  54436. import { Nullable } from "babylonjs/types";
  54437. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54438. import { Camera } from "babylonjs/Cameras/camera";
  54439. import { Engine } from "babylonjs/Engines/engine";
  54440. import "babylonjs/Shaders/chromaticAberration.fragment";
  54441. /**
  54442. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  54443. */
  54444. export class ChromaticAberrationPostProcess extends PostProcess {
  54445. /**
  54446. * The amount of seperation of rgb channels (default: 30)
  54447. */
  54448. aberrationAmount: number;
  54449. /**
  54450. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  54451. */
  54452. radialIntensity: number;
  54453. /**
  54454. * 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))
  54455. */
  54456. direction: Vector2;
  54457. /**
  54458. * 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))
  54459. */
  54460. centerPosition: Vector2;
  54461. /**
  54462. * Creates a new instance ChromaticAberrationPostProcess
  54463. * @param name The name of the effect.
  54464. * @param screenWidth The width of the screen to apply the effect on.
  54465. * @param screenHeight The height of the screen to apply the effect on.
  54466. * @param options The required width/height ratio to downsize to before computing the render pass.
  54467. * @param camera The camera to apply the render pass to.
  54468. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54469. * @param engine The engine which the post process will be applied. (default: current engine)
  54470. * @param reusable If the post process can be reused on the same frame. (default: false)
  54471. * @param textureType Type of textures used when performing the post process. (default: 0)
  54472. * @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)
  54473. */
  54474. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54475. }
  54476. }
  54477. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  54478. /** @hidden */
  54479. export var circleOfConfusionPixelShader: {
  54480. name: string;
  54481. shader: string;
  54482. };
  54483. }
  54484. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  54485. import { Nullable } from "babylonjs/types";
  54486. import { Engine } from "babylonjs/Engines/engine";
  54487. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54488. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54489. import { Camera } from "babylonjs/Cameras/camera";
  54490. import "babylonjs/Shaders/circleOfConfusion.fragment";
  54491. /**
  54492. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  54493. */
  54494. export class CircleOfConfusionPostProcess extends PostProcess {
  54495. /**
  54496. * 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.
  54497. */
  54498. lensSize: number;
  54499. /**
  54500. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  54501. */
  54502. fStop: number;
  54503. /**
  54504. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  54505. */
  54506. focusDistance: number;
  54507. /**
  54508. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  54509. */
  54510. focalLength: number;
  54511. private _depthTexture;
  54512. /**
  54513. * Creates a new instance CircleOfConfusionPostProcess
  54514. * @param name The name of the effect.
  54515. * @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.
  54516. * @param options The required width/height ratio to downsize to before computing the render pass.
  54517. * @param camera The camera to apply the render pass to.
  54518. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54519. * @param engine The engine which the post process will be applied. (default: current engine)
  54520. * @param reusable If the post process can be reused on the same frame. (default: false)
  54521. * @param textureType Type of textures used when performing the post process. (default: 0)
  54522. * @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)
  54523. */
  54524. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54525. /**
  54526. * 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.
  54527. */
  54528. depthTexture: RenderTargetTexture;
  54529. }
  54530. }
  54531. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  54532. /** @hidden */
  54533. export var colorCorrectionPixelShader: {
  54534. name: string;
  54535. shader: string;
  54536. };
  54537. }
  54538. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  54539. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54540. import { Engine } from "babylonjs/Engines/engine";
  54541. import { Camera } from "babylonjs/Cameras/camera";
  54542. import "babylonjs/Shaders/colorCorrection.fragment";
  54543. /**
  54544. *
  54545. * This post-process allows the modification of rendered colors by using
  54546. * a 'look-up table' (LUT). This effect is also called Color Grading.
  54547. *
  54548. * The object needs to be provided an url to a texture containing the color
  54549. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  54550. * Use an image editing software to tweak the LUT to match your needs.
  54551. *
  54552. * For an example of a color LUT, see here:
  54553. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  54554. * For explanations on color grading, see here:
  54555. * @see http://udn.epicgames.com/Three/ColorGrading.html
  54556. *
  54557. */
  54558. export class ColorCorrectionPostProcess extends PostProcess {
  54559. private _colorTableTexture;
  54560. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54561. }
  54562. }
  54563. declare module "babylonjs/Shaders/convolution.fragment" {
  54564. /** @hidden */
  54565. export var convolutionPixelShader: {
  54566. name: string;
  54567. shader: string;
  54568. };
  54569. }
  54570. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  54571. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54572. import { Nullable } from "babylonjs/types";
  54573. import { Camera } from "babylonjs/Cameras/camera";
  54574. import { Engine } from "babylonjs/Engines/engine";
  54575. import "babylonjs/Shaders/convolution.fragment";
  54576. /**
  54577. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  54578. * input texture to perform effects such as edge detection or sharpening
  54579. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  54580. */
  54581. export class ConvolutionPostProcess extends PostProcess {
  54582. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  54583. kernel: number[];
  54584. /**
  54585. * Creates a new instance ConvolutionPostProcess
  54586. * @param name The name of the effect.
  54587. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  54588. * @param options The required width/height ratio to downsize to before computing the render pass.
  54589. * @param camera The camera to apply the render pass to.
  54590. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54591. * @param engine The engine which the post process will be applied. (default: current engine)
  54592. * @param reusable If the post process can be reused on the same frame. (default: false)
  54593. * @param textureType Type of textures used when performing the post process. (default: 0)
  54594. */
  54595. constructor(name: string,
  54596. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  54597. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54598. /**
  54599. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54600. */
  54601. static EdgeDetect0Kernel: number[];
  54602. /**
  54603. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54604. */
  54605. static EdgeDetect1Kernel: number[];
  54606. /**
  54607. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54608. */
  54609. static EdgeDetect2Kernel: number[];
  54610. /**
  54611. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54612. */
  54613. static SharpenKernel: number[];
  54614. /**
  54615. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54616. */
  54617. static EmbossKernel: number[];
  54618. /**
  54619. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54620. */
  54621. static GaussianKernel: number[];
  54622. }
  54623. }
  54624. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  54625. import { Nullable } from "babylonjs/types";
  54626. import { Vector2 } from "babylonjs/Maths/math";
  54627. import { Camera } from "babylonjs/Cameras/camera";
  54628. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54629. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  54630. import { Engine } from "babylonjs/Engines/engine";
  54631. import { Scene } from "babylonjs/scene";
  54632. /**
  54633. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  54634. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  54635. * based on samples that have a large difference in distance than the center pixel.
  54636. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  54637. */
  54638. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  54639. direction: Vector2;
  54640. /**
  54641. * Creates a new instance CircleOfConfusionPostProcess
  54642. * @param name The name of the effect.
  54643. * @param scene The scene the effect belongs to.
  54644. * @param direction The direction the blur should be applied.
  54645. * @param kernel The size of the kernel used to blur.
  54646. * @param options The required width/height ratio to downsize to before computing the render pass.
  54647. * @param camera The camera to apply the render pass to.
  54648. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  54649. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  54650. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54651. * @param engine The engine which the post process will be applied. (default: current engine)
  54652. * @param reusable If the post process can be reused on the same frame. (default: false)
  54653. * @param textureType Type of textures used when performing the post process. (default: 0)
  54654. * @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)
  54655. */
  54656. 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);
  54657. }
  54658. }
  54659. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  54660. /** @hidden */
  54661. export var depthOfFieldMergePixelShader: {
  54662. name: string;
  54663. shader: string;
  54664. };
  54665. }
  54666. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  54667. import { Nullable } from "babylonjs/types";
  54668. import { Camera } from "babylonjs/Cameras/camera";
  54669. import { Effect } from "babylonjs/Materials/effect";
  54670. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54671. import { Engine } from "babylonjs/Engines/engine";
  54672. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  54673. /**
  54674. * Options to be set when merging outputs from the default pipeline.
  54675. */
  54676. export class DepthOfFieldMergePostProcessOptions {
  54677. /**
  54678. * The original image to merge on top of
  54679. */
  54680. originalFromInput: PostProcess;
  54681. /**
  54682. * Parameters to perform the merge of the depth of field effect
  54683. */
  54684. depthOfField?: {
  54685. circleOfConfusion: PostProcess;
  54686. blurSteps: Array<PostProcess>;
  54687. };
  54688. /**
  54689. * Parameters to perform the merge of bloom effect
  54690. */
  54691. bloom?: {
  54692. blurred: PostProcess;
  54693. weight: number;
  54694. };
  54695. }
  54696. /**
  54697. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  54698. */
  54699. export class DepthOfFieldMergePostProcess extends PostProcess {
  54700. private blurSteps;
  54701. /**
  54702. * Creates a new instance of DepthOfFieldMergePostProcess
  54703. * @param name The name of the effect.
  54704. * @param originalFromInput Post process which's input will be used for the merge.
  54705. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  54706. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  54707. * @param options The required width/height ratio to downsize to before computing the render pass.
  54708. * @param camera The camera to apply the render pass to.
  54709. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54710. * @param engine The engine which the post process will be applied. (default: current engine)
  54711. * @param reusable If the post process can be reused on the same frame. (default: false)
  54712. * @param textureType Type of textures used when performing the post process. (default: 0)
  54713. * @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)
  54714. */
  54715. 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);
  54716. /**
  54717. * Updates the effect with the current post process compile time values and recompiles the shader.
  54718. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  54719. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  54720. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  54721. * @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
  54722. * @param onCompiled Called when the shader has been compiled.
  54723. * @param onError Called if there is an error when compiling a shader.
  54724. */
  54725. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  54726. }
  54727. }
  54728. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  54729. import { Nullable } from "babylonjs/types";
  54730. import { Camera } from "babylonjs/Cameras/camera";
  54731. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54732. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54733. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54734. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  54735. import { Scene } from "babylonjs/scene";
  54736. /**
  54737. * Specifies the level of max blur that should be applied when using the depth of field effect
  54738. */
  54739. export enum DepthOfFieldEffectBlurLevel {
  54740. /**
  54741. * Subtle blur
  54742. */
  54743. Low = 0,
  54744. /**
  54745. * Medium blur
  54746. */
  54747. Medium = 1,
  54748. /**
  54749. * Large blur
  54750. */
  54751. High = 2
  54752. }
  54753. /**
  54754. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  54755. */
  54756. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  54757. private _circleOfConfusion;
  54758. /**
  54759. * @hidden Internal, blurs from high to low
  54760. */
  54761. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  54762. private _depthOfFieldBlurY;
  54763. private _dofMerge;
  54764. /**
  54765. * @hidden Internal post processes in depth of field effect
  54766. */
  54767. _effects: Array<PostProcess>;
  54768. /**
  54769. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  54770. */
  54771. focalLength: number;
  54772. /**
  54773. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  54774. */
  54775. fStop: number;
  54776. /**
  54777. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  54778. */
  54779. focusDistance: number;
  54780. /**
  54781. * 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.
  54782. */
  54783. lensSize: number;
  54784. /**
  54785. * Creates a new instance DepthOfFieldEffect
  54786. * @param scene The scene the effect belongs to.
  54787. * @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.
  54788. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  54789. * @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)
  54790. */
  54791. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  54792. /**
  54793. * 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.
  54794. */
  54795. depthTexture: RenderTargetTexture;
  54796. /**
  54797. * Disposes each of the internal effects for a given camera.
  54798. * @param camera The camera to dispose the effect on.
  54799. */
  54800. disposeEffects(camera: Camera): void;
  54801. /**
  54802. * @hidden Internal
  54803. */
  54804. _updateEffects(): void;
  54805. /**
  54806. * Internal
  54807. * @returns if all the contained post processes are ready.
  54808. * @hidden
  54809. */
  54810. _isReady(): boolean;
  54811. }
  54812. }
  54813. declare module "babylonjs/Shaders/displayPass.fragment" {
  54814. /** @hidden */
  54815. export var displayPassPixelShader: {
  54816. name: string;
  54817. shader: string;
  54818. };
  54819. }
  54820. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  54821. import { Nullable } from "babylonjs/types";
  54822. import { Camera } from "babylonjs/Cameras/camera";
  54823. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54824. import { Engine } from "babylonjs/Engines/engine";
  54825. import "babylonjs/Shaders/displayPass.fragment";
  54826. /**
  54827. * DisplayPassPostProcess which produces an output the same as it's input
  54828. */
  54829. export class DisplayPassPostProcess extends PostProcess {
  54830. /**
  54831. * Creates the DisplayPassPostProcess
  54832. * @param name The name of the effect.
  54833. * @param options The required width/height ratio to downsize to before computing the render pass.
  54834. * @param camera The camera to apply the render pass to.
  54835. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54836. * @param engine The engine which the post process will be applied. (default: current engine)
  54837. * @param reusable If the post process can be reused on the same frame. (default: false)
  54838. */
  54839. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54840. }
  54841. }
  54842. declare module "babylonjs/Shaders/filter.fragment" {
  54843. /** @hidden */
  54844. export var filterPixelShader: {
  54845. name: string;
  54846. shader: string;
  54847. };
  54848. }
  54849. declare module "babylonjs/PostProcesses/filterPostProcess" {
  54850. import { Nullable } from "babylonjs/types";
  54851. import { Matrix } from "babylonjs/Maths/math";
  54852. import { Camera } from "babylonjs/Cameras/camera";
  54853. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54854. import { Engine } from "babylonjs/Engines/engine";
  54855. import "babylonjs/Shaders/filter.fragment";
  54856. /**
  54857. * Applies a kernel filter to the image
  54858. */
  54859. export class FilterPostProcess extends PostProcess {
  54860. /** The matrix to be applied to the image */
  54861. kernelMatrix: Matrix;
  54862. /**
  54863. *
  54864. * @param name The name of the effect.
  54865. * @param kernelMatrix The matrix to be applied to the image
  54866. * @param options The required width/height ratio to downsize to before computing the render pass.
  54867. * @param camera The camera to apply the render pass to.
  54868. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54869. * @param engine The engine which the post process will be applied. (default: current engine)
  54870. * @param reusable If the post process can be reused on the same frame. (default: false)
  54871. */
  54872. constructor(name: string,
  54873. /** The matrix to be applied to the image */
  54874. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54875. }
  54876. }
  54877. declare module "babylonjs/Shaders/fxaa.fragment" {
  54878. /** @hidden */
  54879. export var fxaaPixelShader: {
  54880. name: string;
  54881. shader: string;
  54882. };
  54883. }
  54884. declare module "babylonjs/Shaders/fxaa.vertex" {
  54885. /** @hidden */
  54886. export var fxaaVertexShader: {
  54887. name: string;
  54888. shader: string;
  54889. };
  54890. }
  54891. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  54892. import { Nullable } from "babylonjs/types";
  54893. import { Camera } from "babylonjs/Cameras/camera";
  54894. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54895. import { Engine } from "babylonjs/Engines/engine";
  54896. import "babylonjs/Shaders/fxaa.fragment";
  54897. import "babylonjs/Shaders/fxaa.vertex";
  54898. /**
  54899. * Fxaa post process
  54900. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  54901. */
  54902. export class FxaaPostProcess extends PostProcess {
  54903. /** @hidden */
  54904. texelWidth: number;
  54905. /** @hidden */
  54906. texelHeight: number;
  54907. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54908. private _getDefines;
  54909. }
  54910. }
  54911. declare module "babylonjs/Shaders/grain.fragment" {
  54912. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54913. /** @hidden */
  54914. export var grainPixelShader: {
  54915. name: string;
  54916. shader: string;
  54917. };
  54918. }
  54919. declare module "babylonjs/PostProcesses/grainPostProcess" {
  54920. import { Nullable } from "babylonjs/types";
  54921. import { Camera } from "babylonjs/Cameras/camera";
  54922. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54923. import { Engine } from "babylonjs/Engines/engine";
  54924. import "babylonjs/Shaders/grain.fragment";
  54925. /**
  54926. * The GrainPostProcess adds noise to the image at mid luminance levels
  54927. */
  54928. export class GrainPostProcess extends PostProcess {
  54929. /**
  54930. * The intensity of the grain added (default: 30)
  54931. */
  54932. intensity: number;
  54933. /**
  54934. * If the grain should be randomized on every frame
  54935. */
  54936. animated: boolean;
  54937. /**
  54938. * Creates a new instance of @see GrainPostProcess
  54939. * @param name The name of the effect.
  54940. * @param options The required width/height ratio to downsize to before computing the render pass.
  54941. * @param camera The camera to apply the render pass to.
  54942. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54943. * @param engine The engine which the post process will be applied. (default: current engine)
  54944. * @param reusable If the post process can be reused on the same frame. (default: false)
  54945. * @param textureType Type of textures used when performing the post process. (default: 0)
  54946. * @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)
  54947. */
  54948. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54949. }
  54950. }
  54951. declare module "babylonjs/Shaders/highlights.fragment" {
  54952. /** @hidden */
  54953. export var highlightsPixelShader: {
  54954. name: string;
  54955. shader: string;
  54956. };
  54957. }
  54958. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  54959. import { Nullable } from "babylonjs/types";
  54960. import { Camera } from "babylonjs/Cameras/camera";
  54961. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54962. import { Engine } from "babylonjs/Engines/engine";
  54963. import "babylonjs/Shaders/highlights.fragment";
  54964. /**
  54965. * Extracts highlights from the image
  54966. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  54967. */
  54968. export class HighlightsPostProcess extends PostProcess {
  54969. /**
  54970. * Extracts highlights from the image
  54971. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  54972. * @param name The name of the effect.
  54973. * @param options The required width/height ratio to downsize to before computing the render pass.
  54974. * @param camera The camera to apply the render pass to.
  54975. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54976. * @param engine The engine which the post process will be applied. (default: current engine)
  54977. * @param reusable If the post process can be reused on the same frame. (default: false)
  54978. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  54979. */
  54980. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54981. }
  54982. }
  54983. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  54984. /** @hidden */
  54985. export var mrtFragmentDeclaration: {
  54986. name: string;
  54987. shader: string;
  54988. };
  54989. }
  54990. declare module "babylonjs/Shaders/geometry.fragment" {
  54991. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  54992. /** @hidden */
  54993. export var geometryPixelShader: {
  54994. name: string;
  54995. shader: string;
  54996. };
  54997. }
  54998. declare module "babylonjs/Shaders/geometry.vertex" {
  54999. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55000. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55001. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55002. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55003. /** @hidden */
  55004. export var geometryVertexShader: {
  55005. name: string;
  55006. shader: string;
  55007. };
  55008. }
  55009. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  55010. import { Matrix } from "babylonjs/Maths/math";
  55011. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55012. import { Mesh } from "babylonjs/Meshes/mesh";
  55013. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  55014. import { Effect } from "babylonjs/Materials/effect";
  55015. import { Scene } from "babylonjs/scene";
  55016. import "babylonjs/Shaders/geometry.fragment";
  55017. import "babylonjs/Shaders/geometry.vertex";
  55018. /**
  55019. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  55020. */
  55021. export class GeometryBufferRenderer {
  55022. /**
  55023. * Constant used to retrieve the position texture index in the G-Buffer textures array
  55024. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  55025. */
  55026. static readonly POSITION_TEXTURE_TYPE: number;
  55027. /**
  55028. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  55029. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  55030. */
  55031. static readonly VELOCITY_TEXTURE_TYPE: number;
  55032. /**
  55033. * Dictionary used to store the previous transformation matrices of each rendered mesh
  55034. * in order to compute objects velocities when enableVelocity is set to "true"
  55035. * @hidden
  55036. */
  55037. _previousTransformationMatrices: {
  55038. [index: number]: Matrix;
  55039. };
  55040. private _scene;
  55041. private _multiRenderTarget;
  55042. private _ratio;
  55043. private _enablePosition;
  55044. private _enableVelocity;
  55045. private _positionIndex;
  55046. private _velocityIndex;
  55047. protected _effect: Effect;
  55048. protected _cachedDefines: string;
  55049. /**
  55050. * Set the render list (meshes to be rendered) used in the G buffer.
  55051. */
  55052. renderList: Mesh[];
  55053. /**
  55054. * Gets wether or not G buffer are supported by the running hardware.
  55055. * This requires draw buffer supports
  55056. */
  55057. readonly isSupported: boolean;
  55058. /**
  55059. * Returns the index of the given texture type in the G-Buffer textures array
  55060. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  55061. * @returns the index of the given texture type in the G-Buffer textures array
  55062. */
  55063. getTextureIndex(textureType: number): number;
  55064. /**
  55065. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  55066. */
  55067. /**
  55068. * Sets whether or not objects positions are enabled for the G buffer.
  55069. */
  55070. enablePosition: boolean;
  55071. /**
  55072. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  55073. */
  55074. /**
  55075. * Sets wether or not objects velocities are enabled for the G buffer.
  55076. */
  55077. enableVelocity: boolean;
  55078. /**
  55079. * Gets the scene associated with the buffer.
  55080. */
  55081. readonly scene: Scene;
  55082. /**
  55083. * Gets the ratio used by the buffer during its creation.
  55084. * How big is the buffer related to the main canvas.
  55085. */
  55086. readonly ratio: number;
  55087. /** @hidden */
  55088. static _SceneComponentInitialization: (scene: Scene) => void;
  55089. /**
  55090. * Creates a new G Buffer for the scene
  55091. * @param scene The scene the buffer belongs to
  55092. * @param ratio How big is the buffer related to the main canvas.
  55093. */
  55094. constructor(scene: Scene, ratio?: number);
  55095. /**
  55096. * Checks wether everything is ready to render a submesh to the G buffer.
  55097. * @param subMesh the submesh to check readiness for
  55098. * @param useInstances is the mesh drawn using instance or not
  55099. * @returns true if ready otherwise false
  55100. */
  55101. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55102. /**
  55103. * Gets the current underlying G Buffer.
  55104. * @returns the buffer
  55105. */
  55106. getGBuffer(): MultiRenderTarget;
  55107. /**
  55108. * Gets the number of samples used to render the buffer (anti aliasing).
  55109. */
  55110. /**
  55111. * Sets the number of samples used to render the buffer (anti aliasing).
  55112. */
  55113. samples: number;
  55114. /**
  55115. * Disposes the renderer and frees up associated resources.
  55116. */
  55117. dispose(): void;
  55118. protected _createRenderTargets(): void;
  55119. }
  55120. }
  55121. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  55122. import { Nullable } from "babylonjs/types";
  55123. import { Scene } from "babylonjs/scene";
  55124. import { ISceneComponent } from "babylonjs/sceneComponent";
  55125. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  55126. module "babylonjs/scene" {
  55127. interface Scene {
  55128. /** @hidden (Backing field) */
  55129. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55130. /**
  55131. * Gets or Sets the current geometry buffer associated to the scene.
  55132. */
  55133. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55134. /**
  55135. * Enables a GeometryBufferRender and associates it with the scene
  55136. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  55137. * @returns the GeometryBufferRenderer
  55138. */
  55139. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  55140. /**
  55141. * Disables the GeometryBufferRender associated with the scene
  55142. */
  55143. disableGeometryBufferRenderer(): void;
  55144. }
  55145. }
  55146. /**
  55147. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  55148. * in several rendering techniques.
  55149. */
  55150. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  55151. /**
  55152. * The component name helpful to identify the component in the list of scene components.
  55153. */
  55154. readonly name: string;
  55155. /**
  55156. * The scene the component belongs to.
  55157. */
  55158. scene: Scene;
  55159. /**
  55160. * Creates a new instance of the component for the given scene
  55161. * @param scene Defines the scene to register the component in
  55162. */
  55163. constructor(scene: Scene);
  55164. /**
  55165. * Registers the component in a given scene
  55166. */
  55167. register(): void;
  55168. /**
  55169. * Rebuilds the elements related to this component in case of
  55170. * context lost for instance.
  55171. */
  55172. rebuild(): void;
  55173. /**
  55174. * Disposes the component and the associated ressources
  55175. */
  55176. dispose(): void;
  55177. private _gatherRenderTargets;
  55178. }
  55179. }
  55180. declare module "babylonjs/Shaders/motionBlur.fragment" {
  55181. /** @hidden */
  55182. export var motionBlurPixelShader: {
  55183. name: string;
  55184. shader: string;
  55185. };
  55186. }
  55187. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  55188. import { Nullable } from "babylonjs/types";
  55189. import { Camera } from "babylonjs/Cameras/camera";
  55190. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55191. import { Scene } from "babylonjs/scene";
  55192. import "babylonjs/Animations/animatable";
  55193. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  55194. import "babylonjs/Shaders/motionBlur.fragment";
  55195. import { Engine } from "babylonjs/Engines/engine";
  55196. /**
  55197. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  55198. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  55199. * As an example, all you have to do is to create the post-process:
  55200. * var mb = new BABYLON.MotionBlurPostProcess(
  55201. * 'mb', // The name of the effect.
  55202. * scene, // The scene containing the objects to blur according to their velocity.
  55203. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  55204. * camera // The camera to apply the render pass to.
  55205. * );
  55206. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  55207. */
  55208. export class MotionBlurPostProcess extends PostProcess {
  55209. /**
  55210. * Defines how much the image is blurred by the movement. Default value is equal to 1
  55211. */
  55212. motionStrength: number;
  55213. /**
  55214. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  55215. */
  55216. /**
  55217. * Sets the number of iterations to be used for motion blur quality
  55218. */
  55219. motionBlurSamples: number;
  55220. private _motionBlurSamples;
  55221. private _geometryBufferRenderer;
  55222. /**
  55223. * Creates a new instance MotionBlurPostProcess
  55224. * @param name The name of the effect.
  55225. * @param scene The scene containing the objects to blur according to their velocity.
  55226. * @param options The required width/height ratio to downsize to before computing the render pass.
  55227. * @param camera The camera to apply the render pass to.
  55228. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55229. * @param engine The engine which the post process will be applied. (default: current engine)
  55230. * @param reusable If the post process can be reused on the same frame. (default: false)
  55231. * @param textureType Type of textures used when performing the post process. (default: 0)
  55232. * @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)
  55233. */
  55234. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55235. /**
  55236. * Disposes the post process.
  55237. * @param camera The camera to dispose the post process on.
  55238. */
  55239. dispose(camera?: Camera): void;
  55240. }
  55241. }
  55242. declare module "babylonjs/Shaders/refraction.fragment" {
  55243. /** @hidden */
  55244. export var refractionPixelShader: {
  55245. name: string;
  55246. shader: string;
  55247. };
  55248. }
  55249. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  55250. import { Color3 } from "babylonjs/Maths/math";
  55251. import { Camera } from "babylonjs/Cameras/camera";
  55252. import { Texture } from "babylonjs/Materials/Textures/texture";
  55253. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55254. import { Engine } from "babylonjs/Engines/engine";
  55255. import "babylonjs/Shaders/refraction.fragment";
  55256. /**
  55257. * Post process which applies a refractin texture
  55258. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55259. */
  55260. export class RefractionPostProcess extends PostProcess {
  55261. /** the base color of the refraction (used to taint the rendering) */
  55262. color: Color3;
  55263. /** simulated refraction depth */
  55264. depth: number;
  55265. /** the coefficient of the base color (0 to remove base color tainting) */
  55266. colorLevel: number;
  55267. private _refTexture;
  55268. private _ownRefractionTexture;
  55269. /**
  55270. * Gets or sets the refraction texture
  55271. * Please note that you are responsible for disposing the texture if you set it manually
  55272. */
  55273. refractionTexture: Texture;
  55274. /**
  55275. * Initializes the RefractionPostProcess
  55276. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55277. * @param name The name of the effect.
  55278. * @param refractionTextureUrl Url of the refraction texture to use
  55279. * @param color the base color of the refraction (used to taint the rendering)
  55280. * @param depth simulated refraction depth
  55281. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  55282. * @param camera The camera to apply the render pass to.
  55283. * @param options The required width/height ratio to downsize to before computing the render pass.
  55284. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55285. * @param engine The engine which the post process will be applied. (default: current engine)
  55286. * @param reusable If the post process can be reused on the same frame. (default: false)
  55287. */
  55288. constructor(name: string, refractionTextureUrl: string,
  55289. /** the base color of the refraction (used to taint the rendering) */
  55290. color: Color3,
  55291. /** simulated refraction depth */
  55292. depth: number,
  55293. /** the coefficient of the base color (0 to remove base color tainting) */
  55294. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55295. /**
  55296. * Disposes of the post process
  55297. * @param camera Camera to dispose post process on
  55298. */
  55299. dispose(camera: Camera): void;
  55300. }
  55301. }
  55302. declare module "babylonjs/Shaders/sharpen.fragment" {
  55303. /** @hidden */
  55304. export var sharpenPixelShader: {
  55305. name: string;
  55306. shader: string;
  55307. };
  55308. }
  55309. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  55310. import { Nullable } from "babylonjs/types";
  55311. import { Camera } from "babylonjs/Cameras/camera";
  55312. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55313. import "babylonjs/Shaders/sharpen.fragment";
  55314. import { Engine } from "babylonjs/Engines/engine";
  55315. /**
  55316. * The SharpenPostProcess applies a sharpen kernel to every pixel
  55317. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  55318. */
  55319. export class SharpenPostProcess extends PostProcess {
  55320. /**
  55321. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  55322. */
  55323. colorAmount: number;
  55324. /**
  55325. * How much sharpness should be applied (default: 0.3)
  55326. */
  55327. edgeAmount: number;
  55328. /**
  55329. * Creates a new instance ConvolutionPostProcess
  55330. * @param name The name of the effect.
  55331. * @param options The required width/height ratio to downsize to before computing the render pass.
  55332. * @param camera The camera to apply the render pass to.
  55333. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55334. * @param engine The engine which the post process will be applied. (default: current engine)
  55335. * @param reusable If the post process can be reused on the same frame. (default: false)
  55336. * @param textureType Type of textures used when performing the post process. (default: 0)
  55337. * @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)
  55338. */
  55339. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55340. }
  55341. }
  55342. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  55343. import { Nullable } from "babylonjs/types";
  55344. import { Camera } from "babylonjs/Cameras/camera";
  55345. import { Engine } from "babylonjs/Engines/engine";
  55346. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  55347. import { IInspectable } from "babylonjs/Misc/iInspectable";
  55348. /**
  55349. * PostProcessRenderPipeline
  55350. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55351. */
  55352. export class PostProcessRenderPipeline {
  55353. private engine;
  55354. private _renderEffects;
  55355. private _renderEffectsForIsolatedPass;
  55356. /**
  55357. * List of inspectable custom properties (used by the Inspector)
  55358. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  55359. */
  55360. inspectableCustomProperties: IInspectable[];
  55361. /**
  55362. * @hidden
  55363. */
  55364. protected _cameras: Camera[];
  55365. /** @hidden */
  55366. _name: string;
  55367. /**
  55368. * Gets pipeline name
  55369. */
  55370. readonly name: string;
  55371. /**
  55372. * Initializes a PostProcessRenderPipeline
  55373. * @param engine engine to add the pipeline to
  55374. * @param name name of the pipeline
  55375. */
  55376. constructor(engine: Engine, name: string);
  55377. /**
  55378. * Gets the class name
  55379. * @returns "PostProcessRenderPipeline"
  55380. */
  55381. getClassName(): string;
  55382. /**
  55383. * If all the render effects in the pipeline are supported
  55384. */
  55385. readonly isSupported: boolean;
  55386. /**
  55387. * Adds an effect to the pipeline
  55388. * @param renderEffect the effect to add
  55389. */
  55390. addEffect(renderEffect: PostProcessRenderEffect): void;
  55391. /** @hidden */
  55392. _rebuild(): void;
  55393. /** @hidden */
  55394. _enableEffect(renderEffectName: string, cameras: Camera): void;
  55395. /** @hidden */
  55396. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  55397. /** @hidden */
  55398. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55399. /** @hidden */
  55400. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55401. /** @hidden */
  55402. _attachCameras(cameras: Camera, unique: boolean): void;
  55403. /** @hidden */
  55404. _attachCameras(cameras: Camera[], unique: boolean): void;
  55405. /** @hidden */
  55406. _detachCameras(cameras: Camera): void;
  55407. /** @hidden */
  55408. _detachCameras(cameras: Nullable<Camera[]>): void;
  55409. /** @hidden */
  55410. _update(): void;
  55411. /** @hidden */
  55412. _reset(): void;
  55413. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  55414. /**
  55415. * Disposes of the pipeline
  55416. */
  55417. dispose(): void;
  55418. }
  55419. }
  55420. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  55421. import { Camera } from "babylonjs/Cameras/camera";
  55422. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55423. /**
  55424. * PostProcessRenderPipelineManager class
  55425. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55426. */
  55427. export class PostProcessRenderPipelineManager {
  55428. private _renderPipelines;
  55429. /**
  55430. * Initializes a PostProcessRenderPipelineManager
  55431. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55432. */
  55433. constructor();
  55434. /**
  55435. * Gets the list of supported render pipelines
  55436. */
  55437. readonly supportedPipelines: PostProcessRenderPipeline[];
  55438. /**
  55439. * Adds a pipeline to the manager
  55440. * @param renderPipeline The pipeline to add
  55441. */
  55442. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  55443. /**
  55444. * Attaches a camera to the pipeline
  55445. * @param renderPipelineName The name of the pipeline to attach to
  55446. * @param cameras the camera to attach
  55447. * @param unique if the camera can be attached multiple times to the pipeline
  55448. */
  55449. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  55450. /**
  55451. * Detaches a camera from the pipeline
  55452. * @param renderPipelineName The name of the pipeline to detach from
  55453. * @param cameras the camera to detach
  55454. */
  55455. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  55456. /**
  55457. * Enables an effect by name on a pipeline
  55458. * @param renderPipelineName the name of the pipeline to enable the effect in
  55459. * @param renderEffectName the name of the effect to enable
  55460. * @param cameras the cameras that the effect should be enabled on
  55461. */
  55462. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55463. /**
  55464. * Disables an effect by name on a pipeline
  55465. * @param renderPipelineName the name of the pipeline to disable the effect in
  55466. * @param renderEffectName the name of the effect to disable
  55467. * @param cameras the cameras that the effect should be disabled on
  55468. */
  55469. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55470. /**
  55471. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  55472. */
  55473. update(): void;
  55474. /** @hidden */
  55475. _rebuild(): void;
  55476. /**
  55477. * Disposes of the manager and pipelines
  55478. */
  55479. dispose(): void;
  55480. }
  55481. }
  55482. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  55483. import { ISceneComponent } from "babylonjs/sceneComponent";
  55484. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  55485. import { Scene } from "babylonjs/scene";
  55486. module "babylonjs/scene" {
  55487. interface Scene {
  55488. /** @hidden (Backing field) */
  55489. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  55490. /**
  55491. * Gets the postprocess render pipeline manager
  55492. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55493. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  55494. */
  55495. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  55496. }
  55497. }
  55498. /**
  55499. * Defines the Render Pipeline scene component responsible to rendering pipelines
  55500. */
  55501. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  55502. /**
  55503. * The component name helpfull to identify the component in the list of scene components.
  55504. */
  55505. readonly name: string;
  55506. /**
  55507. * The scene the component belongs to.
  55508. */
  55509. scene: Scene;
  55510. /**
  55511. * Creates a new instance of the component for the given scene
  55512. * @param scene Defines the scene to register the component in
  55513. */
  55514. constructor(scene: Scene);
  55515. /**
  55516. * Registers the component in a given scene
  55517. */
  55518. register(): void;
  55519. /**
  55520. * Rebuilds the elements related to this component in case of
  55521. * context lost for instance.
  55522. */
  55523. rebuild(): void;
  55524. /**
  55525. * Disposes the component and the associated ressources
  55526. */
  55527. dispose(): void;
  55528. private _gatherRenderTargets;
  55529. }
  55530. }
  55531. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  55532. import { IAnimatable } from "babylonjs/Misc/tools";
  55533. import { Camera } from "babylonjs/Cameras/camera";
  55534. import { IDisposable } from "babylonjs/scene";
  55535. import { Scene } from "babylonjs/scene";
  55536. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  55537. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  55538. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  55539. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  55540. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  55541. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55542. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  55543. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  55544. import { Animation } from "babylonjs/Animations/animation";
  55545. /**
  55546. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  55547. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  55548. */
  55549. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  55550. private _scene;
  55551. private _camerasToBeAttached;
  55552. /**
  55553. * ID of the sharpen post process,
  55554. */
  55555. private readonly SharpenPostProcessId;
  55556. /**
  55557. * @ignore
  55558. * ID of the image processing post process;
  55559. */
  55560. readonly ImageProcessingPostProcessId: string;
  55561. /**
  55562. * @ignore
  55563. * ID of the Fast Approximate Anti-Aliasing post process;
  55564. */
  55565. readonly FxaaPostProcessId: string;
  55566. /**
  55567. * ID of the chromatic aberration post process,
  55568. */
  55569. private readonly ChromaticAberrationPostProcessId;
  55570. /**
  55571. * ID of the grain post process
  55572. */
  55573. private readonly GrainPostProcessId;
  55574. /**
  55575. * Sharpen post process which will apply a sharpen convolution to enhance edges
  55576. */
  55577. sharpen: SharpenPostProcess;
  55578. private _sharpenEffect;
  55579. private bloom;
  55580. /**
  55581. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  55582. */
  55583. depthOfField: DepthOfFieldEffect;
  55584. /**
  55585. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  55586. */
  55587. fxaa: FxaaPostProcess;
  55588. /**
  55589. * Image post processing pass used to perform operations such as tone mapping or color grading.
  55590. */
  55591. imageProcessing: ImageProcessingPostProcess;
  55592. /**
  55593. * Chromatic aberration post process which will shift rgb colors in the image
  55594. */
  55595. chromaticAberration: ChromaticAberrationPostProcess;
  55596. private _chromaticAberrationEffect;
  55597. /**
  55598. * Grain post process which add noise to the image
  55599. */
  55600. grain: GrainPostProcess;
  55601. private _grainEffect;
  55602. /**
  55603. * Glow post process which adds a glow to emissive areas of the image
  55604. */
  55605. private _glowLayer;
  55606. /**
  55607. * Animations which can be used to tweak settings over a period of time
  55608. */
  55609. animations: Animation[];
  55610. private _imageProcessingConfigurationObserver;
  55611. private _sharpenEnabled;
  55612. private _bloomEnabled;
  55613. private _depthOfFieldEnabled;
  55614. private _depthOfFieldBlurLevel;
  55615. private _fxaaEnabled;
  55616. private _imageProcessingEnabled;
  55617. private _defaultPipelineTextureType;
  55618. private _bloomScale;
  55619. private _chromaticAberrationEnabled;
  55620. private _grainEnabled;
  55621. private _buildAllowed;
  55622. /**
  55623. * Gets active scene
  55624. */
  55625. readonly scene: Scene;
  55626. /**
  55627. * Enable or disable the sharpen process from the pipeline
  55628. */
  55629. sharpenEnabled: boolean;
  55630. private _resizeObserver;
  55631. private _hardwareScaleLevel;
  55632. private _bloomKernel;
  55633. /**
  55634. * Specifies the size of the bloom blur kernel, relative to the final output size
  55635. */
  55636. bloomKernel: number;
  55637. /**
  55638. * Specifies the weight of the bloom in the final rendering
  55639. */
  55640. private _bloomWeight;
  55641. /**
  55642. * Specifies the luma threshold for the area that will be blurred by the bloom
  55643. */
  55644. private _bloomThreshold;
  55645. private _hdr;
  55646. /**
  55647. * The strength of the bloom.
  55648. */
  55649. bloomWeight: number;
  55650. /**
  55651. * The strength of the bloom.
  55652. */
  55653. bloomThreshold: number;
  55654. /**
  55655. * The scale of the bloom, lower value will provide better performance.
  55656. */
  55657. bloomScale: number;
  55658. /**
  55659. * Enable or disable the bloom from the pipeline
  55660. */
  55661. bloomEnabled: boolean;
  55662. private _rebuildBloom;
  55663. /**
  55664. * If the depth of field is enabled.
  55665. */
  55666. depthOfFieldEnabled: boolean;
  55667. /**
  55668. * Blur level of the depth of field effect. (Higher blur will effect performance)
  55669. */
  55670. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  55671. /**
  55672. * If the anti aliasing is enabled.
  55673. */
  55674. fxaaEnabled: boolean;
  55675. private _samples;
  55676. /**
  55677. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  55678. */
  55679. samples: number;
  55680. /**
  55681. * If image processing is enabled.
  55682. */
  55683. imageProcessingEnabled: boolean;
  55684. /**
  55685. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  55686. */
  55687. glowLayerEnabled: boolean;
  55688. /**
  55689. * Enable or disable the chromaticAberration process from the pipeline
  55690. */
  55691. chromaticAberrationEnabled: boolean;
  55692. /**
  55693. * Enable or disable the grain process from the pipeline
  55694. */
  55695. grainEnabled: boolean;
  55696. /**
  55697. * @constructor
  55698. * @param name - The rendering pipeline name (default: "")
  55699. * @param hdr - If high dynamic range textures should be used (default: true)
  55700. * @param scene - The scene linked to this pipeline (default: the last created scene)
  55701. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  55702. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  55703. */
  55704. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  55705. /**
  55706. * Get the class name
  55707. * @returns "DefaultRenderingPipeline"
  55708. */
  55709. getClassName(): string;
  55710. /**
  55711. * Force the compilation of the entire pipeline.
  55712. */
  55713. prepare(): void;
  55714. private _hasCleared;
  55715. private _prevPostProcess;
  55716. private _prevPrevPostProcess;
  55717. private _setAutoClearAndTextureSharing;
  55718. private _depthOfFieldSceneObserver;
  55719. private _buildPipeline;
  55720. private _disposePostProcesses;
  55721. /**
  55722. * Adds a camera to the pipeline
  55723. * @param camera the camera to be added
  55724. */
  55725. addCamera(camera: Camera): void;
  55726. /**
  55727. * Removes a camera from the pipeline
  55728. * @param camera the camera to remove
  55729. */
  55730. removeCamera(camera: Camera): void;
  55731. /**
  55732. * Dispose of the pipeline and stop all post processes
  55733. */
  55734. dispose(): void;
  55735. /**
  55736. * Serialize the rendering pipeline (Used when exporting)
  55737. * @returns the serialized object
  55738. */
  55739. serialize(): any;
  55740. /**
  55741. * Parse the serialized pipeline
  55742. * @param source Source pipeline.
  55743. * @param scene The scene to load the pipeline to.
  55744. * @param rootUrl The URL of the serialized pipeline.
  55745. * @returns An instantiated pipeline from the serialized object.
  55746. */
  55747. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  55748. }
  55749. }
  55750. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  55751. /** @hidden */
  55752. export var lensHighlightsPixelShader: {
  55753. name: string;
  55754. shader: string;
  55755. };
  55756. }
  55757. declare module "babylonjs/Shaders/depthOfField.fragment" {
  55758. /** @hidden */
  55759. export var depthOfFieldPixelShader: {
  55760. name: string;
  55761. shader: string;
  55762. };
  55763. }
  55764. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  55765. import { Camera } from "babylonjs/Cameras/camera";
  55766. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55767. import { Scene } from "babylonjs/scene";
  55768. import "babylonjs/Shaders/chromaticAberration.fragment";
  55769. import "babylonjs/Shaders/lensHighlights.fragment";
  55770. import "babylonjs/Shaders/depthOfField.fragment";
  55771. /**
  55772. * BABYLON.JS Chromatic Aberration GLSL Shader
  55773. * Author: Olivier Guyot
  55774. * Separates very slightly R, G and B colors on the edges of the screen
  55775. * Inspired by Francois Tarlier & Martins Upitis
  55776. */
  55777. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  55778. /**
  55779. * @ignore
  55780. * The chromatic aberration PostProcess id in the pipeline
  55781. */
  55782. LensChromaticAberrationEffect: string;
  55783. /**
  55784. * @ignore
  55785. * The highlights enhancing PostProcess id in the pipeline
  55786. */
  55787. HighlightsEnhancingEffect: string;
  55788. /**
  55789. * @ignore
  55790. * The depth-of-field PostProcess id in the pipeline
  55791. */
  55792. LensDepthOfFieldEffect: string;
  55793. private _scene;
  55794. private _depthTexture;
  55795. private _grainTexture;
  55796. private _chromaticAberrationPostProcess;
  55797. private _highlightsPostProcess;
  55798. private _depthOfFieldPostProcess;
  55799. private _edgeBlur;
  55800. private _grainAmount;
  55801. private _chromaticAberration;
  55802. private _distortion;
  55803. private _highlightsGain;
  55804. private _highlightsThreshold;
  55805. private _dofDistance;
  55806. private _dofAperture;
  55807. private _dofDarken;
  55808. private _dofPentagon;
  55809. private _blurNoise;
  55810. /**
  55811. * @constructor
  55812. *
  55813. * Effect parameters are as follow:
  55814. * {
  55815. * chromatic_aberration: number; // from 0 to x (1 for realism)
  55816. * edge_blur: number; // from 0 to x (1 for realism)
  55817. * distortion: number; // from 0 to x (1 for realism)
  55818. * grain_amount: number; // from 0 to 1
  55819. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  55820. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  55821. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  55822. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  55823. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  55824. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  55825. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  55826. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  55827. * }
  55828. * Note: if an effect parameter is unset, effect is disabled
  55829. *
  55830. * @param name The rendering pipeline name
  55831. * @param parameters - An object containing all parameters (see above)
  55832. * @param scene The scene linked to this pipeline
  55833. * @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)
  55834. * @param cameras The array of cameras that the rendering pipeline will be attached to
  55835. */
  55836. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  55837. /**
  55838. * Get the class name
  55839. * @returns "LensRenderingPipeline"
  55840. */
  55841. getClassName(): string;
  55842. /**
  55843. * Gets associated scene
  55844. */
  55845. readonly scene: Scene;
  55846. /**
  55847. * Gets or sets the edge blur
  55848. */
  55849. edgeBlur: number;
  55850. /**
  55851. * Gets or sets the grain amount
  55852. */
  55853. grainAmount: number;
  55854. /**
  55855. * Gets or sets the chromatic aberration amount
  55856. */
  55857. chromaticAberration: number;
  55858. /**
  55859. * Gets or sets the depth of field aperture
  55860. */
  55861. dofAperture: number;
  55862. /**
  55863. * Gets or sets the edge distortion
  55864. */
  55865. edgeDistortion: number;
  55866. /**
  55867. * Gets or sets the depth of field distortion
  55868. */
  55869. dofDistortion: number;
  55870. /**
  55871. * Gets or sets the darken out of focus amount
  55872. */
  55873. darkenOutOfFocus: number;
  55874. /**
  55875. * Gets or sets a boolean indicating if blur noise is enabled
  55876. */
  55877. blurNoise: boolean;
  55878. /**
  55879. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  55880. */
  55881. pentagonBokeh: boolean;
  55882. /**
  55883. * Gets or sets the highlight grain amount
  55884. */
  55885. highlightsGain: number;
  55886. /**
  55887. * Gets or sets the highlight threshold
  55888. */
  55889. highlightsThreshold: number;
  55890. /**
  55891. * Sets the amount of blur at the edges
  55892. * @param amount blur amount
  55893. */
  55894. setEdgeBlur(amount: number): void;
  55895. /**
  55896. * Sets edge blur to 0
  55897. */
  55898. disableEdgeBlur(): void;
  55899. /**
  55900. * Sets the amout of grain
  55901. * @param amount Amount of grain
  55902. */
  55903. setGrainAmount(amount: number): void;
  55904. /**
  55905. * Set grain amount to 0
  55906. */
  55907. disableGrain(): void;
  55908. /**
  55909. * Sets the chromatic aberration amount
  55910. * @param amount amount of chromatic aberration
  55911. */
  55912. setChromaticAberration(amount: number): void;
  55913. /**
  55914. * Sets chromatic aberration amount to 0
  55915. */
  55916. disableChromaticAberration(): void;
  55917. /**
  55918. * Sets the EdgeDistortion amount
  55919. * @param amount amount of EdgeDistortion
  55920. */
  55921. setEdgeDistortion(amount: number): void;
  55922. /**
  55923. * Sets edge distortion to 0
  55924. */
  55925. disableEdgeDistortion(): void;
  55926. /**
  55927. * Sets the FocusDistance amount
  55928. * @param amount amount of FocusDistance
  55929. */
  55930. setFocusDistance(amount: number): void;
  55931. /**
  55932. * Disables depth of field
  55933. */
  55934. disableDepthOfField(): void;
  55935. /**
  55936. * Sets the Aperture amount
  55937. * @param amount amount of Aperture
  55938. */
  55939. setAperture(amount: number): void;
  55940. /**
  55941. * Sets the DarkenOutOfFocus amount
  55942. * @param amount amount of DarkenOutOfFocus
  55943. */
  55944. setDarkenOutOfFocus(amount: number): void;
  55945. private _pentagonBokehIsEnabled;
  55946. /**
  55947. * Creates a pentagon bokeh effect
  55948. */
  55949. enablePentagonBokeh(): void;
  55950. /**
  55951. * Disables the pentagon bokeh effect
  55952. */
  55953. disablePentagonBokeh(): void;
  55954. /**
  55955. * Enables noise blur
  55956. */
  55957. enableNoiseBlur(): void;
  55958. /**
  55959. * Disables noise blur
  55960. */
  55961. disableNoiseBlur(): void;
  55962. /**
  55963. * Sets the HighlightsGain amount
  55964. * @param amount amount of HighlightsGain
  55965. */
  55966. setHighlightsGain(amount: number): void;
  55967. /**
  55968. * Sets the HighlightsThreshold amount
  55969. * @param amount amount of HighlightsThreshold
  55970. */
  55971. setHighlightsThreshold(amount: number): void;
  55972. /**
  55973. * Disables highlights
  55974. */
  55975. disableHighlights(): void;
  55976. /**
  55977. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  55978. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  55979. */
  55980. dispose(disableDepthRender?: boolean): void;
  55981. private _createChromaticAberrationPostProcess;
  55982. private _createHighlightsPostProcess;
  55983. private _createDepthOfFieldPostProcess;
  55984. private _createGrainTexture;
  55985. }
  55986. }
  55987. declare module "babylonjs/Shaders/ssao2.fragment" {
  55988. /** @hidden */
  55989. export var ssao2PixelShader: {
  55990. name: string;
  55991. shader: string;
  55992. };
  55993. }
  55994. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  55995. /** @hidden */
  55996. export var ssaoCombinePixelShader: {
  55997. name: string;
  55998. shader: string;
  55999. };
  56000. }
  56001. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  56002. import { Camera } from "babylonjs/Cameras/camera";
  56003. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56004. import { Scene } from "babylonjs/scene";
  56005. import "babylonjs/Shaders/ssao2.fragment";
  56006. import "babylonjs/Shaders/ssaoCombine.fragment";
  56007. /**
  56008. * Render pipeline to produce ssao effect
  56009. */
  56010. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  56011. /**
  56012. * @ignore
  56013. * The PassPostProcess id in the pipeline that contains the original scene color
  56014. */
  56015. SSAOOriginalSceneColorEffect: string;
  56016. /**
  56017. * @ignore
  56018. * The SSAO PostProcess id in the pipeline
  56019. */
  56020. SSAORenderEffect: string;
  56021. /**
  56022. * @ignore
  56023. * The horizontal blur PostProcess id in the pipeline
  56024. */
  56025. SSAOBlurHRenderEffect: string;
  56026. /**
  56027. * @ignore
  56028. * The vertical blur PostProcess id in the pipeline
  56029. */
  56030. SSAOBlurVRenderEffect: string;
  56031. /**
  56032. * @ignore
  56033. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56034. */
  56035. SSAOCombineRenderEffect: string;
  56036. /**
  56037. * The output strength of the SSAO post-process. Default value is 1.0.
  56038. */
  56039. totalStrength: number;
  56040. /**
  56041. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  56042. */
  56043. maxZ: number;
  56044. /**
  56045. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  56046. */
  56047. minZAspect: number;
  56048. private _samples;
  56049. /**
  56050. * Number of samples used for the SSAO calculations. Default value is 8
  56051. */
  56052. samples: number;
  56053. private _textureSamples;
  56054. /**
  56055. * Number of samples to use for antialiasing
  56056. */
  56057. textureSamples: number;
  56058. /**
  56059. * Ratio object used for SSAO ratio and blur ratio
  56060. */
  56061. private _ratio;
  56062. /**
  56063. * Dynamically generated sphere sampler.
  56064. */
  56065. private _sampleSphere;
  56066. /**
  56067. * Blur filter offsets
  56068. */
  56069. private _samplerOffsets;
  56070. private _expensiveBlur;
  56071. /**
  56072. * If bilateral blur should be used
  56073. */
  56074. expensiveBlur: boolean;
  56075. /**
  56076. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  56077. */
  56078. radius: number;
  56079. /**
  56080. * The base color of the SSAO post-process
  56081. * The final result is "base + ssao" between [0, 1]
  56082. */
  56083. base: number;
  56084. /**
  56085. * Support test.
  56086. */
  56087. static readonly IsSupported: boolean;
  56088. private _scene;
  56089. private _depthTexture;
  56090. private _normalTexture;
  56091. private _randomTexture;
  56092. private _originalColorPostProcess;
  56093. private _ssaoPostProcess;
  56094. private _blurHPostProcess;
  56095. private _blurVPostProcess;
  56096. private _ssaoCombinePostProcess;
  56097. private _firstUpdate;
  56098. /**
  56099. * Gets active scene
  56100. */
  56101. readonly scene: Scene;
  56102. /**
  56103. * @constructor
  56104. * @param name The rendering pipeline name
  56105. * @param scene The scene linked to this pipeline
  56106. * @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 }
  56107. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56108. */
  56109. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56110. /**
  56111. * Get the class name
  56112. * @returns "SSAO2RenderingPipeline"
  56113. */
  56114. getClassName(): string;
  56115. /**
  56116. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56117. */
  56118. dispose(disableGeometryBufferRenderer?: boolean): void;
  56119. private _createBlurPostProcess;
  56120. /** @hidden */
  56121. _rebuild(): void;
  56122. private _bits;
  56123. private _radicalInverse_VdC;
  56124. private _hammersley;
  56125. private _hemisphereSample_uniform;
  56126. private _generateHemisphere;
  56127. private _createSSAOPostProcess;
  56128. private _createSSAOCombinePostProcess;
  56129. private _createRandomTexture;
  56130. /**
  56131. * Serialize the rendering pipeline (Used when exporting)
  56132. * @returns the serialized object
  56133. */
  56134. serialize(): any;
  56135. /**
  56136. * Parse the serialized pipeline
  56137. * @param source Source pipeline.
  56138. * @param scene The scene to load the pipeline to.
  56139. * @param rootUrl The URL of the serialized pipeline.
  56140. * @returns An instantiated pipeline from the serialized object.
  56141. */
  56142. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  56143. }
  56144. }
  56145. declare module "babylonjs/Shaders/ssao.fragment" {
  56146. /** @hidden */
  56147. export var ssaoPixelShader: {
  56148. name: string;
  56149. shader: string;
  56150. };
  56151. }
  56152. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  56153. import { Camera } from "babylonjs/Cameras/camera";
  56154. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56155. import { Scene } from "babylonjs/scene";
  56156. import "babylonjs/Shaders/ssao.fragment";
  56157. import "babylonjs/Shaders/ssaoCombine.fragment";
  56158. /**
  56159. * Render pipeline to produce ssao effect
  56160. */
  56161. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  56162. /**
  56163. * @ignore
  56164. * The PassPostProcess id in the pipeline that contains the original scene color
  56165. */
  56166. SSAOOriginalSceneColorEffect: string;
  56167. /**
  56168. * @ignore
  56169. * The SSAO PostProcess id in the pipeline
  56170. */
  56171. SSAORenderEffect: string;
  56172. /**
  56173. * @ignore
  56174. * The horizontal blur PostProcess id in the pipeline
  56175. */
  56176. SSAOBlurHRenderEffect: string;
  56177. /**
  56178. * @ignore
  56179. * The vertical blur PostProcess id in the pipeline
  56180. */
  56181. SSAOBlurVRenderEffect: string;
  56182. /**
  56183. * @ignore
  56184. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56185. */
  56186. SSAOCombineRenderEffect: string;
  56187. /**
  56188. * The output strength of the SSAO post-process. Default value is 1.0.
  56189. */
  56190. totalStrength: number;
  56191. /**
  56192. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  56193. */
  56194. radius: number;
  56195. /**
  56196. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  56197. * Must not be equal to fallOff and superior to fallOff.
  56198. * Default value is 0.0075
  56199. */
  56200. area: number;
  56201. /**
  56202. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  56203. * Must not be equal to area and inferior to area.
  56204. * Default value is 0.000001
  56205. */
  56206. fallOff: number;
  56207. /**
  56208. * The base color of the SSAO post-process
  56209. * The final result is "base + ssao" between [0, 1]
  56210. */
  56211. base: number;
  56212. private _scene;
  56213. private _depthTexture;
  56214. private _randomTexture;
  56215. private _originalColorPostProcess;
  56216. private _ssaoPostProcess;
  56217. private _blurHPostProcess;
  56218. private _blurVPostProcess;
  56219. private _ssaoCombinePostProcess;
  56220. private _firstUpdate;
  56221. /**
  56222. * Gets active scene
  56223. */
  56224. readonly scene: Scene;
  56225. /**
  56226. * @constructor
  56227. * @param name - The rendering pipeline name
  56228. * @param scene - The scene linked to this pipeline
  56229. * @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 }
  56230. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  56231. */
  56232. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56233. /**
  56234. * Get the class name
  56235. * @returns "SSAORenderingPipeline"
  56236. */
  56237. getClassName(): string;
  56238. /**
  56239. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56240. */
  56241. dispose(disableDepthRender?: boolean): void;
  56242. private _createBlurPostProcess;
  56243. /** @hidden */
  56244. _rebuild(): void;
  56245. private _createSSAOPostProcess;
  56246. private _createSSAOCombinePostProcess;
  56247. private _createRandomTexture;
  56248. }
  56249. }
  56250. declare module "babylonjs/Shaders/standard.fragment" {
  56251. /** @hidden */
  56252. export var standardPixelShader: {
  56253. name: string;
  56254. shader: string;
  56255. };
  56256. }
  56257. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  56258. import { Nullable } from "babylonjs/types";
  56259. import { IAnimatable } from "babylonjs/Misc/tools";
  56260. import { Camera } from "babylonjs/Cameras/camera";
  56261. import { Texture } from "babylonjs/Materials/Textures/texture";
  56262. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56263. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56264. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  56265. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  56266. import { IDisposable } from "babylonjs/scene";
  56267. import { SpotLight } from "babylonjs/Lights/spotLight";
  56268. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  56269. import { Scene } from "babylonjs/scene";
  56270. import { Animation } from "babylonjs/Animations/animation";
  56271. import "babylonjs/Shaders/standard.fragment";
  56272. /**
  56273. * Standard rendering pipeline
  56274. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56275. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  56276. */
  56277. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56278. /**
  56279. * Public members
  56280. */
  56281. /**
  56282. * Post-process which contains the original scene color before the pipeline applies all the effects
  56283. */
  56284. originalPostProcess: Nullable<PostProcess>;
  56285. /**
  56286. * Post-process used to down scale an image x4
  56287. */
  56288. downSampleX4PostProcess: Nullable<PostProcess>;
  56289. /**
  56290. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  56291. */
  56292. brightPassPostProcess: Nullable<PostProcess>;
  56293. /**
  56294. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  56295. */
  56296. blurHPostProcesses: PostProcess[];
  56297. /**
  56298. * Post-process array storing all the vertical blur post-processes used by the pipeline
  56299. */
  56300. blurVPostProcesses: PostProcess[];
  56301. /**
  56302. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  56303. */
  56304. textureAdderPostProcess: Nullable<PostProcess>;
  56305. /**
  56306. * Post-process used to create volumetric lighting effect
  56307. */
  56308. volumetricLightPostProcess: Nullable<PostProcess>;
  56309. /**
  56310. * Post-process used to smooth the previous volumetric light post-process on the X axis
  56311. */
  56312. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  56313. /**
  56314. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  56315. */
  56316. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  56317. /**
  56318. * Post-process used to merge the volumetric light effect and the real scene color
  56319. */
  56320. volumetricLightMergePostProces: Nullable<PostProcess>;
  56321. /**
  56322. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  56323. */
  56324. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  56325. /**
  56326. * Base post-process used to calculate the average luminance of the final image for HDR
  56327. */
  56328. luminancePostProcess: Nullable<PostProcess>;
  56329. /**
  56330. * Post-processes used to create down sample post-processes in order to get
  56331. * the average luminance of the final image for HDR
  56332. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  56333. */
  56334. luminanceDownSamplePostProcesses: PostProcess[];
  56335. /**
  56336. * Post-process used to create a HDR effect (light adaptation)
  56337. */
  56338. hdrPostProcess: Nullable<PostProcess>;
  56339. /**
  56340. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  56341. */
  56342. textureAdderFinalPostProcess: Nullable<PostProcess>;
  56343. /**
  56344. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  56345. */
  56346. lensFlareFinalPostProcess: Nullable<PostProcess>;
  56347. /**
  56348. * Post-process used to merge the final HDR post-process and the real scene color
  56349. */
  56350. hdrFinalPostProcess: Nullable<PostProcess>;
  56351. /**
  56352. * Post-process used to create a lens flare effect
  56353. */
  56354. lensFlarePostProcess: Nullable<PostProcess>;
  56355. /**
  56356. * Post-process that merges the result of the lens flare post-process and the real scene color
  56357. */
  56358. lensFlareComposePostProcess: Nullable<PostProcess>;
  56359. /**
  56360. * Post-process used to create a motion blur effect
  56361. */
  56362. motionBlurPostProcess: Nullable<PostProcess>;
  56363. /**
  56364. * Post-process used to create a depth of field effect
  56365. */
  56366. depthOfFieldPostProcess: Nullable<PostProcess>;
  56367. /**
  56368. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  56369. */
  56370. fxaaPostProcess: Nullable<FxaaPostProcess>;
  56371. /**
  56372. * Represents the brightness threshold in order to configure the illuminated surfaces
  56373. */
  56374. brightThreshold: number;
  56375. /**
  56376. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  56377. */
  56378. blurWidth: number;
  56379. /**
  56380. * Sets if the blur for highlighted surfaces must be only horizontal
  56381. */
  56382. horizontalBlur: boolean;
  56383. /**
  56384. * Gets the overall exposure used by the pipeline
  56385. */
  56386. /**
  56387. * Sets the overall exposure used by the pipeline
  56388. */
  56389. exposure: number;
  56390. /**
  56391. * Texture used typically to simulate "dirty" on camera lens
  56392. */
  56393. lensTexture: Nullable<Texture>;
  56394. /**
  56395. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  56396. */
  56397. volumetricLightCoefficient: number;
  56398. /**
  56399. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  56400. */
  56401. volumetricLightPower: number;
  56402. /**
  56403. * Used the set the blur intensity to smooth the volumetric lights
  56404. */
  56405. volumetricLightBlurScale: number;
  56406. /**
  56407. * Light (spot or directional) used to generate the volumetric lights rays
  56408. * The source light must have a shadow generate so the pipeline can get its
  56409. * depth map
  56410. */
  56411. sourceLight: Nullable<SpotLight | DirectionalLight>;
  56412. /**
  56413. * For eye adaptation, represents the minimum luminance the eye can see
  56414. */
  56415. hdrMinimumLuminance: number;
  56416. /**
  56417. * For eye adaptation, represents the decrease luminance speed
  56418. */
  56419. hdrDecreaseRate: number;
  56420. /**
  56421. * For eye adaptation, represents the increase luminance speed
  56422. */
  56423. hdrIncreaseRate: number;
  56424. /**
  56425. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56426. */
  56427. /**
  56428. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56429. */
  56430. hdrAutoExposure: boolean;
  56431. /**
  56432. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  56433. */
  56434. lensColorTexture: Nullable<Texture>;
  56435. /**
  56436. * The overall strengh for the lens flare effect
  56437. */
  56438. lensFlareStrength: number;
  56439. /**
  56440. * Dispersion coefficient for lens flare ghosts
  56441. */
  56442. lensFlareGhostDispersal: number;
  56443. /**
  56444. * Main lens flare halo width
  56445. */
  56446. lensFlareHaloWidth: number;
  56447. /**
  56448. * Based on the lens distortion effect, defines how much the lens flare result
  56449. * is distorted
  56450. */
  56451. lensFlareDistortionStrength: number;
  56452. /**
  56453. * Lens star texture must be used to simulate rays on the flares and is available
  56454. * in the documentation
  56455. */
  56456. lensStarTexture: Nullable<Texture>;
  56457. /**
  56458. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  56459. * flare effect by taking account of the dirt texture
  56460. */
  56461. lensFlareDirtTexture: Nullable<Texture>;
  56462. /**
  56463. * Represents the focal length for the depth of field effect
  56464. */
  56465. depthOfFieldDistance: number;
  56466. /**
  56467. * Represents the blur intensity for the blurred part of the depth of field effect
  56468. */
  56469. depthOfFieldBlurWidth: number;
  56470. /**
  56471. * For motion blur, defines how much the image is blurred by the movement
  56472. */
  56473. motionStrength: number;
  56474. /**
  56475. * List of animations for the pipeline (IAnimatable implementation)
  56476. */
  56477. animations: Animation[];
  56478. /**
  56479. * Private members
  56480. */
  56481. private _scene;
  56482. private _currentDepthOfFieldSource;
  56483. private _basePostProcess;
  56484. private _fixedExposure;
  56485. private _currentExposure;
  56486. private _hdrAutoExposure;
  56487. private _hdrCurrentLuminance;
  56488. private _floatTextureType;
  56489. private _ratio;
  56490. private _bloomEnabled;
  56491. private _depthOfFieldEnabled;
  56492. private _vlsEnabled;
  56493. private _lensFlareEnabled;
  56494. private _hdrEnabled;
  56495. private _motionBlurEnabled;
  56496. private _fxaaEnabled;
  56497. private _motionBlurSamples;
  56498. private _volumetricLightStepsCount;
  56499. private _samples;
  56500. /**
  56501. * @ignore
  56502. * Specifies if the bloom pipeline is enabled
  56503. */
  56504. BloomEnabled: boolean;
  56505. /**
  56506. * @ignore
  56507. * Specifies if the depth of field pipeline is enabed
  56508. */
  56509. DepthOfFieldEnabled: boolean;
  56510. /**
  56511. * @ignore
  56512. * Specifies if the lens flare pipeline is enabed
  56513. */
  56514. LensFlareEnabled: boolean;
  56515. /**
  56516. * @ignore
  56517. * Specifies if the HDR pipeline is enabled
  56518. */
  56519. HDREnabled: boolean;
  56520. /**
  56521. * @ignore
  56522. * Specifies if the volumetric lights scattering effect is enabled
  56523. */
  56524. VLSEnabled: boolean;
  56525. /**
  56526. * @ignore
  56527. * Specifies if the motion blur effect is enabled
  56528. */
  56529. MotionBlurEnabled: boolean;
  56530. /**
  56531. * Specifies if anti-aliasing is enabled
  56532. */
  56533. fxaaEnabled: boolean;
  56534. /**
  56535. * Specifies the number of steps used to calculate the volumetric lights
  56536. * Typically in interval [50, 200]
  56537. */
  56538. volumetricLightStepsCount: number;
  56539. /**
  56540. * Specifies the number of samples used for the motion blur effect
  56541. * Typically in interval [16, 64]
  56542. */
  56543. motionBlurSamples: number;
  56544. /**
  56545. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  56546. */
  56547. samples: number;
  56548. /**
  56549. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56550. * @constructor
  56551. * @param name The rendering pipeline name
  56552. * @param scene The scene linked to this pipeline
  56553. * @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)
  56554. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  56555. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56556. */
  56557. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  56558. private _buildPipeline;
  56559. private _createDownSampleX4PostProcess;
  56560. private _createBrightPassPostProcess;
  56561. private _createBlurPostProcesses;
  56562. private _createTextureAdderPostProcess;
  56563. private _createVolumetricLightPostProcess;
  56564. private _createLuminancePostProcesses;
  56565. private _createHdrPostProcess;
  56566. private _createLensFlarePostProcess;
  56567. private _createDepthOfFieldPostProcess;
  56568. private _createMotionBlurPostProcess;
  56569. private _getDepthTexture;
  56570. private _disposePostProcesses;
  56571. /**
  56572. * Dispose of the pipeline and stop all post processes
  56573. */
  56574. dispose(): void;
  56575. /**
  56576. * Serialize the rendering pipeline (Used when exporting)
  56577. * @returns the serialized object
  56578. */
  56579. serialize(): any;
  56580. /**
  56581. * Parse the serialized pipeline
  56582. * @param source Source pipeline.
  56583. * @param scene The scene to load the pipeline to.
  56584. * @param rootUrl The URL of the serialized pipeline.
  56585. * @returns An instantiated pipeline from the serialized object.
  56586. */
  56587. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  56588. /**
  56589. * Luminance steps
  56590. */
  56591. static LuminanceSteps: number;
  56592. }
  56593. }
  56594. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  56595. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  56596. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  56597. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  56598. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  56599. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  56600. }
  56601. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  56602. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  56603. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  56604. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56605. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  56606. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  56607. }
  56608. declare module "babylonjs/Shaders/tonemap.fragment" {
  56609. /** @hidden */
  56610. export var tonemapPixelShader: {
  56611. name: string;
  56612. shader: string;
  56613. };
  56614. }
  56615. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  56616. import { Camera } from "babylonjs/Cameras/camera";
  56617. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56618. import "babylonjs/Shaders/tonemap.fragment";
  56619. import { Engine } from "babylonjs/Engines/engine";
  56620. /** Defines operator used for tonemapping */
  56621. export enum TonemappingOperator {
  56622. /** Hable */
  56623. Hable = 0,
  56624. /** Reinhard */
  56625. Reinhard = 1,
  56626. /** HejiDawson */
  56627. HejiDawson = 2,
  56628. /** Photographic */
  56629. Photographic = 3
  56630. }
  56631. /**
  56632. * Defines a post process to apply tone mapping
  56633. */
  56634. export class TonemapPostProcess extends PostProcess {
  56635. private _operator;
  56636. /** Defines the required exposure adjustement */
  56637. exposureAdjustment: number;
  56638. /**
  56639. * Creates a new TonemapPostProcess
  56640. * @param name defines the name of the postprocess
  56641. * @param _operator defines the operator to use
  56642. * @param exposureAdjustment defines the required exposure adjustement
  56643. * @param camera defines the camera to use (can be null)
  56644. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  56645. * @param engine defines the hosting engine (can be ignore if camera is set)
  56646. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56647. */
  56648. constructor(name: string, _operator: TonemappingOperator,
  56649. /** Defines the required exposure adjustement */
  56650. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  56651. }
  56652. }
  56653. declare module "babylonjs/Shaders/depth.vertex" {
  56654. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56655. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56656. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56657. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56658. /** @hidden */
  56659. export var depthVertexShader: {
  56660. name: string;
  56661. shader: string;
  56662. };
  56663. }
  56664. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  56665. /** @hidden */
  56666. export var volumetricLightScatteringPixelShader: {
  56667. name: string;
  56668. shader: string;
  56669. };
  56670. }
  56671. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  56672. /** @hidden */
  56673. export var volumetricLightScatteringPassPixelShader: {
  56674. name: string;
  56675. shader: string;
  56676. };
  56677. }
  56678. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  56679. import { Vector3 } from "babylonjs/Maths/math";
  56680. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56681. import { Mesh } from "babylonjs/Meshes/mesh";
  56682. import { Camera } from "babylonjs/Cameras/camera";
  56683. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56684. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56685. import { Scene } from "babylonjs/scene";
  56686. import "babylonjs/Meshes/Builders/planeBuilder";
  56687. import "babylonjs/Shaders/depth.vertex";
  56688. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  56689. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  56690. import { Engine } from "babylonjs/Engines/engine";
  56691. /**
  56692. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  56693. */
  56694. export class VolumetricLightScatteringPostProcess extends PostProcess {
  56695. private _volumetricLightScatteringPass;
  56696. private _volumetricLightScatteringRTT;
  56697. private _viewPort;
  56698. private _screenCoordinates;
  56699. private _cachedDefines;
  56700. /**
  56701. * If not undefined, the mesh position is computed from the attached node position
  56702. */
  56703. attachedNode: {
  56704. position: Vector3;
  56705. };
  56706. /**
  56707. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  56708. */
  56709. customMeshPosition: Vector3;
  56710. /**
  56711. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  56712. */
  56713. useCustomMeshPosition: boolean;
  56714. /**
  56715. * If the post-process should inverse the light scattering direction
  56716. */
  56717. invert: boolean;
  56718. /**
  56719. * The internal mesh used by the post-process
  56720. */
  56721. mesh: Mesh;
  56722. /**
  56723. * @hidden
  56724. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  56725. */
  56726. useDiffuseColor: boolean;
  56727. /**
  56728. * Array containing the excluded meshes not rendered in the internal pass
  56729. */
  56730. excludedMeshes: AbstractMesh[];
  56731. /**
  56732. * Controls the overall intensity of the post-process
  56733. */
  56734. exposure: number;
  56735. /**
  56736. * Dissipates each sample's contribution in range [0, 1]
  56737. */
  56738. decay: number;
  56739. /**
  56740. * Controls the overall intensity of each sample
  56741. */
  56742. weight: number;
  56743. /**
  56744. * Controls the density of each sample
  56745. */
  56746. density: number;
  56747. /**
  56748. * @constructor
  56749. * @param name The post-process name
  56750. * @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)
  56751. * @param camera The camera that the post-process will be attached to
  56752. * @param mesh The mesh used to create the light scattering
  56753. * @param samples The post-process quality, default 100
  56754. * @param samplingModeThe post-process filtering mode
  56755. * @param engine The babylon engine
  56756. * @param reusable If the post-process is reusable
  56757. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  56758. */
  56759. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  56760. /**
  56761. * Returns the string "VolumetricLightScatteringPostProcess"
  56762. * @returns "VolumetricLightScatteringPostProcess"
  56763. */
  56764. getClassName(): string;
  56765. private _isReady;
  56766. /**
  56767. * Sets the new light position for light scattering effect
  56768. * @param position The new custom light position
  56769. */
  56770. setCustomMeshPosition(position: Vector3): void;
  56771. /**
  56772. * Returns the light position for light scattering effect
  56773. * @return Vector3 The custom light position
  56774. */
  56775. getCustomMeshPosition(): Vector3;
  56776. /**
  56777. * Disposes the internal assets and detaches the post-process from the camera
  56778. */
  56779. dispose(camera: Camera): void;
  56780. /**
  56781. * Returns the render target texture used by the post-process
  56782. * @return the render target texture used by the post-process
  56783. */
  56784. getPass(): RenderTargetTexture;
  56785. private _meshExcluded;
  56786. private _createPass;
  56787. private _updateMeshScreenCoordinates;
  56788. /**
  56789. * Creates a default mesh for the Volumeric Light Scattering post-process
  56790. * @param name The mesh name
  56791. * @param scene The scene where to create the mesh
  56792. * @return the default mesh
  56793. */
  56794. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  56795. }
  56796. }
  56797. declare module "babylonjs/PostProcesses/index" {
  56798. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  56799. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  56800. export * from "babylonjs/PostProcesses/bloomEffect";
  56801. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  56802. export * from "babylonjs/PostProcesses/blurPostProcess";
  56803. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  56804. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  56805. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  56806. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  56807. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  56808. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  56809. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  56810. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  56811. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  56812. export * from "babylonjs/PostProcesses/filterPostProcess";
  56813. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  56814. export * from "babylonjs/PostProcesses/grainPostProcess";
  56815. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  56816. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  56817. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  56818. export * from "babylonjs/PostProcesses/passPostProcess";
  56819. export * from "babylonjs/PostProcesses/postProcess";
  56820. export * from "babylonjs/PostProcesses/postProcessManager";
  56821. export * from "babylonjs/PostProcesses/refractionPostProcess";
  56822. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  56823. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  56824. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  56825. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  56826. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  56827. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  56828. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  56829. }
  56830. declare module "babylonjs/Probes/index" {
  56831. export * from "babylonjs/Probes/reflectionProbe";
  56832. }
  56833. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  56834. import { Scene } from "babylonjs/scene";
  56835. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56836. import { Color3 } from "babylonjs/Maths/math";
  56837. import { SmartArray } from "babylonjs/Misc/smartArray";
  56838. import { ISceneComponent } from "babylonjs/sceneComponent";
  56839. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  56840. import "babylonjs/Meshes/Builders/boxBuilder";
  56841. import "babylonjs/Shaders/color.fragment";
  56842. import "babylonjs/Shaders/color.vertex";
  56843. module "babylonjs/scene" {
  56844. interface Scene {
  56845. /** @hidden (Backing field) */
  56846. _boundingBoxRenderer: BoundingBoxRenderer;
  56847. /** @hidden (Backing field) */
  56848. _forceShowBoundingBoxes: boolean;
  56849. /**
  56850. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  56851. */
  56852. forceShowBoundingBoxes: boolean;
  56853. /**
  56854. * Gets the bounding box renderer associated with the scene
  56855. * @returns a BoundingBoxRenderer
  56856. */
  56857. getBoundingBoxRenderer(): BoundingBoxRenderer;
  56858. }
  56859. }
  56860. module "babylonjs/Meshes/abstractMesh" {
  56861. interface AbstractMesh {
  56862. /** @hidden (Backing field) */
  56863. _showBoundingBox: boolean;
  56864. /**
  56865. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  56866. */
  56867. showBoundingBox: boolean;
  56868. }
  56869. }
  56870. /**
  56871. * Component responsible of rendering the bounding box of the meshes in a scene.
  56872. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  56873. */
  56874. export class BoundingBoxRenderer implements ISceneComponent {
  56875. /**
  56876. * The component name helpfull to identify the component in the list of scene components.
  56877. */
  56878. readonly name: string;
  56879. /**
  56880. * The scene the component belongs to.
  56881. */
  56882. scene: Scene;
  56883. /**
  56884. * Color of the bounding box lines placed in front of an object
  56885. */
  56886. frontColor: Color3;
  56887. /**
  56888. * Color of the bounding box lines placed behind an object
  56889. */
  56890. backColor: Color3;
  56891. /**
  56892. * Defines if the renderer should show the back lines or not
  56893. */
  56894. showBackLines: boolean;
  56895. /**
  56896. * @hidden
  56897. */
  56898. renderList: SmartArray<BoundingBox>;
  56899. private _colorShader;
  56900. private _vertexBuffers;
  56901. private _indexBuffer;
  56902. /**
  56903. * Instantiates a new bounding box renderer in a scene.
  56904. * @param scene the scene the renderer renders in
  56905. */
  56906. constructor(scene: Scene);
  56907. /**
  56908. * Registers the component in a given scene
  56909. */
  56910. register(): void;
  56911. private _evaluateSubMesh;
  56912. private _activeMesh;
  56913. private _prepareRessources;
  56914. private _createIndexBuffer;
  56915. /**
  56916. * Rebuilds the elements related to this component in case of
  56917. * context lost for instance.
  56918. */
  56919. rebuild(): void;
  56920. /**
  56921. * @hidden
  56922. */
  56923. reset(): void;
  56924. /**
  56925. * Render the bounding boxes of a specific rendering group
  56926. * @param renderingGroupId defines the rendering group to render
  56927. */
  56928. render(renderingGroupId: number): void;
  56929. /**
  56930. * In case of occlusion queries, we can render the occlusion bounding box through this method
  56931. * @param mesh Define the mesh to render the occlusion bounding box for
  56932. */
  56933. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  56934. /**
  56935. * Dispose and release the resources attached to this renderer.
  56936. */
  56937. dispose(): void;
  56938. }
  56939. }
  56940. declare module "babylonjs/Shaders/depth.fragment" {
  56941. /** @hidden */
  56942. export var depthPixelShader: {
  56943. name: string;
  56944. shader: string;
  56945. };
  56946. }
  56947. declare module "babylonjs/Rendering/depthRenderer" {
  56948. import { Nullable } from "babylonjs/types";
  56949. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56950. import { Scene } from "babylonjs/scene";
  56951. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56952. import { Camera } from "babylonjs/Cameras/camera";
  56953. import "babylonjs/Shaders/depth.fragment";
  56954. import "babylonjs/Shaders/depth.vertex";
  56955. /**
  56956. * This represents a depth renderer in Babylon.
  56957. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56958. */
  56959. export class DepthRenderer {
  56960. private _scene;
  56961. private _depthMap;
  56962. private _effect;
  56963. private _cachedDefines;
  56964. private _camera;
  56965. /**
  56966. * Specifiess that the depth renderer will only be used within
  56967. * the camera it is created for.
  56968. * This can help forcing its rendering during the camera processing.
  56969. */
  56970. useOnlyInActiveCamera: boolean;
  56971. /** @hidden */
  56972. static _SceneComponentInitialization: (scene: Scene) => void;
  56973. /**
  56974. * Instantiates a depth renderer
  56975. * @param scene The scene the renderer belongs to
  56976. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56977. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56978. */
  56979. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  56980. /**
  56981. * Creates the depth rendering effect and checks if the effect is ready.
  56982. * @param subMesh The submesh to be used to render the depth map of
  56983. * @param useInstances If multiple world instances should be used
  56984. * @returns if the depth renderer is ready to render the depth map
  56985. */
  56986. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56987. /**
  56988. * Gets the texture which the depth map will be written to.
  56989. * @returns The depth map texture
  56990. */
  56991. getDepthMap(): RenderTargetTexture;
  56992. /**
  56993. * Disposes of the depth renderer.
  56994. */
  56995. dispose(): void;
  56996. }
  56997. }
  56998. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  56999. import { Nullable } from "babylonjs/types";
  57000. import { Scene } from "babylonjs/scene";
  57001. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  57002. import { Camera } from "babylonjs/Cameras/camera";
  57003. import { ISceneComponent } from "babylonjs/sceneComponent";
  57004. module "babylonjs/scene" {
  57005. interface Scene {
  57006. /** @hidden (Backing field) */
  57007. _depthRenderer: {
  57008. [id: string]: DepthRenderer;
  57009. };
  57010. /**
  57011. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  57012. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  57013. * @returns the created depth renderer
  57014. */
  57015. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  57016. /**
  57017. * Disables a depth renderer for a given camera
  57018. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  57019. */
  57020. disableDepthRenderer(camera?: Nullable<Camera>): void;
  57021. }
  57022. }
  57023. /**
  57024. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  57025. * in several rendering techniques.
  57026. */
  57027. export class DepthRendererSceneComponent implements ISceneComponent {
  57028. /**
  57029. * The component name helpfull to identify the component in the list of scene components.
  57030. */
  57031. readonly name: string;
  57032. /**
  57033. * The scene the component belongs to.
  57034. */
  57035. scene: Scene;
  57036. /**
  57037. * Creates a new instance of the component for the given scene
  57038. * @param scene Defines the scene to register the component in
  57039. */
  57040. constructor(scene: Scene);
  57041. /**
  57042. * Registers the component in a given scene
  57043. */
  57044. register(): void;
  57045. /**
  57046. * Rebuilds the elements related to this component in case of
  57047. * context lost for instance.
  57048. */
  57049. rebuild(): void;
  57050. /**
  57051. * Disposes the component and the associated ressources
  57052. */
  57053. dispose(): void;
  57054. private _gatherRenderTargets;
  57055. private _gatherActiveCameraRenderTargets;
  57056. }
  57057. }
  57058. declare module "babylonjs/Shaders/outline.fragment" {
  57059. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57060. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  57061. /** @hidden */
  57062. export var outlinePixelShader: {
  57063. name: string;
  57064. shader: string;
  57065. };
  57066. }
  57067. declare module "babylonjs/Shaders/outline.vertex" {
  57068. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57069. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57070. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57071. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57072. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57073. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  57074. /** @hidden */
  57075. export var outlineVertexShader: {
  57076. name: string;
  57077. shader: string;
  57078. };
  57079. }
  57080. declare module "babylonjs/Rendering/outlineRenderer" {
  57081. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57082. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  57083. import { Scene } from "babylonjs/scene";
  57084. import { ISceneComponent } from "babylonjs/sceneComponent";
  57085. import "babylonjs/Shaders/outline.fragment";
  57086. import "babylonjs/Shaders/outline.vertex";
  57087. module "babylonjs/scene" {
  57088. interface Scene {
  57089. /** @hidden */
  57090. _outlineRenderer: OutlineRenderer;
  57091. /**
  57092. * Gets the outline renderer associated with the scene
  57093. * @returns a OutlineRenderer
  57094. */
  57095. getOutlineRenderer(): OutlineRenderer;
  57096. }
  57097. }
  57098. module "babylonjs/Meshes/abstractMesh" {
  57099. interface AbstractMesh {
  57100. /** @hidden (Backing field) */
  57101. _renderOutline: boolean;
  57102. /**
  57103. * Gets or sets a boolean indicating if the outline must be rendered as well
  57104. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  57105. */
  57106. renderOutline: boolean;
  57107. /** @hidden (Backing field) */
  57108. _renderOverlay: boolean;
  57109. /**
  57110. * Gets or sets a boolean indicating if the overlay must be rendered as well
  57111. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  57112. */
  57113. renderOverlay: boolean;
  57114. }
  57115. }
  57116. /**
  57117. * This class is responsible to draw bothe outline/overlay of meshes.
  57118. * It should not be used directly but through the available method on mesh.
  57119. */
  57120. export class OutlineRenderer implements ISceneComponent {
  57121. /**
  57122. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  57123. */
  57124. private static _StencilReference;
  57125. /**
  57126. * The name of the component. Each component must have a unique name.
  57127. */
  57128. name: string;
  57129. /**
  57130. * The scene the component belongs to.
  57131. */
  57132. scene: Scene;
  57133. /**
  57134. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  57135. */
  57136. zOffset: number;
  57137. private _engine;
  57138. private _effect;
  57139. private _cachedDefines;
  57140. private _savedDepthWrite;
  57141. /**
  57142. * Instantiates a new outline renderer. (There could be only one per scene).
  57143. * @param scene Defines the scene it belongs to
  57144. */
  57145. constructor(scene: Scene);
  57146. /**
  57147. * Register the component to one instance of a scene.
  57148. */
  57149. register(): void;
  57150. /**
  57151. * Rebuilds the elements related to this component in case of
  57152. * context lost for instance.
  57153. */
  57154. rebuild(): void;
  57155. /**
  57156. * Disposes the component and the associated ressources.
  57157. */
  57158. dispose(): void;
  57159. /**
  57160. * Renders the outline in the canvas.
  57161. * @param subMesh Defines the sumesh to render
  57162. * @param batch Defines the batch of meshes in case of instances
  57163. * @param useOverlay Defines if the rendering is for the overlay or the outline
  57164. */
  57165. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  57166. /**
  57167. * Returns whether or not the outline renderer is ready for a given submesh.
  57168. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  57169. * @param subMesh Defines the submesh to check readyness for
  57170. * @param useInstances Defines wheter wee are trying to render instances or not
  57171. * @returns true if ready otherwise false
  57172. */
  57173. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57174. private _beforeRenderingMesh;
  57175. private _afterRenderingMesh;
  57176. }
  57177. }
  57178. declare module "babylonjs/Rendering/index" {
  57179. export * from "babylonjs/Rendering/boundingBoxRenderer";
  57180. export * from "babylonjs/Rendering/depthRenderer";
  57181. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  57182. export * from "babylonjs/Rendering/edgesRenderer";
  57183. export * from "babylonjs/Rendering/geometryBufferRenderer";
  57184. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  57185. export * from "babylonjs/Rendering/outlineRenderer";
  57186. export * from "babylonjs/Rendering/renderingGroup";
  57187. export * from "babylonjs/Rendering/renderingManager";
  57188. export * from "babylonjs/Rendering/utilityLayerRenderer";
  57189. }
  57190. declare module "babylonjs/Sprites/index" {
  57191. export * from "babylonjs/Sprites/sprite";
  57192. export * from "babylonjs/Sprites/spriteManager";
  57193. export * from "babylonjs/Sprites/spriteSceneComponent";
  57194. }
  57195. declare module "babylonjs/Misc/assetsManager" {
  57196. import { Scene } from "babylonjs/scene";
  57197. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57198. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  57199. import { Skeleton } from "babylonjs/Bones/skeleton";
  57200. import { Observable } from "babylonjs/Misc/observable";
  57201. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57202. import { Texture } from "babylonjs/Materials/Textures/texture";
  57203. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  57204. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  57205. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  57206. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  57207. /**
  57208. * Defines the list of states available for a task inside a AssetsManager
  57209. */
  57210. export enum AssetTaskState {
  57211. /**
  57212. * Initialization
  57213. */
  57214. INIT = 0,
  57215. /**
  57216. * Running
  57217. */
  57218. RUNNING = 1,
  57219. /**
  57220. * Done
  57221. */
  57222. DONE = 2,
  57223. /**
  57224. * Error
  57225. */
  57226. ERROR = 3
  57227. }
  57228. /**
  57229. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  57230. */
  57231. export abstract class AbstractAssetTask {
  57232. /**
  57233. * Task name
  57234. */ name: string;
  57235. /**
  57236. * Callback called when the task is successful
  57237. */
  57238. onSuccess: (task: any) => void;
  57239. /**
  57240. * Callback called when the task is not successful
  57241. */
  57242. onError: (task: any, message?: string, exception?: any) => void;
  57243. /**
  57244. * Creates a new AssetsManager
  57245. * @param name defines the name of the task
  57246. */
  57247. constructor(
  57248. /**
  57249. * Task name
  57250. */ name: string);
  57251. private _isCompleted;
  57252. private _taskState;
  57253. private _errorObject;
  57254. /**
  57255. * Get if the task is completed
  57256. */
  57257. readonly isCompleted: boolean;
  57258. /**
  57259. * Gets the current state of the task
  57260. */
  57261. readonly taskState: AssetTaskState;
  57262. /**
  57263. * Gets the current error object (if task is in error)
  57264. */
  57265. readonly errorObject: {
  57266. message?: string;
  57267. exception?: any;
  57268. };
  57269. /**
  57270. * Internal only
  57271. * @hidden
  57272. */
  57273. _setErrorObject(message?: string, exception?: any): void;
  57274. /**
  57275. * Execute the current task
  57276. * @param scene defines the scene where you want your assets to be loaded
  57277. * @param onSuccess is a callback called when the task is successfully executed
  57278. * @param onError is a callback called if an error occurs
  57279. */
  57280. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57281. /**
  57282. * Execute the current task
  57283. * @param scene defines the scene where you want your assets to be loaded
  57284. * @param onSuccess is a callback called when the task is successfully executed
  57285. * @param onError is a callback called if an error occurs
  57286. */
  57287. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57288. /**
  57289. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  57290. * This can be used with failed tasks that have the reason for failure fixed.
  57291. */
  57292. reset(): void;
  57293. private onErrorCallback;
  57294. private onDoneCallback;
  57295. }
  57296. /**
  57297. * Define the interface used by progress events raised during assets loading
  57298. */
  57299. export interface IAssetsProgressEvent {
  57300. /**
  57301. * Defines the number of remaining tasks to process
  57302. */
  57303. remainingCount: number;
  57304. /**
  57305. * Defines the total number of tasks
  57306. */
  57307. totalCount: number;
  57308. /**
  57309. * Defines the task that was just processed
  57310. */
  57311. task: AbstractAssetTask;
  57312. }
  57313. /**
  57314. * Class used to share progress information about assets loading
  57315. */
  57316. export class AssetsProgressEvent implements IAssetsProgressEvent {
  57317. /**
  57318. * Defines the number of remaining tasks to process
  57319. */
  57320. remainingCount: number;
  57321. /**
  57322. * Defines the total number of tasks
  57323. */
  57324. totalCount: number;
  57325. /**
  57326. * Defines the task that was just processed
  57327. */
  57328. task: AbstractAssetTask;
  57329. /**
  57330. * Creates a AssetsProgressEvent
  57331. * @param remainingCount defines the number of remaining tasks to process
  57332. * @param totalCount defines the total number of tasks
  57333. * @param task defines the task that was just processed
  57334. */
  57335. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  57336. }
  57337. /**
  57338. * Define a task used by AssetsManager to load meshes
  57339. */
  57340. export class MeshAssetTask extends AbstractAssetTask {
  57341. /**
  57342. * Defines the name of the task
  57343. */
  57344. name: string;
  57345. /**
  57346. * Defines the list of mesh's names you want to load
  57347. */
  57348. meshesNames: any;
  57349. /**
  57350. * Defines the root url to use as a base to load your meshes and associated resources
  57351. */
  57352. rootUrl: string;
  57353. /**
  57354. * Defines the filename of the scene to load from
  57355. */
  57356. sceneFilename: string;
  57357. /**
  57358. * Gets the list of loaded meshes
  57359. */
  57360. loadedMeshes: Array<AbstractMesh>;
  57361. /**
  57362. * Gets the list of loaded particle systems
  57363. */
  57364. loadedParticleSystems: Array<IParticleSystem>;
  57365. /**
  57366. * Gets the list of loaded skeletons
  57367. */
  57368. loadedSkeletons: Array<Skeleton>;
  57369. /**
  57370. * Gets the list of loaded animation groups
  57371. */
  57372. loadedAnimationGroups: Array<AnimationGroup>;
  57373. /**
  57374. * Callback called when the task is successful
  57375. */
  57376. onSuccess: (task: MeshAssetTask) => void;
  57377. /**
  57378. * Callback called when the task is successful
  57379. */
  57380. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  57381. /**
  57382. * Creates a new MeshAssetTask
  57383. * @param name defines the name of the task
  57384. * @param meshesNames defines the list of mesh's names you want to load
  57385. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  57386. * @param sceneFilename defines the filename of the scene to load from
  57387. */
  57388. constructor(
  57389. /**
  57390. * Defines the name of the task
  57391. */
  57392. name: string,
  57393. /**
  57394. * Defines the list of mesh's names you want to load
  57395. */
  57396. meshesNames: any,
  57397. /**
  57398. * Defines the root url to use as a base to load your meshes and associated resources
  57399. */
  57400. rootUrl: string,
  57401. /**
  57402. * Defines the filename of the scene to load from
  57403. */
  57404. sceneFilename: string);
  57405. /**
  57406. * Execute the current task
  57407. * @param scene defines the scene where you want your assets to be loaded
  57408. * @param onSuccess is a callback called when the task is successfully executed
  57409. * @param onError is a callback called if an error occurs
  57410. */
  57411. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57412. }
  57413. /**
  57414. * Define a task used by AssetsManager to load text content
  57415. */
  57416. export class TextFileAssetTask extends AbstractAssetTask {
  57417. /**
  57418. * Defines the name of the task
  57419. */
  57420. name: string;
  57421. /**
  57422. * Defines the location of the file to load
  57423. */
  57424. url: string;
  57425. /**
  57426. * Gets the loaded text string
  57427. */
  57428. text: string;
  57429. /**
  57430. * Callback called when the task is successful
  57431. */
  57432. onSuccess: (task: TextFileAssetTask) => void;
  57433. /**
  57434. * Callback called when the task is successful
  57435. */
  57436. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  57437. /**
  57438. * Creates a new TextFileAssetTask object
  57439. * @param name defines the name of the task
  57440. * @param url defines the location of the file to load
  57441. */
  57442. constructor(
  57443. /**
  57444. * Defines the name of the task
  57445. */
  57446. name: string,
  57447. /**
  57448. * Defines the location of the file to load
  57449. */
  57450. url: string);
  57451. /**
  57452. * Execute the current task
  57453. * @param scene defines the scene where you want your assets to be loaded
  57454. * @param onSuccess is a callback called when the task is successfully executed
  57455. * @param onError is a callback called if an error occurs
  57456. */
  57457. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57458. }
  57459. /**
  57460. * Define a task used by AssetsManager to load binary data
  57461. */
  57462. export class BinaryFileAssetTask extends AbstractAssetTask {
  57463. /**
  57464. * Defines the name of the task
  57465. */
  57466. name: string;
  57467. /**
  57468. * Defines the location of the file to load
  57469. */
  57470. url: string;
  57471. /**
  57472. * Gets the lodaded data (as an array buffer)
  57473. */
  57474. data: ArrayBuffer;
  57475. /**
  57476. * Callback called when the task is successful
  57477. */
  57478. onSuccess: (task: BinaryFileAssetTask) => void;
  57479. /**
  57480. * Callback called when the task is successful
  57481. */
  57482. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  57483. /**
  57484. * Creates a new BinaryFileAssetTask object
  57485. * @param name defines the name of the new task
  57486. * @param url defines the location of the file to load
  57487. */
  57488. constructor(
  57489. /**
  57490. * Defines the name of the task
  57491. */
  57492. name: string,
  57493. /**
  57494. * Defines the location of the file to load
  57495. */
  57496. url: string);
  57497. /**
  57498. * Execute the current task
  57499. * @param scene defines the scene where you want your assets to be loaded
  57500. * @param onSuccess is a callback called when the task is successfully executed
  57501. * @param onError is a callback called if an error occurs
  57502. */
  57503. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57504. }
  57505. /**
  57506. * Define a task used by AssetsManager to load images
  57507. */
  57508. export class ImageAssetTask extends AbstractAssetTask {
  57509. /**
  57510. * Defines the name of the task
  57511. */
  57512. name: string;
  57513. /**
  57514. * Defines the location of the image to load
  57515. */
  57516. url: string;
  57517. /**
  57518. * Gets the loaded images
  57519. */
  57520. image: HTMLImageElement;
  57521. /**
  57522. * Callback called when the task is successful
  57523. */
  57524. onSuccess: (task: ImageAssetTask) => void;
  57525. /**
  57526. * Callback called when the task is successful
  57527. */
  57528. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  57529. /**
  57530. * Creates a new ImageAssetTask
  57531. * @param name defines the name of the task
  57532. * @param url defines the location of the image to load
  57533. */
  57534. constructor(
  57535. /**
  57536. * Defines the name of the task
  57537. */
  57538. name: string,
  57539. /**
  57540. * Defines the location of the image to load
  57541. */
  57542. url: string);
  57543. /**
  57544. * Execute the current task
  57545. * @param scene defines the scene where you want your assets to be loaded
  57546. * @param onSuccess is a callback called when the task is successfully executed
  57547. * @param onError is a callback called if an error occurs
  57548. */
  57549. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57550. }
  57551. /**
  57552. * Defines the interface used by texture loading tasks
  57553. */
  57554. export interface ITextureAssetTask<TEX extends BaseTexture> {
  57555. /**
  57556. * Gets the loaded texture
  57557. */
  57558. texture: TEX;
  57559. }
  57560. /**
  57561. * Define a task used by AssetsManager to load 2D textures
  57562. */
  57563. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  57564. /**
  57565. * Defines the name of the task
  57566. */
  57567. name: string;
  57568. /**
  57569. * Defines the location of the file to load
  57570. */
  57571. url: string;
  57572. /**
  57573. * Defines if mipmap should not be generated (default is false)
  57574. */
  57575. noMipmap?: boolean | undefined;
  57576. /**
  57577. * Defines if texture must be inverted on Y axis (default is false)
  57578. */
  57579. invertY?: boolean | undefined;
  57580. /**
  57581. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57582. */
  57583. samplingMode: number;
  57584. /**
  57585. * Gets the loaded texture
  57586. */
  57587. texture: Texture;
  57588. /**
  57589. * Callback called when the task is successful
  57590. */
  57591. onSuccess: (task: TextureAssetTask) => void;
  57592. /**
  57593. * Callback called when the task is successful
  57594. */
  57595. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  57596. /**
  57597. * Creates a new TextureAssetTask object
  57598. * @param name defines the name of the task
  57599. * @param url defines the location of the file to load
  57600. * @param noMipmap defines if mipmap should not be generated (default is false)
  57601. * @param invertY defines if texture must be inverted on Y axis (default is false)
  57602. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57603. */
  57604. constructor(
  57605. /**
  57606. * Defines the name of the task
  57607. */
  57608. name: string,
  57609. /**
  57610. * Defines the location of the file to load
  57611. */
  57612. url: string,
  57613. /**
  57614. * Defines if mipmap should not be generated (default is false)
  57615. */
  57616. noMipmap?: boolean | undefined,
  57617. /**
  57618. * Defines if texture must be inverted on Y axis (default is false)
  57619. */
  57620. invertY?: boolean | undefined,
  57621. /**
  57622. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57623. */
  57624. samplingMode?: number);
  57625. /**
  57626. * Execute the current task
  57627. * @param scene defines the scene where you want your assets to be loaded
  57628. * @param onSuccess is a callback called when the task is successfully executed
  57629. * @param onError is a callback called if an error occurs
  57630. */
  57631. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57632. }
  57633. /**
  57634. * Define a task used by AssetsManager to load cube textures
  57635. */
  57636. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  57637. /**
  57638. * Defines the name of the task
  57639. */
  57640. name: string;
  57641. /**
  57642. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57643. */
  57644. url: string;
  57645. /**
  57646. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57647. */
  57648. extensions?: string[] | undefined;
  57649. /**
  57650. * Defines if mipmaps should not be generated (default is false)
  57651. */
  57652. noMipmap?: boolean | undefined;
  57653. /**
  57654. * Defines the explicit list of files (undefined by default)
  57655. */
  57656. files?: string[] | undefined;
  57657. /**
  57658. * Gets the loaded texture
  57659. */
  57660. texture: CubeTexture;
  57661. /**
  57662. * Callback called when the task is successful
  57663. */
  57664. onSuccess: (task: CubeTextureAssetTask) => void;
  57665. /**
  57666. * Callback called when the task is successful
  57667. */
  57668. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  57669. /**
  57670. * Creates a new CubeTextureAssetTask
  57671. * @param name defines the name of the task
  57672. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57673. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57674. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57675. * @param files defines the explicit list of files (undefined by default)
  57676. */
  57677. constructor(
  57678. /**
  57679. * Defines the name of the task
  57680. */
  57681. name: string,
  57682. /**
  57683. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57684. */
  57685. url: string,
  57686. /**
  57687. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57688. */
  57689. extensions?: string[] | undefined,
  57690. /**
  57691. * Defines if mipmaps should not be generated (default is false)
  57692. */
  57693. noMipmap?: boolean | undefined,
  57694. /**
  57695. * Defines the explicit list of files (undefined by default)
  57696. */
  57697. files?: string[] | undefined);
  57698. /**
  57699. * Execute the current task
  57700. * @param scene defines the scene where you want your assets to be loaded
  57701. * @param onSuccess is a callback called when the task is successfully executed
  57702. * @param onError is a callback called if an error occurs
  57703. */
  57704. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57705. }
  57706. /**
  57707. * Define a task used by AssetsManager to load HDR cube textures
  57708. */
  57709. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  57710. /**
  57711. * Defines the name of the task
  57712. */
  57713. name: string;
  57714. /**
  57715. * Defines the location of the file to load
  57716. */
  57717. url: string;
  57718. /**
  57719. * Defines the desired size (the more it increases the longer the generation will be)
  57720. */
  57721. size: number;
  57722. /**
  57723. * Defines if mipmaps should not be generated (default is false)
  57724. */
  57725. noMipmap: boolean;
  57726. /**
  57727. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57728. */
  57729. generateHarmonics: boolean;
  57730. /**
  57731. * 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)
  57732. */
  57733. gammaSpace: boolean;
  57734. /**
  57735. * Internal Use Only
  57736. */
  57737. reserved: boolean;
  57738. /**
  57739. * Gets the loaded texture
  57740. */
  57741. texture: HDRCubeTexture;
  57742. /**
  57743. * Callback called when the task is successful
  57744. */
  57745. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  57746. /**
  57747. * Callback called when the task is successful
  57748. */
  57749. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  57750. /**
  57751. * Creates a new HDRCubeTextureAssetTask object
  57752. * @param name defines the name of the task
  57753. * @param url defines the location of the file to load
  57754. * @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.
  57755. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57756. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57757. * @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)
  57758. * @param reserved Internal use only
  57759. */
  57760. constructor(
  57761. /**
  57762. * Defines the name of the task
  57763. */
  57764. name: string,
  57765. /**
  57766. * Defines the location of the file to load
  57767. */
  57768. url: string,
  57769. /**
  57770. * Defines the desired size (the more it increases the longer the generation will be)
  57771. */
  57772. size: number,
  57773. /**
  57774. * Defines if mipmaps should not be generated (default is false)
  57775. */
  57776. noMipmap?: boolean,
  57777. /**
  57778. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57779. */
  57780. generateHarmonics?: boolean,
  57781. /**
  57782. * 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)
  57783. */
  57784. gammaSpace?: boolean,
  57785. /**
  57786. * Internal Use Only
  57787. */
  57788. reserved?: boolean);
  57789. /**
  57790. * Execute the current task
  57791. * @param scene defines the scene where you want your assets to be loaded
  57792. * @param onSuccess is a callback called when the task is successfully executed
  57793. * @param onError is a callback called if an error occurs
  57794. */
  57795. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57796. }
  57797. /**
  57798. * Define a task used by AssetsManager to load Equirectangular cube textures
  57799. */
  57800. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  57801. /**
  57802. * Defines the name of the task
  57803. */
  57804. name: string;
  57805. /**
  57806. * Defines the location of the file to load
  57807. */
  57808. url: string;
  57809. /**
  57810. * Defines the desired size (the more it increases the longer the generation will be)
  57811. */
  57812. size: number;
  57813. /**
  57814. * Defines if mipmaps should not be generated (default is false)
  57815. */
  57816. noMipmap: boolean;
  57817. /**
  57818. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  57819. * but the standard material would require them in Gamma space) (default is true)
  57820. */
  57821. gammaSpace: boolean;
  57822. /**
  57823. * Gets the loaded texture
  57824. */
  57825. texture: EquiRectangularCubeTexture;
  57826. /**
  57827. * Callback called when the task is successful
  57828. */
  57829. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  57830. /**
  57831. * Callback called when the task is successful
  57832. */
  57833. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  57834. /**
  57835. * Creates a new EquiRectangularCubeTextureAssetTask object
  57836. * @param name defines the name of the task
  57837. * @param url defines the location of the file to load
  57838. * @param size defines the desired size (the more it increases the longer the generation will be)
  57839. * If the size is omitted this implies you are using a preprocessed cubemap.
  57840. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57841. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  57842. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  57843. * (default is true)
  57844. */
  57845. constructor(
  57846. /**
  57847. * Defines the name of the task
  57848. */
  57849. name: string,
  57850. /**
  57851. * Defines the location of the file to load
  57852. */
  57853. url: string,
  57854. /**
  57855. * Defines the desired size (the more it increases the longer the generation will be)
  57856. */
  57857. size: number,
  57858. /**
  57859. * Defines if mipmaps should not be generated (default is false)
  57860. */
  57861. noMipmap?: boolean,
  57862. /**
  57863. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  57864. * but the standard material would require them in Gamma space) (default is true)
  57865. */
  57866. gammaSpace?: boolean);
  57867. /**
  57868. * Execute the current task
  57869. * @param scene defines the scene where you want your assets to be loaded
  57870. * @param onSuccess is a callback called when the task is successfully executed
  57871. * @param onError is a callback called if an error occurs
  57872. */
  57873. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57874. }
  57875. /**
  57876. * This class can be used to easily import assets into a scene
  57877. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  57878. */
  57879. export class AssetsManager {
  57880. private _scene;
  57881. private _isLoading;
  57882. protected _tasks: AbstractAssetTask[];
  57883. protected _waitingTasksCount: number;
  57884. protected _totalTasksCount: number;
  57885. /**
  57886. * Callback called when all tasks are processed
  57887. */
  57888. onFinish: (tasks: AbstractAssetTask[]) => void;
  57889. /**
  57890. * Callback called when a task is successful
  57891. */
  57892. onTaskSuccess: (task: AbstractAssetTask) => void;
  57893. /**
  57894. * Callback called when a task had an error
  57895. */
  57896. onTaskError: (task: AbstractAssetTask) => void;
  57897. /**
  57898. * Callback called when a task is done (whatever the result is)
  57899. */
  57900. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  57901. /**
  57902. * Observable called when all tasks are processed
  57903. */
  57904. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  57905. /**
  57906. * Observable called when a task had an error
  57907. */
  57908. onTaskErrorObservable: Observable<AbstractAssetTask>;
  57909. /**
  57910. * Observable called when all tasks were executed
  57911. */
  57912. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  57913. /**
  57914. * Observable called when a task is done (whatever the result is)
  57915. */
  57916. onProgressObservable: Observable<IAssetsProgressEvent>;
  57917. /**
  57918. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  57919. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  57920. */
  57921. useDefaultLoadingScreen: boolean;
  57922. /**
  57923. * Creates a new AssetsManager
  57924. * @param scene defines the scene to work on
  57925. */
  57926. constructor(scene: Scene);
  57927. /**
  57928. * Add a MeshAssetTask to the list of active tasks
  57929. * @param taskName defines the name of the new task
  57930. * @param meshesNames defines the name of meshes to load
  57931. * @param rootUrl defines the root url to use to locate files
  57932. * @param sceneFilename defines the filename of the scene file
  57933. * @returns a new MeshAssetTask object
  57934. */
  57935. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  57936. /**
  57937. * Add a TextFileAssetTask to the list of active tasks
  57938. * @param taskName defines the name of the new task
  57939. * @param url defines the url of the file to load
  57940. * @returns a new TextFileAssetTask object
  57941. */
  57942. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  57943. /**
  57944. * Add a BinaryFileAssetTask to the list of active tasks
  57945. * @param taskName defines the name of the new task
  57946. * @param url defines the url of the file to load
  57947. * @returns a new BinaryFileAssetTask object
  57948. */
  57949. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  57950. /**
  57951. * Add a ImageAssetTask to the list of active tasks
  57952. * @param taskName defines the name of the new task
  57953. * @param url defines the url of the file to load
  57954. * @returns a new ImageAssetTask object
  57955. */
  57956. addImageTask(taskName: string, url: string): ImageAssetTask;
  57957. /**
  57958. * Add a TextureAssetTask to the list of active tasks
  57959. * @param taskName defines the name of the new task
  57960. * @param url defines the url of the file to load
  57961. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57962. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  57963. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57964. * @returns a new TextureAssetTask object
  57965. */
  57966. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  57967. /**
  57968. * Add a CubeTextureAssetTask to the list of active tasks
  57969. * @param taskName defines the name of the new task
  57970. * @param url defines the url of the file to load
  57971. * @param extensions defines the extension to use to load the cube map (can be null)
  57972. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57973. * @param files defines the list of files to load (can be null)
  57974. * @returns a new CubeTextureAssetTask object
  57975. */
  57976. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  57977. /**
  57978. *
  57979. * Add a HDRCubeTextureAssetTask to the list of active tasks
  57980. * @param taskName defines the name of the new task
  57981. * @param url defines the url of the file to load
  57982. * @param size defines the size you want for the cubemap (can be null)
  57983. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57984. * @param generateHarmonics defines if you want to automatically generate (true by default)
  57985. * @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)
  57986. * @param reserved Internal use only
  57987. * @returns a new HDRCubeTextureAssetTask object
  57988. */
  57989. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  57990. /**
  57991. *
  57992. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  57993. * @param taskName defines the name of the new task
  57994. * @param url defines the url of the file to load
  57995. * @param size defines the size you want for the cubemap (can be null)
  57996. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57997. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  57998. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  57999. * @returns a new EquiRectangularCubeTextureAssetTask object
  58000. */
  58001. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  58002. /**
  58003. * Remove a task from the assets manager.
  58004. * @param task the task to remove
  58005. */
  58006. removeTask(task: AbstractAssetTask): void;
  58007. private _decreaseWaitingTasksCount;
  58008. private _runTask;
  58009. /**
  58010. * Reset the AssetsManager and remove all tasks
  58011. * @return the current instance of the AssetsManager
  58012. */
  58013. reset(): AssetsManager;
  58014. /**
  58015. * Start the loading process
  58016. * @return the current instance of the AssetsManager
  58017. */
  58018. load(): AssetsManager;
  58019. /**
  58020. * Start the loading process as an async operation
  58021. * @return a promise returning the list of failed tasks
  58022. */
  58023. loadAsync(): Promise<void>;
  58024. }
  58025. }
  58026. declare module "babylonjs/Misc/deferred" {
  58027. /**
  58028. * Wrapper class for promise with external resolve and reject.
  58029. */
  58030. export class Deferred<T> {
  58031. /**
  58032. * The promise associated with this deferred object.
  58033. */
  58034. readonly promise: Promise<T>;
  58035. private _resolve;
  58036. private _reject;
  58037. /**
  58038. * The resolve method of the promise associated with this deferred object.
  58039. */
  58040. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  58041. /**
  58042. * The reject method of the promise associated with this deferred object.
  58043. */
  58044. readonly reject: (reason?: any) => void;
  58045. /**
  58046. * Constructor for this deferred object.
  58047. */
  58048. constructor();
  58049. }
  58050. }
  58051. declare module "babylonjs/Misc/meshExploder" {
  58052. import { Mesh } from "babylonjs/Meshes/mesh";
  58053. /**
  58054. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  58055. */
  58056. export class MeshExploder {
  58057. private _centerMesh;
  58058. private _meshes;
  58059. private _meshesOrigins;
  58060. private _toCenterVectors;
  58061. private _scaledDirection;
  58062. private _newPosition;
  58063. private _centerPosition;
  58064. /**
  58065. * Explodes meshes from a center mesh.
  58066. * @param meshes The meshes to explode.
  58067. * @param centerMesh The mesh to be center of explosion.
  58068. */
  58069. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  58070. private _setCenterMesh;
  58071. /**
  58072. * Get class name
  58073. * @returns "MeshExploder"
  58074. */
  58075. getClassName(): string;
  58076. /**
  58077. * "Exploded meshes"
  58078. * @returns Array of meshes with the centerMesh at index 0.
  58079. */
  58080. getMeshes(): Array<Mesh>;
  58081. /**
  58082. * Explodes meshes giving a specific direction
  58083. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  58084. */
  58085. explode(direction?: number): void;
  58086. }
  58087. }
  58088. declare module "babylonjs/Misc/filesInput" {
  58089. import { Engine } from "babylonjs/Engines/engine";
  58090. import { Scene } from "babylonjs/scene";
  58091. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  58092. /**
  58093. * Class used to help managing file picking and drag'n'drop
  58094. */
  58095. export class FilesInput {
  58096. /**
  58097. * List of files ready to be loaded
  58098. */
  58099. static readonly FilesToLoad: {
  58100. [key: string]: File;
  58101. };
  58102. /**
  58103. * Callback called when a file is processed
  58104. */
  58105. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  58106. private _engine;
  58107. private _currentScene;
  58108. private _sceneLoadedCallback;
  58109. private _progressCallback;
  58110. private _additionalRenderLoopLogicCallback;
  58111. private _textureLoadingCallback;
  58112. private _startingProcessingFilesCallback;
  58113. private _onReloadCallback;
  58114. private _errorCallback;
  58115. private _elementToMonitor;
  58116. private _sceneFileToLoad;
  58117. private _filesToLoad;
  58118. /**
  58119. * Creates a new FilesInput
  58120. * @param engine defines the rendering engine
  58121. * @param scene defines the hosting scene
  58122. * @param sceneLoadedCallback callback called when scene is loaded
  58123. * @param progressCallback callback called to track progress
  58124. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  58125. * @param textureLoadingCallback callback called when a texture is loading
  58126. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  58127. * @param onReloadCallback callback called when a reload is requested
  58128. * @param errorCallback callback call if an error occurs
  58129. */
  58130. 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);
  58131. private _dragEnterHandler;
  58132. private _dragOverHandler;
  58133. private _dropHandler;
  58134. /**
  58135. * Calls this function to listen to drag'n'drop events on a specific DOM element
  58136. * @param elementToMonitor defines the DOM element to track
  58137. */
  58138. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  58139. /**
  58140. * Release all associated resources
  58141. */
  58142. dispose(): void;
  58143. private renderFunction;
  58144. private drag;
  58145. private drop;
  58146. private _traverseFolder;
  58147. private _processFiles;
  58148. /**
  58149. * Load files from a drop event
  58150. * @param event defines the drop event to use as source
  58151. */
  58152. loadFiles(event: any): void;
  58153. private _processReload;
  58154. /**
  58155. * Reload the current scene from the loaded files
  58156. */
  58157. reload(): void;
  58158. }
  58159. }
  58160. declare module "babylonjs/Misc/HighDynamicRange/index" {
  58161. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  58162. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  58163. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  58164. }
  58165. declare module "babylonjs/Misc/sceneOptimizer" {
  58166. import { Scene, IDisposable } from "babylonjs/scene";
  58167. import { Observable } from "babylonjs/Misc/observable";
  58168. /**
  58169. * Defines the root class used to create scene optimization to use with SceneOptimizer
  58170. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58171. */
  58172. export class SceneOptimization {
  58173. /**
  58174. * Defines the priority of this optimization (0 by default which means first in the list)
  58175. */
  58176. priority: number;
  58177. /**
  58178. * Gets a string describing the action executed by the current optimization
  58179. * @returns description string
  58180. */
  58181. getDescription(): string;
  58182. /**
  58183. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58184. * @param scene defines the current scene where to apply this optimization
  58185. * @param optimizer defines the current optimizer
  58186. * @returns true if everything that can be done was applied
  58187. */
  58188. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58189. /**
  58190. * Creates the SceneOptimization object
  58191. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58192. * @param desc defines the description associated with the optimization
  58193. */
  58194. constructor(
  58195. /**
  58196. * Defines the priority of this optimization (0 by default which means first in the list)
  58197. */
  58198. priority?: number);
  58199. }
  58200. /**
  58201. * Defines an optimization used to reduce the size of render target textures
  58202. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58203. */
  58204. export class TextureOptimization extends SceneOptimization {
  58205. /**
  58206. * Defines the priority of this optimization (0 by default which means first in the list)
  58207. */
  58208. priority: number;
  58209. /**
  58210. * 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
  58211. */
  58212. maximumSize: number;
  58213. /**
  58214. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58215. */
  58216. step: number;
  58217. /**
  58218. * Gets a string describing the action executed by the current optimization
  58219. * @returns description string
  58220. */
  58221. getDescription(): string;
  58222. /**
  58223. * Creates the TextureOptimization object
  58224. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58225. * @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
  58226. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58227. */
  58228. constructor(
  58229. /**
  58230. * Defines the priority of this optimization (0 by default which means first in the list)
  58231. */
  58232. priority?: number,
  58233. /**
  58234. * 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
  58235. */
  58236. maximumSize?: number,
  58237. /**
  58238. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58239. */
  58240. step?: number);
  58241. /**
  58242. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58243. * @param scene defines the current scene where to apply this optimization
  58244. * @param optimizer defines the current optimizer
  58245. * @returns true if everything that can be done was applied
  58246. */
  58247. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58248. }
  58249. /**
  58250. * Defines an optimization used to increase or decrease the rendering resolution
  58251. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58252. */
  58253. export class HardwareScalingOptimization extends SceneOptimization {
  58254. /**
  58255. * Defines the priority of this optimization (0 by default which means first in the list)
  58256. */
  58257. priority: number;
  58258. /**
  58259. * Defines the maximum scale to use (2 by default)
  58260. */
  58261. maximumScale: number;
  58262. /**
  58263. * Defines the step to use between two passes (0.5 by default)
  58264. */
  58265. step: number;
  58266. private _currentScale;
  58267. private _directionOffset;
  58268. /**
  58269. * Gets a string describing the action executed by the current optimization
  58270. * @return description string
  58271. */
  58272. getDescription(): string;
  58273. /**
  58274. * Creates the HardwareScalingOptimization object
  58275. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58276. * @param maximumScale defines the maximum scale to use (2 by default)
  58277. * @param step defines the step to use between two passes (0.5 by default)
  58278. */
  58279. constructor(
  58280. /**
  58281. * Defines the priority of this optimization (0 by default which means first in the list)
  58282. */
  58283. priority?: number,
  58284. /**
  58285. * Defines the maximum scale to use (2 by default)
  58286. */
  58287. maximumScale?: number,
  58288. /**
  58289. * Defines the step to use between two passes (0.5 by default)
  58290. */
  58291. step?: number);
  58292. /**
  58293. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58294. * @param scene defines the current scene where to apply this optimization
  58295. * @param optimizer defines the current optimizer
  58296. * @returns true if everything that can be done was applied
  58297. */
  58298. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58299. }
  58300. /**
  58301. * Defines an optimization used to remove shadows
  58302. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58303. */
  58304. export class ShadowsOptimization extends SceneOptimization {
  58305. /**
  58306. * Gets a string describing the action executed by the current optimization
  58307. * @return description string
  58308. */
  58309. getDescription(): string;
  58310. /**
  58311. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58312. * @param scene defines the current scene where to apply this optimization
  58313. * @param optimizer defines the current optimizer
  58314. * @returns true if everything that can be done was applied
  58315. */
  58316. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58317. }
  58318. /**
  58319. * Defines an optimization used to turn post-processes off
  58320. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58321. */
  58322. export class PostProcessesOptimization extends SceneOptimization {
  58323. /**
  58324. * Gets a string describing the action executed by the current optimization
  58325. * @return description string
  58326. */
  58327. getDescription(): string;
  58328. /**
  58329. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58330. * @param scene defines the current scene where to apply this optimization
  58331. * @param optimizer defines the current optimizer
  58332. * @returns true if everything that can be done was applied
  58333. */
  58334. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58335. }
  58336. /**
  58337. * Defines an optimization used to turn lens flares off
  58338. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58339. */
  58340. export class LensFlaresOptimization extends SceneOptimization {
  58341. /**
  58342. * Gets a string describing the action executed by the current optimization
  58343. * @return description string
  58344. */
  58345. getDescription(): string;
  58346. /**
  58347. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58348. * @param scene defines the current scene where to apply this optimization
  58349. * @param optimizer defines the current optimizer
  58350. * @returns true if everything that can be done was applied
  58351. */
  58352. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58353. }
  58354. /**
  58355. * Defines an optimization based on user defined callback.
  58356. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58357. */
  58358. export class CustomOptimization extends SceneOptimization {
  58359. /**
  58360. * Callback called to apply the custom optimization.
  58361. */
  58362. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  58363. /**
  58364. * Callback called to get custom description
  58365. */
  58366. onGetDescription: () => string;
  58367. /**
  58368. * Gets a string describing the action executed by the current optimization
  58369. * @returns description string
  58370. */
  58371. getDescription(): string;
  58372. /**
  58373. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58374. * @param scene defines the current scene where to apply this optimization
  58375. * @param optimizer defines the current optimizer
  58376. * @returns true if everything that can be done was applied
  58377. */
  58378. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58379. }
  58380. /**
  58381. * Defines an optimization used to turn particles off
  58382. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58383. */
  58384. export class ParticlesOptimization extends SceneOptimization {
  58385. /**
  58386. * Gets a string describing the action executed by the current optimization
  58387. * @return description string
  58388. */
  58389. getDescription(): string;
  58390. /**
  58391. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58392. * @param scene defines the current scene where to apply this optimization
  58393. * @param optimizer defines the current optimizer
  58394. * @returns true if everything that can be done was applied
  58395. */
  58396. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58397. }
  58398. /**
  58399. * Defines an optimization used to turn render targets off
  58400. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58401. */
  58402. export class RenderTargetsOptimization extends SceneOptimization {
  58403. /**
  58404. * Gets a string describing the action executed by the current optimization
  58405. * @return description string
  58406. */
  58407. getDescription(): string;
  58408. /**
  58409. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58410. * @param scene defines the current scene where to apply this optimization
  58411. * @param optimizer defines the current optimizer
  58412. * @returns true if everything that can be done was applied
  58413. */
  58414. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58415. }
  58416. /**
  58417. * Defines an optimization used to merge meshes with compatible materials
  58418. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58419. */
  58420. export class MergeMeshesOptimization extends SceneOptimization {
  58421. private static _UpdateSelectionTree;
  58422. /**
  58423. * Gets or sets a boolean which defines if optimization octree has to be updated
  58424. */
  58425. /**
  58426. * Gets or sets a boolean which defines if optimization octree has to be updated
  58427. */
  58428. static UpdateSelectionTree: boolean;
  58429. /**
  58430. * Gets a string describing the action executed by the current optimization
  58431. * @return description string
  58432. */
  58433. getDescription(): string;
  58434. private _canBeMerged;
  58435. /**
  58436. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58437. * @param scene defines the current scene where to apply this optimization
  58438. * @param optimizer defines the current optimizer
  58439. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  58440. * @returns true if everything that can be done was applied
  58441. */
  58442. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  58443. }
  58444. /**
  58445. * Defines a list of options used by SceneOptimizer
  58446. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58447. */
  58448. export class SceneOptimizerOptions {
  58449. /**
  58450. * Defines the target frame rate to reach (60 by default)
  58451. */
  58452. targetFrameRate: number;
  58453. /**
  58454. * Defines the interval between two checkes (2000ms by default)
  58455. */
  58456. trackerDuration: number;
  58457. /**
  58458. * Gets the list of optimizations to apply
  58459. */
  58460. optimizations: SceneOptimization[];
  58461. /**
  58462. * Creates a new list of options used by SceneOptimizer
  58463. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  58464. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  58465. */
  58466. constructor(
  58467. /**
  58468. * Defines the target frame rate to reach (60 by default)
  58469. */
  58470. targetFrameRate?: number,
  58471. /**
  58472. * Defines the interval between two checkes (2000ms by default)
  58473. */
  58474. trackerDuration?: number);
  58475. /**
  58476. * Add a new optimization
  58477. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  58478. * @returns the current SceneOptimizerOptions
  58479. */
  58480. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  58481. /**
  58482. * Add a new custom optimization
  58483. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  58484. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  58485. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58486. * @returns the current SceneOptimizerOptions
  58487. */
  58488. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  58489. /**
  58490. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  58491. * @param targetFrameRate defines the target frame rate (60 by default)
  58492. * @returns a SceneOptimizerOptions object
  58493. */
  58494. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58495. /**
  58496. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  58497. * @param targetFrameRate defines the target frame rate (60 by default)
  58498. * @returns a SceneOptimizerOptions object
  58499. */
  58500. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58501. /**
  58502. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  58503. * @param targetFrameRate defines the target frame rate (60 by default)
  58504. * @returns a SceneOptimizerOptions object
  58505. */
  58506. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58507. }
  58508. /**
  58509. * Class used to run optimizations in order to reach a target frame rate
  58510. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58511. */
  58512. export class SceneOptimizer implements IDisposable {
  58513. private _isRunning;
  58514. private _options;
  58515. private _scene;
  58516. private _currentPriorityLevel;
  58517. private _targetFrameRate;
  58518. private _trackerDuration;
  58519. private _currentFrameRate;
  58520. private _sceneDisposeObserver;
  58521. private _improvementMode;
  58522. /**
  58523. * Defines an observable called when the optimizer reaches the target frame rate
  58524. */
  58525. onSuccessObservable: Observable<SceneOptimizer>;
  58526. /**
  58527. * Defines an observable called when the optimizer enables an optimization
  58528. */
  58529. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  58530. /**
  58531. * Defines an observable called when the optimizer is not able to reach the target frame rate
  58532. */
  58533. onFailureObservable: Observable<SceneOptimizer>;
  58534. /**
  58535. * Gets a boolean indicating if the optimizer is in improvement mode
  58536. */
  58537. readonly isInImprovementMode: boolean;
  58538. /**
  58539. * Gets the current priority level (0 at start)
  58540. */
  58541. readonly currentPriorityLevel: number;
  58542. /**
  58543. * Gets the current frame rate checked by the SceneOptimizer
  58544. */
  58545. readonly currentFrameRate: number;
  58546. /**
  58547. * Gets or sets the current target frame rate (60 by default)
  58548. */
  58549. /**
  58550. * Gets or sets the current target frame rate (60 by default)
  58551. */
  58552. targetFrameRate: number;
  58553. /**
  58554. * Gets or sets the current interval between two checks (every 2000ms by default)
  58555. */
  58556. /**
  58557. * Gets or sets the current interval between two checks (every 2000ms by default)
  58558. */
  58559. trackerDuration: number;
  58560. /**
  58561. * Gets the list of active optimizations
  58562. */
  58563. readonly optimizations: SceneOptimization[];
  58564. /**
  58565. * Creates a new SceneOptimizer
  58566. * @param scene defines the scene to work on
  58567. * @param options defines the options to use with the SceneOptimizer
  58568. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  58569. * @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)
  58570. */
  58571. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  58572. /**
  58573. * Stops the current optimizer
  58574. */
  58575. stop(): void;
  58576. /**
  58577. * Reset the optimizer to initial step (current priority level = 0)
  58578. */
  58579. reset(): void;
  58580. /**
  58581. * Start the optimizer. By default it will try to reach a specific framerate
  58582. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  58583. */
  58584. start(): void;
  58585. private _checkCurrentState;
  58586. /**
  58587. * Release all resources
  58588. */
  58589. dispose(): void;
  58590. /**
  58591. * Helper function to create a SceneOptimizer with one single line of code
  58592. * @param scene defines the scene to work on
  58593. * @param options defines the options to use with the SceneOptimizer
  58594. * @param onSuccess defines a callback to call on success
  58595. * @param onFailure defines a callback to call on failure
  58596. * @returns the new SceneOptimizer object
  58597. */
  58598. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  58599. }
  58600. }
  58601. declare module "babylonjs/Misc/sceneSerializer" {
  58602. import { Scene } from "babylonjs/scene";
  58603. /**
  58604. * Class used to serialize a scene into a string
  58605. */
  58606. export class SceneSerializer {
  58607. /**
  58608. * Clear cache used by a previous serialization
  58609. */
  58610. static ClearCache(): void;
  58611. /**
  58612. * Serialize a scene into a JSON compatible object
  58613. * @param scene defines the scene to serialize
  58614. * @returns a JSON compatible object
  58615. */
  58616. static Serialize(scene: Scene): any;
  58617. /**
  58618. * Serialize a mesh into a JSON compatible object
  58619. * @param toSerialize defines the mesh to serialize
  58620. * @param withParents defines if parents must be serialized as well
  58621. * @param withChildren defines if children must be serialized as well
  58622. * @returns a JSON compatible object
  58623. */
  58624. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  58625. }
  58626. }
  58627. declare module "babylonjs/Misc/textureTools" {
  58628. import { Texture } from "babylonjs/Materials/Textures/texture";
  58629. /**
  58630. * Class used to host texture specific utilities
  58631. */
  58632. export class TextureTools {
  58633. /**
  58634. * Uses the GPU to create a copy texture rescaled at a given size
  58635. * @param texture Texture to copy from
  58636. * @param width defines the desired width
  58637. * @param height defines the desired height
  58638. * @param useBilinearMode defines if bilinear mode has to be used
  58639. * @return the generated texture
  58640. */
  58641. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  58642. }
  58643. }
  58644. declare module "babylonjs/Misc/videoRecorder" {
  58645. import { Nullable } from "babylonjs/types";
  58646. import { Engine } from "babylonjs/Engines/engine";
  58647. /**
  58648. * This represents the different options avilable for the video capture.
  58649. */
  58650. export interface VideoRecorderOptions {
  58651. /** Defines the mime type of the video */
  58652. mimeType: string;
  58653. /** Defines the video the video should be recorded at */
  58654. fps: number;
  58655. /** Defines the chunk size for the recording data */
  58656. recordChunckSize: number;
  58657. /** The audio tracks to attach to the record */
  58658. audioTracks?: MediaStreamTrack[];
  58659. }
  58660. /**
  58661. * This can helps recording videos from BabylonJS.
  58662. * This is based on the available WebRTC functionalities of the browser.
  58663. *
  58664. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  58665. */
  58666. export class VideoRecorder {
  58667. private static readonly _defaultOptions;
  58668. /**
  58669. * Returns wehther or not the VideoRecorder is available in your browser.
  58670. * @param engine Defines the Babylon Engine to check the support for
  58671. * @returns true if supported otherwise false
  58672. */
  58673. static IsSupported(engine: Engine): boolean;
  58674. private readonly _options;
  58675. private _canvas;
  58676. private _mediaRecorder;
  58677. private _recordedChunks;
  58678. private _fileName;
  58679. private _resolve;
  58680. private _reject;
  58681. /**
  58682. * True wether a recording is already in progress.
  58683. */
  58684. readonly isRecording: boolean;
  58685. /**
  58686. * Create a new VideoCapture object which can help converting what you see in Babylon to
  58687. * a video file.
  58688. * @param engine Defines the BabylonJS Engine you wish to record
  58689. * @param options Defines options that can be used to customized the capture
  58690. */
  58691. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  58692. /**
  58693. * Stops the current recording before the default capture timeout passed in the startRecording
  58694. * functions.
  58695. */
  58696. stopRecording(): void;
  58697. /**
  58698. * Starts recording the canvas for a max duration specified in parameters.
  58699. * @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.
  58700. * @param maxDuration Defines the maximum recording time in seconds.
  58701. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  58702. * @return a promise callback at the end of the recording with the video data in Blob.
  58703. */
  58704. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  58705. /**
  58706. * Releases internal resources used during the recording.
  58707. */
  58708. dispose(): void;
  58709. private _handleDataAvailable;
  58710. private _handleError;
  58711. private _handleStop;
  58712. }
  58713. }
  58714. declare module "babylonjs/Misc/screenshotTools" {
  58715. import { Camera } from "babylonjs/Cameras/camera";
  58716. import { Engine } from "babylonjs/Engines/engine";
  58717. /**
  58718. * Class containing a set of static utilities functions for screenshots
  58719. */
  58720. export class ScreenshotTools {
  58721. /**
  58722. * Captures a screenshot of the current rendering
  58723. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  58724. * @param engine defines the rendering engine
  58725. * @param camera defines the source camera
  58726. * @param size This parameter can be set to a single number or to an object with the
  58727. * following (optional) properties: precision, width, height. If a single number is passed,
  58728. * it will be used for both width and height. If an object is passed, the screenshot size
  58729. * will be derived from the parameters. The precision property is a multiplier allowing
  58730. * rendering at a higher or lower resolution
  58731. * @param successCallback defines the callback receives a single parameter which contains the
  58732. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  58733. * src parameter of an <img> to display it
  58734. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  58735. * Check your browser for supported MIME types
  58736. */
  58737. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  58738. /**
  58739. * Generates an image screenshot from the specified camera.
  58740. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  58741. * @param engine The engine to use for rendering
  58742. * @param camera The camera to use for rendering
  58743. * @param size This parameter can be set to a single number or to an object with the
  58744. * following (optional) properties: precision, width, height. If a single number is passed,
  58745. * it will be used for both width and height. If an object is passed, the screenshot size
  58746. * will be derived from the parameters. The precision property is a multiplier allowing
  58747. * rendering at a higher or lower resolution
  58748. * @param successCallback The callback receives a single parameter which contains the
  58749. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  58750. * src parameter of an <img> to display it
  58751. * @param mimeType The MIME type of the screenshot image (default: image/png).
  58752. * Check your browser for supported MIME types
  58753. * @param samples Texture samples (default: 1)
  58754. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  58755. * @param fileName A name for for the downloaded file.
  58756. */
  58757. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  58758. }
  58759. }
  58760. declare module "babylonjs/Misc/index" {
  58761. export * from "babylonjs/Misc/andOrNotEvaluator";
  58762. export * from "babylonjs/Misc/assetsManager";
  58763. export * from "babylonjs/Misc/dds";
  58764. export * from "babylonjs/Misc/decorators";
  58765. export * from "babylonjs/Misc/deferred";
  58766. export * from "babylonjs/Misc/environmentTextureTools";
  58767. export * from "babylonjs/Misc/meshExploder";
  58768. export * from "babylonjs/Misc/filesInput";
  58769. export * from "babylonjs/Misc/HighDynamicRange/index";
  58770. export * from "babylonjs/Misc/khronosTextureContainer";
  58771. export * from "babylonjs/Misc/observable";
  58772. export * from "babylonjs/Misc/performanceMonitor";
  58773. export * from "babylonjs/Misc/promise";
  58774. export * from "babylonjs/Misc/sceneOptimizer";
  58775. export * from "babylonjs/Misc/sceneSerializer";
  58776. export * from "babylonjs/Misc/smartArray";
  58777. export * from "babylonjs/Misc/stringDictionary";
  58778. export * from "babylonjs/Misc/tags";
  58779. export * from "babylonjs/Misc/textureTools";
  58780. export * from "babylonjs/Misc/tga";
  58781. export * from "babylonjs/Misc/tools";
  58782. export * from "babylonjs/Misc/videoRecorder";
  58783. export * from "babylonjs/Misc/virtualJoystick";
  58784. export * from "babylonjs/Misc/workerPool";
  58785. export * from "babylonjs/Misc/logger";
  58786. export * from "babylonjs/Misc/typeStore";
  58787. export * from "babylonjs/Misc/filesInputStore";
  58788. export * from "babylonjs/Misc/deepCopier";
  58789. export * from "babylonjs/Misc/pivotTools";
  58790. export * from "babylonjs/Misc/precisionDate";
  58791. export * from "babylonjs/Misc/screenshotTools";
  58792. export * from "babylonjs/Misc/typeStore";
  58793. export * from "babylonjs/Misc/webRequest";
  58794. export * from "babylonjs/Misc/iInspectable";
  58795. }
  58796. declare module "babylonjs/index" {
  58797. export * from "babylonjs/abstractScene";
  58798. export * from "babylonjs/Actions/index";
  58799. export * from "babylonjs/Animations/index";
  58800. export * from "babylonjs/assetContainer";
  58801. export * from "babylonjs/Audio/index";
  58802. export * from "babylonjs/Behaviors/index";
  58803. export * from "babylonjs/Bones/index";
  58804. export * from "babylonjs/Cameras/index";
  58805. export * from "babylonjs/Collisions/index";
  58806. export * from "babylonjs/Culling/index";
  58807. export * from "babylonjs/Debug/index";
  58808. export * from "babylonjs/Engines/index";
  58809. export * from "babylonjs/Events/index";
  58810. export * from "babylonjs/Gamepads/index";
  58811. export * from "babylonjs/Gizmos/index";
  58812. export * from "babylonjs/Helpers/index";
  58813. export * from "babylonjs/Instrumentation/index";
  58814. export * from "babylonjs/Layers/index";
  58815. export * from "babylonjs/LensFlares/index";
  58816. export * from "babylonjs/Lights/index";
  58817. export * from "babylonjs/Loading/index";
  58818. export * from "babylonjs/Materials/index";
  58819. export * from "babylonjs/Maths/index";
  58820. export * from "babylonjs/Meshes/index";
  58821. export * from "babylonjs/Morph/index";
  58822. export * from "babylonjs/node";
  58823. export * from "babylonjs/Offline/index";
  58824. export * from "babylonjs/Particles/index";
  58825. export * from "babylonjs/Physics/index";
  58826. export * from "babylonjs/PostProcesses/index";
  58827. export * from "babylonjs/Probes/index";
  58828. export * from "babylonjs/Rendering/index";
  58829. export * from "babylonjs/scene";
  58830. export * from "babylonjs/sceneComponent";
  58831. export * from "babylonjs/Sprites/index";
  58832. export * from "babylonjs/States/index";
  58833. export * from "babylonjs/Misc/index";
  58834. export * from "babylonjs/types";
  58835. }
  58836. declare module "babylonjs/Animations/pathCursor" {
  58837. import { Path2, Vector3 } from "babylonjs/Maths/math";
  58838. /**
  58839. * A cursor which tracks a point on a path
  58840. */
  58841. export class PathCursor {
  58842. private path;
  58843. /**
  58844. * Stores path cursor callbacks for when an onchange event is triggered
  58845. */
  58846. private _onchange;
  58847. /**
  58848. * The value of the path cursor
  58849. */
  58850. value: number;
  58851. /**
  58852. * The animation array of the path cursor
  58853. */
  58854. animations: Animation[];
  58855. /**
  58856. * Initializes the path cursor
  58857. * @param path The path to track
  58858. */
  58859. constructor(path: Path2);
  58860. /**
  58861. * Gets the cursor point on the path
  58862. * @returns A point on the path cursor at the cursor location
  58863. */
  58864. getPoint(): Vector3;
  58865. /**
  58866. * Moves the cursor ahead by the step amount
  58867. * @param step The amount to move the cursor forward
  58868. * @returns This path cursor
  58869. */
  58870. moveAhead(step?: number): PathCursor;
  58871. /**
  58872. * Moves the cursor behind by the step amount
  58873. * @param step The amount to move the cursor back
  58874. * @returns This path cursor
  58875. */
  58876. moveBack(step?: number): PathCursor;
  58877. /**
  58878. * Moves the cursor by the step amount
  58879. * If the step amount is greater than one, an exception is thrown
  58880. * @param step The amount to move the cursor
  58881. * @returns This path cursor
  58882. */
  58883. move(step: number): PathCursor;
  58884. /**
  58885. * Ensures that the value is limited between zero and one
  58886. * @returns This path cursor
  58887. */
  58888. private ensureLimits;
  58889. /**
  58890. * Runs onchange callbacks on change (used by the animation engine)
  58891. * @returns This path cursor
  58892. */
  58893. private raiseOnChange;
  58894. /**
  58895. * Executes a function on change
  58896. * @param f A path cursor onchange callback
  58897. * @returns This path cursor
  58898. */
  58899. onchange(f: (cursor: PathCursor) => void): PathCursor;
  58900. }
  58901. }
  58902. declare module "babylonjs/Legacy/legacy" {
  58903. import * as Babylon from "babylonjs/index";
  58904. export * from "babylonjs/index";
  58905. }
  58906. declare module "babylonjs/Shaders/blur.fragment" {
  58907. /** @hidden */
  58908. export var blurPixelShader: {
  58909. name: string;
  58910. shader: string;
  58911. };
  58912. }
  58913. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  58914. /** @hidden */
  58915. export var bones300Declaration: {
  58916. name: string;
  58917. shader: string;
  58918. };
  58919. }
  58920. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  58921. /** @hidden */
  58922. export var instances300Declaration: {
  58923. name: string;
  58924. shader: string;
  58925. };
  58926. }
  58927. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  58928. /** @hidden */
  58929. export var pointCloudVertexDeclaration: {
  58930. name: string;
  58931. shader: string;
  58932. };
  58933. }
  58934. // Mixins
  58935. interface Window {
  58936. mozIndexedDB: IDBFactory;
  58937. webkitIndexedDB: IDBFactory;
  58938. msIndexedDB: IDBFactory;
  58939. webkitURL: typeof URL;
  58940. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  58941. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  58942. WebGLRenderingContext: WebGLRenderingContext;
  58943. MSGesture: MSGesture;
  58944. CANNON: any;
  58945. AudioContext: AudioContext;
  58946. webkitAudioContext: AudioContext;
  58947. PointerEvent: any;
  58948. Math: Math;
  58949. Uint8Array: Uint8ArrayConstructor;
  58950. Float32Array: Float32ArrayConstructor;
  58951. mozURL: typeof URL;
  58952. msURL: typeof URL;
  58953. VRFrameData: any; // WebVR, from specs 1.1
  58954. DracoDecoderModule: any;
  58955. setImmediate(handler: (...args: any[]) => void): number;
  58956. }
  58957. interface HTMLCanvasElement {
  58958. requestPointerLock(): void;
  58959. msRequestPointerLock?(): void;
  58960. mozRequestPointerLock?(): void;
  58961. webkitRequestPointerLock?(): void;
  58962. /** Track wether a record is in progress */
  58963. isRecording: boolean;
  58964. /** Capture Stream method defined by some browsers */
  58965. captureStream(fps?: number): MediaStream;
  58966. }
  58967. interface CanvasRenderingContext2D {
  58968. msImageSmoothingEnabled: boolean;
  58969. }
  58970. interface MouseEvent {
  58971. mozMovementX: number;
  58972. mozMovementY: number;
  58973. webkitMovementX: number;
  58974. webkitMovementY: number;
  58975. msMovementX: number;
  58976. msMovementY: number;
  58977. }
  58978. interface Navigator {
  58979. mozGetVRDevices: (any: any) => any;
  58980. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58981. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58982. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58983. webkitGetGamepads(): Gamepad[];
  58984. msGetGamepads(): Gamepad[];
  58985. webkitGamepads(): Gamepad[];
  58986. }
  58987. interface HTMLVideoElement {
  58988. mozSrcObject: any;
  58989. }
  58990. interface Math {
  58991. fround(x: number): number;
  58992. imul(a: number, b: number): number;
  58993. }
  58994. interface WebGLProgram {
  58995. context?: WebGLRenderingContext;
  58996. vertexShader?: WebGLShader;
  58997. fragmentShader?: WebGLShader;
  58998. isParallelCompiled: boolean;
  58999. onCompiled?: () => void;
  59000. }
  59001. interface WebGLRenderingContext {
  59002. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  59003. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  59004. vertexAttribDivisor(index: number, divisor: number): void;
  59005. createVertexArray(): any;
  59006. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  59007. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  59008. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  59009. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  59010. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  59011. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  59012. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  59013. // Queries
  59014. createQuery(): WebGLQuery;
  59015. deleteQuery(query: WebGLQuery): void;
  59016. beginQuery(target: number, query: WebGLQuery): void;
  59017. endQuery(target: number): void;
  59018. getQueryParameter(query: WebGLQuery, pname: number): any;
  59019. getQuery(target: number, pname: number): any;
  59020. MAX_SAMPLES: number;
  59021. RGBA8: number;
  59022. READ_FRAMEBUFFER: number;
  59023. DRAW_FRAMEBUFFER: number;
  59024. UNIFORM_BUFFER: number;
  59025. HALF_FLOAT_OES: number;
  59026. RGBA16F: number;
  59027. RGBA32F: number;
  59028. R32F: number;
  59029. RG32F: number;
  59030. RGB32F: number;
  59031. R16F: number;
  59032. RG16F: number;
  59033. RGB16F: number;
  59034. RED: number;
  59035. RG: number;
  59036. R8: number;
  59037. RG8: number;
  59038. UNSIGNED_INT_24_8: number;
  59039. DEPTH24_STENCIL8: number;
  59040. /* Multiple Render Targets */
  59041. drawBuffers(buffers: number[]): void;
  59042. readBuffer(src: number): void;
  59043. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  59044. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  59045. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  59046. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  59047. // Occlusion Query
  59048. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  59049. ANY_SAMPLES_PASSED: number;
  59050. QUERY_RESULT_AVAILABLE: number;
  59051. QUERY_RESULT: number;
  59052. }
  59053. interface WebGLBuffer {
  59054. references: number;
  59055. capacity: number;
  59056. is32Bits: boolean;
  59057. }
  59058. interface WebGLProgram {
  59059. transformFeedback?: WebGLTransformFeedback | null;
  59060. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  59061. }
  59062. interface EXT_disjoint_timer_query {
  59063. QUERY_COUNTER_BITS_EXT: number;
  59064. TIME_ELAPSED_EXT: number;
  59065. TIMESTAMP_EXT: number;
  59066. GPU_DISJOINT_EXT: number;
  59067. QUERY_RESULT_EXT: number;
  59068. QUERY_RESULT_AVAILABLE_EXT: number;
  59069. queryCounterEXT(query: WebGLQuery, target: number): void;
  59070. createQueryEXT(): WebGLQuery;
  59071. beginQueryEXT(target: number, query: WebGLQuery): void;
  59072. endQueryEXT(target: number): void;
  59073. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  59074. deleteQueryEXT(query: WebGLQuery): void;
  59075. }
  59076. interface WebGLUniformLocation {
  59077. _currentState: any;
  59078. }
  59079. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  59080. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  59081. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  59082. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59083. interface WebGLRenderingContext {
  59084. readonly RASTERIZER_DISCARD: number;
  59085. readonly DEPTH_COMPONENT24: number;
  59086. readonly TEXTURE_3D: number;
  59087. readonly TEXTURE_2D_ARRAY: number;
  59088. readonly TEXTURE_COMPARE_FUNC: number;
  59089. readonly TEXTURE_COMPARE_MODE: number;
  59090. readonly COMPARE_REF_TO_TEXTURE: number;
  59091. readonly TEXTURE_WRAP_R: number;
  59092. readonly HALF_FLOAT: number;
  59093. readonly RGB8: number;
  59094. readonly RED_INTEGER: number;
  59095. readonly RG_INTEGER: number;
  59096. readonly RGB_INTEGER: number;
  59097. readonly RGBA_INTEGER: number;
  59098. readonly R8_SNORM: number;
  59099. readonly RG8_SNORM: number;
  59100. readonly RGB8_SNORM: number;
  59101. readonly RGBA8_SNORM: number;
  59102. readonly R8I: number;
  59103. readonly RG8I: number;
  59104. readonly RGB8I: number;
  59105. readonly RGBA8I: number;
  59106. readonly R8UI: number;
  59107. readonly RG8UI: number;
  59108. readonly RGB8UI: number;
  59109. readonly RGBA8UI: number;
  59110. readonly R16I: number;
  59111. readonly RG16I: number;
  59112. readonly RGB16I: number;
  59113. readonly RGBA16I: number;
  59114. readonly R16UI: number;
  59115. readonly RG16UI: number;
  59116. readonly RGB16UI: number;
  59117. readonly RGBA16UI: number;
  59118. readonly R32I: number;
  59119. readonly RG32I: number;
  59120. readonly RGB32I: number;
  59121. readonly RGBA32I: number;
  59122. readonly R32UI: number;
  59123. readonly RG32UI: number;
  59124. readonly RGB32UI: number;
  59125. readonly RGBA32UI: number;
  59126. readonly RGB10_A2UI: number;
  59127. readonly R11F_G11F_B10F: number;
  59128. readonly RGB9_E5: number;
  59129. readonly RGB10_A2: number;
  59130. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  59131. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  59132. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  59133. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  59134. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  59135. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  59136. 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;
  59137. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  59138. readonly TRANSFORM_FEEDBACK: number;
  59139. readonly INTERLEAVED_ATTRIBS: number;
  59140. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  59141. createTransformFeedback(): WebGLTransformFeedback;
  59142. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  59143. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  59144. beginTransformFeedback(primitiveMode: number): void;
  59145. endTransformFeedback(): void;
  59146. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  59147. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59148. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59149. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59150. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  59151. }
  59152. interface ImageBitmap {
  59153. readonly width: number;
  59154. readonly height: number;
  59155. close(): void;
  59156. }
  59157. interface WebGLQuery extends WebGLObject {
  59158. }
  59159. declare var WebGLQuery: {
  59160. prototype: WebGLQuery;
  59161. new(): WebGLQuery;
  59162. };
  59163. interface WebGLSampler extends WebGLObject {
  59164. }
  59165. declare var WebGLSampler: {
  59166. prototype: WebGLSampler;
  59167. new(): WebGLSampler;
  59168. };
  59169. interface WebGLSync extends WebGLObject {
  59170. }
  59171. declare var WebGLSync: {
  59172. prototype: WebGLSync;
  59173. new(): WebGLSync;
  59174. };
  59175. interface WebGLTransformFeedback extends WebGLObject {
  59176. }
  59177. declare var WebGLTransformFeedback: {
  59178. prototype: WebGLTransformFeedback;
  59179. new(): WebGLTransformFeedback;
  59180. };
  59181. interface WebGLVertexArrayObject extends WebGLObject {
  59182. }
  59183. declare var WebGLVertexArrayObject: {
  59184. prototype: WebGLVertexArrayObject;
  59185. new(): WebGLVertexArrayObject;
  59186. };
  59187. // Type definitions for WebVR API
  59188. // Project: https://w3c.github.io/webvr/
  59189. // Definitions by: six a <https://github.com/lostfictions>
  59190. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59191. interface VRDisplay extends EventTarget {
  59192. /**
  59193. * Dictionary of capabilities describing the VRDisplay.
  59194. */
  59195. readonly capabilities: VRDisplayCapabilities;
  59196. /**
  59197. * z-depth defining the far plane of the eye view frustum
  59198. * enables mapping of values in the render target depth
  59199. * attachment to scene coordinates. Initially set to 10000.0.
  59200. */
  59201. depthFar: number;
  59202. /**
  59203. * z-depth defining the near plane of the eye view frustum
  59204. * enables mapping of values in the render target depth
  59205. * attachment to scene coordinates. Initially set to 0.01.
  59206. */
  59207. depthNear: number;
  59208. /**
  59209. * An identifier for this distinct VRDisplay. Used as an
  59210. * association point in the Gamepad API.
  59211. */
  59212. readonly displayId: number;
  59213. /**
  59214. * A display name, a user-readable name identifying it.
  59215. */
  59216. readonly displayName: string;
  59217. readonly isConnected: boolean;
  59218. readonly isPresenting: boolean;
  59219. /**
  59220. * If this VRDisplay supports room-scale experiences, the optional
  59221. * stage attribute contains details on the room-scale parameters.
  59222. */
  59223. readonly stageParameters: VRStageParameters | null;
  59224. /**
  59225. * Passing the value returned by `requestAnimationFrame` to
  59226. * `cancelAnimationFrame` will unregister the callback.
  59227. * @param handle Define the hanle of the request to cancel
  59228. */
  59229. cancelAnimationFrame(handle: number): void;
  59230. /**
  59231. * Stops presenting to the VRDisplay.
  59232. * @returns a promise to know when it stopped
  59233. */
  59234. exitPresent(): Promise<void>;
  59235. /**
  59236. * Return the current VREyeParameters for the given eye.
  59237. * @param whichEye Define the eye we want the parameter for
  59238. * @returns the eye parameters
  59239. */
  59240. getEyeParameters(whichEye: string): VREyeParameters;
  59241. /**
  59242. * Populates the passed VRFrameData with the information required to render
  59243. * the current frame.
  59244. * @param frameData Define the data structure to populate
  59245. * @returns true if ok otherwise false
  59246. */
  59247. getFrameData(frameData: VRFrameData): boolean;
  59248. /**
  59249. * Get the layers currently being presented.
  59250. * @returns the list of VR layers
  59251. */
  59252. getLayers(): VRLayer[];
  59253. /**
  59254. * Return a VRPose containing the future predicted pose of the VRDisplay
  59255. * when the current frame will be presented. The value returned will not
  59256. * change until JavaScript has returned control to the browser.
  59257. *
  59258. * The VRPose will contain the position, orientation, velocity,
  59259. * and acceleration of each of these properties.
  59260. * @returns the pose object
  59261. */
  59262. getPose(): VRPose;
  59263. /**
  59264. * Return the current instantaneous pose of the VRDisplay, with no
  59265. * prediction applied.
  59266. * @returns the current instantaneous pose
  59267. */
  59268. getImmediatePose(): VRPose;
  59269. /**
  59270. * The callback passed to `requestAnimationFrame` will be called
  59271. * any time a new frame should be rendered. When the VRDisplay is
  59272. * presenting the callback will be called at the native refresh
  59273. * rate of the HMD. When not presenting this function acts
  59274. * identically to how window.requestAnimationFrame acts. Content should
  59275. * make no assumptions of frame rate or vsync behavior as the HMD runs
  59276. * asynchronously from other displays and at differing refresh rates.
  59277. * @param callback Define the eaction to run next frame
  59278. * @returns the request handle it
  59279. */
  59280. requestAnimationFrame(callback: FrameRequestCallback): number;
  59281. /**
  59282. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  59283. * Repeat calls while already presenting will update the VRLayers being displayed.
  59284. * @param layers Define the list of layer to present
  59285. * @returns a promise to know when the request has been fulfilled
  59286. */
  59287. requestPresent(layers: VRLayer[]): Promise<void>;
  59288. /**
  59289. * Reset the pose for this display, treating its current position and
  59290. * orientation as the "origin/zero" values. VRPose.position,
  59291. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  59292. * updated when calling resetPose(). This should be called in only
  59293. * sitting-space experiences.
  59294. */
  59295. resetPose(): void;
  59296. /**
  59297. * The VRLayer provided to the VRDisplay will be captured and presented
  59298. * in the HMD. Calling this function has the same effect on the source
  59299. * canvas as any other operation that uses its source image, and canvases
  59300. * created without preserveDrawingBuffer set to true will be cleared.
  59301. * @param pose Define the pose to submit
  59302. */
  59303. submitFrame(pose?: VRPose): void;
  59304. }
  59305. declare var VRDisplay: {
  59306. prototype: VRDisplay;
  59307. new(): VRDisplay;
  59308. };
  59309. interface VRLayer {
  59310. leftBounds?: number[] | Float32Array | null;
  59311. rightBounds?: number[] | Float32Array | null;
  59312. source?: HTMLCanvasElement | null;
  59313. }
  59314. interface VRDisplayCapabilities {
  59315. readonly canPresent: boolean;
  59316. readonly hasExternalDisplay: boolean;
  59317. readonly hasOrientation: boolean;
  59318. readonly hasPosition: boolean;
  59319. readonly maxLayers: number;
  59320. }
  59321. interface VREyeParameters {
  59322. /** @deprecated */
  59323. readonly fieldOfView: VRFieldOfView;
  59324. readonly offset: Float32Array;
  59325. readonly renderHeight: number;
  59326. readonly renderWidth: number;
  59327. }
  59328. interface VRFieldOfView {
  59329. readonly downDegrees: number;
  59330. readonly leftDegrees: number;
  59331. readonly rightDegrees: number;
  59332. readonly upDegrees: number;
  59333. }
  59334. interface VRFrameData {
  59335. readonly leftProjectionMatrix: Float32Array;
  59336. readonly leftViewMatrix: Float32Array;
  59337. readonly pose: VRPose;
  59338. readonly rightProjectionMatrix: Float32Array;
  59339. readonly rightViewMatrix: Float32Array;
  59340. readonly timestamp: number;
  59341. }
  59342. interface VRPose {
  59343. readonly angularAcceleration: Float32Array | null;
  59344. readonly angularVelocity: Float32Array | null;
  59345. readonly linearAcceleration: Float32Array | null;
  59346. readonly linearVelocity: Float32Array | null;
  59347. readonly orientation: Float32Array | null;
  59348. readonly position: Float32Array | null;
  59349. readonly timestamp: number;
  59350. }
  59351. interface VRStageParameters {
  59352. sittingToStandingTransform?: Float32Array;
  59353. sizeX?: number;
  59354. sizeY?: number;
  59355. }
  59356. interface Navigator {
  59357. getVRDisplays(): Promise<VRDisplay[]>;
  59358. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  59359. }
  59360. interface Window {
  59361. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  59362. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  59363. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  59364. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59365. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59366. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  59367. }
  59368. interface Gamepad {
  59369. readonly displayId: number;
  59370. }
  59371. interface XRDevice {
  59372. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  59373. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  59374. }
  59375. interface XRSession {
  59376. getInputSources(): Array<any>;
  59377. baseLayer: XRWebGLLayer;
  59378. requestFrameOfReference(type: string): Promise<void>;
  59379. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  59380. end(): Promise<void>;
  59381. requestAnimationFrame: Function;
  59382. addEventListener: Function;
  59383. }
  59384. interface XRSessionCreationOptions {
  59385. outputContext?: WebGLRenderingContext | null;
  59386. immersive?: boolean;
  59387. environmentIntegration?: boolean;
  59388. }
  59389. interface XRLayer {
  59390. getViewport: Function;
  59391. framebufferWidth: number;
  59392. framebufferHeight: number;
  59393. }
  59394. interface XRView {
  59395. projectionMatrix: Float32Array;
  59396. }
  59397. interface XRFrame {
  59398. getDevicePose: Function;
  59399. getInputPose: Function;
  59400. views: Array<XRView>;
  59401. baseLayer: XRLayer;
  59402. }
  59403. interface XRFrameOfReference {
  59404. }
  59405. interface XRWebGLLayer extends XRLayer {
  59406. framebuffer: WebGLFramebuffer;
  59407. }
  59408. declare var XRWebGLLayer: {
  59409. prototype: XRWebGLLayer;
  59410. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  59411. };
  59412. declare module "babylonjs" {
  59413. export * from "babylonjs/Legacy/legacy";
  59414. }
  59415. declare module BABYLON {
  59416. /** Alias type for value that can be null */
  59417. export type Nullable<T> = T | null;
  59418. /**
  59419. * Alias type for number that are floats
  59420. * @ignorenaming
  59421. */
  59422. export type float = number;
  59423. /**
  59424. * Alias type for number that are doubles.
  59425. * @ignorenaming
  59426. */
  59427. export type double = number;
  59428. /**
  59429. * Alias type for number that are integer
  59430. * @ignorenaming
  59431. */
  59432. export type int = number;
  59433. /** Alias type for number array or Float32Array */
  59434. export type FloatArray = number[] | Float32Array;
  59435. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  59436. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  59437. /**
  59438. * Alias for types that can be used by a Buffer or VertexBuffer.
  59439. */
  59440. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  59441. /**
  59442. * Alias type for primitive types
  59443. * @ignorenaming
  59444. */
  59445. type Primitive = undefined | null | boolean | string | number | Function;
  59446. /**
  59447. * Type modifier to make all the properties of an object Readonly
  59448. */
  59449. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  59450. /**
  59451. * Type modifier to make all the properties of an object Readonly recursively
  59452. */
  59453. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  59454. /** @hidden */
  59455. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  59456. }
  59457. /** @hidden */
  59458. /** @hidden */
  59459. type DeepImmutableObject<T> = {
  59460. readonly [K in keyof T]: DeepImmutable<T[K]>;
  59461. };
  59462. }
  59463. declare module BABYLON {
  59464. /**
  59465. * Class containing a set of static utilities functions for arrays.
  59466. */
  59467. export class ArrayTools {
  59468. /**
  59469. * Returns an array of the given size filled with element built from the given constructor and the paramters
  59470. * @param size the number of element to construct and put in the array
  59471. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  59472. * @returns a new array filled with new objects
  59473. */
  59474. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  59475. }
  59476. }
  59477. declare module BABYLON {
  59478. /**
  59479. * Scalar computation library
  59480. */
  59481. export class Scalar {
  59482. /**
  59483. * Two pi constants convenient for computation.
  59484. */
  59485. static TwoPi: number;
  59486. /**
  59487. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  59488. * @param a number
  59489. * @param b number
  59490. * @param epsilon (default = 1.401298E-45)
  59491. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  59492. */
  59493. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  59494. /**
  59495. * Returns a string : the upper case translation of the number i to hexadecimal.
  59496. * @param i number
  59497. * @returns the upper case translation of the number i to hexadecimal.
  59498. */
  59499. static ToHex(i: number): string;
  59500. /**
  59501. * Returns -1 if value is negative and +1 is value is positive.
  59502. * @param value the value
  59503. * @returns the value itself if it's equal to zero.
  59504. */
  59505. static Sign(value: number): number;
  59506. /**
  59507. * Returns the value itself if it's between min and max.
  59508. * Returns min if the value is lower than min.
  59509. * Returns max if the value is greater than max.
  59510. * @param value the value to clmap
  59511. * @param min the min value to clamp to (default: 0)
  59512. * @param max the max value to clamp to (default: 1)
  59513. * @returns the clamped value
  59514. */
  59515. static Clamp(value: number, min?: number, max?: number): number;
  59516. /**
  59517. * the log2 of value.
  59518. * @param value the value to compute log2 of
  59519. * @returns the log2 of value.
  59520. */
  59521. static Log2(value: number): number;
  59522. /**
  59523. * Loops the value, so that it is never larger than length and never smaller than 0.
  59524. *
  59525. * This is similar to the modulo operator but it works with floating point numbers.
  59526. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  59527. * With t = 5 and length = 2.5, the result would be 0.0.
  59528. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  59529. * @param value the value
  59530. * @param length the length
  59531. * @returns the looped value
  59532. */
  59533. static Repeat(value: number, length: number): number;
  59534. /**
  59535. * Normalize the value between 0.0 and 1.0 using min and max values
  59536. * @param value value to normalize
  59537. * @param min max to normalize between
  59538. * @param max min to normalize between
  59539. * @returns the normalized value
  59540. */
  59541. static Normalize(value: number, min: number, max: number): number;
  59542. /**
  59543. * Denormalize the value from 0.0 and 1.0 using min and max values
  59544. * @param normalized value to denormalize
  59545. * @param min max to denormalize between
  59546. * @param max min to denormalize between
  59547. * @returns the denormalized value
  59548. */
  59549. static Denormalize(normalized: number, min: number, max: number): number;
  59550. /**
  59551. * Calculates the shortest difference between two given angles given in degrees.
  59552. * @param current current angle in degrees
  59553. * @param target target angle in degrees
  59554. * @returns the delta
  59555. */
  59556. static DeltaAngle(current: number, target: number): number;
  59557. /**
  59558. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  59559. * @param tx value
  59560. * @param length length
  59561. * @returns The returned value will move back and forth between 0 and length
  59562. */
  59563. static PingPong(tx: number, length: number): number;
  59564. /**
  59565. * Interpolates between min and max with smoothing at the limits.
  59566. *
  59567. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  59568. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  59569. * @param from from
  59570. * @param to to
  59571. * @param tx value
  59572. * @returns the smooth stepped value
  59573. */
  59574. static SmoothStep(from: number, to: number, tx: number): number;
  59575. /**
  59576. * Moves a value current towards target.
  59577. *
  59578. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  59579. * Negative values of maxDelta pushes the value away from target.
  59580. * @param current current value
  59581. * @param target target value
  59582. * @param maxDelta max distance to move
  59583. * @returns resulting value
  59584. */
  59585. static MoveTowards(current: number, target: number, maxDelta: number): number;
  59586. /**
  59587. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  59588. *
  59589. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  59590. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  59591. * @param current current value
  59592. * @param target target value
  59593. * @param maxDelta max distance to move
  59594. * @returns resulting angle
  59595. */
  59596. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  59597. /**
  59598. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  59599. * @param start start value
  59600. * @param end target value
  59601. * @param amount amount to lerp between
  59602. * @returns the lerped value
  59603. */
  59604. static Lerp(start: number, end: number, amount: number): number;
  59605. /**
  59606. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  59607. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  59608. * @param start start value
  59609. * @param end target value
  59610. * @param amount amount to lerp between
  59611. * @returns the lerped value
  59612. */
  59613. static LerpAngle(start: number, end: number, amount: number): number;
  59614. /**
  59615. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  59616. * @param a start value
  59617. * @param b target value
  59618. * @param value value between a and b
  59619. * @returns the inverseLerp value
  59620. */
  59621. static InverseLerp(a: number, b: number, value: number): number;
  59622. /**
  59623. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  59624. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  59625. * @param value1 spline value
  59626. * @param tangent1 spline value
  59627. * @param value2 spline value
  59628. * @param tangent2 spline value
  59629. * @param amount input value
  59630. * @returns hermite result
  59631. */
  59632. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  59633. /**
  59634. * Returns a random float number between and min and max values
  59635. * @param min min value of random
  59636. * @param max max value of random
  59637. * @returns random value
  59638. */
  59639. static RandomRange(min: number, max: number): number;
  59640. /**
  59641. * This function returns percentage of a number in a given range.
  59642. *
  59643. * RangeToPercent(40,20,60) will return 0.5 (50%)
  59644. * RangeToPercent(34,0,100) will return 0.34 (34%)
  59645. * @param number to convert to percentage
  59646. * @param min min range
  59647. * @param max max range
  59648. * @returns the percentage
  59649. */
  59650. static RangeToPercent(number: number, min: number, max: number): number;
  59651. /**
  59652. * This function returns number that corresponds to the percentage in a given range.
  59653. *
  59654. * PercentToRange(0.34,0,100) will return 34.
  59655. * @param percent to convert to number
  59656. * @param min min range
  59657. * @param max max range
  59658. * @returns the number
  59659. */
  59660. static PercentToRange(percent: number, min: number, max: number): number;
  59661. /**
  59662. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  59663. * @param angle The angle to normalize in radian.
  59664. * @return The converted angle.
  59665. */
  59666. static NormalizeRadians(angle: number): number;
  59667. }
  59668. }
  59669. declare module BABYLON {
  59670. /**
  59671. * Constant used to convert a value to gamma space
  59672. * @ignorenaming
  59673. */
  59674. export const ToGammaSpace: number;
  59675. /**
  59676. * Constant used to convert a value to linear space
  59677. * @ignorenaming
  59678. */
  59679. export const ToLinearSpace = 2.2;
  59680. /**
  59681. * Constant used to define the minimal number value in Babylon.js
  59682. * @ignorenaming
  59683. */
  59684. let Epsilon: number;
  59685. /**
  59686. * Class used to hold a RBG color
  59687. */
  59688. export class Color3 {
  59689. /**
  59690. * Defines the red component (between 0 and 1, default is 0)
  59691. */
  59692. r: number;
  59693. /**
  59694. * Defines the green component (between 0 and 1, default is 0)
  59695. */
  59696. g: number;
  59697. /**
  59698. * Defines the blue component (between 0 and 1, default is 0)
  59699. */
  59700. b: number;
  59701. /**
  59702. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  59703. * @param r defines the red component (between 0 and 1, default is 0)
  59704. * @param g defines the green component (between 0 and 1, default is 0)
  59705. * @param b defines the blue component (between 0 and 1, default is 0)
  59706. */
  59707. constructor(
  59708. /**
  59709. * Defines the red component (between 0 and 1, default is 0)
  59710. */
  59711. r?: number,
  59712. /**
  59713. * Defines the green component (between 0 and 1, default is 0)
  59714. */
  59715. g?: number,
  59716. /**
  59717. * Defines the blue component (between 0 and 1, default is 0)
  59718. */
  59719. b?: number);
  59720. /**
  59721. * Creates a string with the Color3 current values
  59722. * @returns the string representation of the Color3 object
  59723. */
  59724. toString(): string;
  59725. /**
  59726. * Returns the string "Color3"
  59727. * @returns "Color3"
  59728. */
  59729. getClassName(): string;
  59730. /**
  59731. * Compute the Color3 hash code
  59732. * @returns an unique number that can be used to hash Color3 objects
  59733. */
  59734. getHashCode(): number;
  59735. /**
  59736. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  59737. * @param array defines the array where to store the r,g,b components
  59738. * @param index defines an optional index in the target array to define where to start storing values
  59739. * @returns the current Color3 object
  59740. */
  59741. toArray(array: FloatArray, index?: number): Color3;
  59742. /**
  59743. * Returns a new Color4 object from the current Color3 and the given alpha
  59744. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  59745. * @returns a new Color4 object
  59746. */
  59747. toColor4(alpha?: number): Color4;
  59748. /**
  59749. * Returns a new array populated with 3 numeric elements : red, green and blue values
  59750. * @returns the new array
  59751. */
  59752. asArray(): number[];
  59753. /**
  59754. * Returns the luminance value
  59755. * @returns a float value
  59756. */
  59757. toLuminance(): number;
  59758. /**
  59759. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  59760. * @param otherColor defines the second operand
  59761. * @returns the new Color3 object
  59762. */
  59763. multiply(otherColor: DeepImmutable<Color3>): Color3;
  59764. /**
  59765. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  59766. * @param otherColor defines the second operand
  59767. * @param result defines the Color3 object where to store the result
  59768. * @returns the current Color3
  59769. */
  59770. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  59771. /**
  59772. * Determines equality between Color3 objects
  59773. * @param otherColor defines the second operand
  59774. * @returns true if the rgb values are equal to the given ones
  59775. */
  59776. equals(otherColor: DeepImmutable<Color3>): boolean;
  59777. /**
  59778. * Determines equality between the current Color3 object and a set of r,b,g values
  59779. * @param r defines the red component to check
  59780. * @param g defines the green component to check
  59781. * @param b defines the blue component to check
  59782. * @returns true if the rgb values are equal to the given ones
  59783. */
  59784. equalsFloats(r: number, g: number, b: number): boolean;
  59785. /**
  59786. * Multiplies in place each rgb value by scale
  59787. * @param scale defines the scaling factor
  59788. * @returns the updated Color3
  59789. */
  59790. scale(scale: number): Color3;
  59791. /**
  59792. * Multiplies the rgb values by scale and stores the result into "result"
  59793. * @param scale defines the scaling factor
  59794. * @param result defines the Color3 object where to store the result
  59795. * @returns the unmodified current Color3
  59796. */
  59797. scaleToRef(scale: number, result: Color3): Color3;
  59798. /**
  59799. * Scale the current Color3 values by a factor and add the result to a given Color3
  59800. * @param scale defines the scale factor
  59801. * @param result defines color to store the result into
  59802. * @returns the unmodified current Color3
  59803. */
  59804. scaleAndAddToRef(scale: number, result: Color3): Color3;
  59805. /**
  59806. * Clamps the rgb values by the min and max values and stores the result into "result"
  59807. * @param min defines minimum clamping value (default is 0)
  59808. * @param max defines maximum clamping value (default is 1)
  59809. * @param result defines color to store the result into
  59810. * @returns the original Color3
  59811. */
  59812. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  59813. /**
  59814. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  59815. * @param otherColor defines the second operand
  59816. * @returns the new Color3
  59817. */
  59818. add(otherColor: DeepImmutable<Color3>): Color3;
  59819. /**
  59820. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  59821. * @param otherColor defines the second operand
  59822. * @param result defines Color3 object to store the result into
  59823. * @returns the unmodified current Color3
  59824. */
  59825. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  59826. /**
  59827. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  59828. * @param otherColor defines the second operand
  59829. * @returns the new Color3
  59830. */
  59831. subtract(otherColor: DeepImmutable<Color3>): Color3;
  59832. /**
  59833. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  59834. * @param otherColor defines the second operand
  59835. * @param result defines Color3 object to store the result into
  59836. * @returns the unmodified current Color3
  59837. */
  59838. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  59839. /**
  59840. * Copy the current object
  59841. * @returns a new Color3 copied the current one
  59842. */
  59843. clone(): Color3;
  59844. /**
  59845. * Copies the rgb values from the source in the current Color3
  59846. * @param source defines the source Color3 object
  59847. * @returns the updated Color3 object
  59848. */
  59849. copyFrom(source: DeepImmutable<Color3>): Color3;
  59850. /**
  59851. * Updates the Color3 rgb values from the given floats
  59852. * @param r defines the red component to read from
  59853. * @param g defines the green component to read from
  59854. * @param b defines the blue component to read from
  59855. * @returns the current Color3 object
  59856. */
  59857. copyFromFloats(r: number, g: number, b: number): Color3;
  59858. /**
  59859. * Updates the Color3 rgb values from the given floats
  59860. * @param r defines the red component to read from
  59861. * @param g defines the green component to read from
  59862. * @param b defines the blue component to read from
  59863. * @returns the current Color3 object
  59864. */
  59865. set(r: number, g: number, b: number): Color3;
  59866. /**
  59867. * Compute the Color3 hexadecimal code as a string
  59868. * @returns a string containing the hexadecimal representation of the Color3 object
  59869. */
  59870. toHexString(): string;
  59871. /**
  59872. * Computes a new Color3 converted from the current one to linear space
  59873. * @returns a new Color3 object
  59874. */
  59875. toLinearSpace(): Color3;
  59876. /**
  59877. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  59878. * @param convertedColor defines the Color3 object where to store the linear space version
  59879. * @returns the unmodified Color3
  59880. */
  59881. toLinearSpaceToRef(convertedColor: Color3): Color3;
  59882. /**
  59883. * Computes a new Color3 converted from the current one to gamma space
  59884. * @returns a new Color3 object
  59885. */
  59886. toGammaSpace(): Color3;
  59887. /**
  59888. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  59889. * @param convertedColor defines the Color3 object where to store the gamma space version
  59890. * @returns the unmodified Color3
  59891. */
  59892. toGammaSpaceToRef(convertedColor: Color3): Color3;
  59893. private static _BlackReadOnly;
  59894. /**
  59895. * Creates a new Color3 from the string containing valid hexadecimal values
  59896. * @param hex defines a string containing valid hexadecimal values
  59897. * @returns a new Color3 object
  59898. */
  59899. static FromHexString(hex: string): Color3;
  59900. /**
  59901. * Creates a new Vector3 from the starting index of the given array
  59902. * @param array defines the source array
  59903. * @param offset defines an offset in the source array
  59904. * @returns a new Color3 object
  59905. */
  59906. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  59907. /**
  59908. * Creates a new Color3 from integer values (< 256)
  59909. * @param r defines the red component to read from (value between 0 and 255)
  59910. * @param g defines the green component to read from (value between 0 and 255)
  59911. * @param b defines the blue component to read from (value between 0 and 255)
  59912. * @returns a new Color3 object
  59913. */
  59914. static FromInts(r: number, g: number, b: number): Color3;
  59915. /**
  59916. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  59917. * @param start defines the start Color3 value
  59918. * @param end defines the end Color3 value
  59919. * @param amount defines the gradient value between start and end
  59920. * @returns a new Color3 object
  59921. */
  59922. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  59923. /**
  59924. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  59925. * @param left defines the start value
  59926. * @param right defines the end value
  59927. * @param amount defines the gradient factor
  59928. * @param result defines the Color3 object where to store the result
  59929. */
  59930. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  59931. /**
  59932. * Returns a Color3 value containing a red color
  59933. * @returns a new Color3 object
  59934. */
  59935. static Red(): Color3;
  59936. /**
  59937. * Returns a Color3 value containing a green color
  59938. * @returns a new Color3 object
  59939. */
  59940. static Green(): Color3;
  59941. /**
  59942. * Returns a Color3 value containing a blue color
  59943. * @returns a new Color3 object
  59944. */
  59945. static Blue(): Color3;
  59946. /**
  59947. * Returns a Color3 value containing a black color
  59948. * @returns a new Color3 object
  59949. */
  59950. static Black(): Color3;
  59951. /**
  59952. * Gets a Color3 value containing a black color that must not be updated
  59953. */
  59954. static readonly BlackReadOnly: DeepImmutable<Color3>;
  59955. /**
  59956. * Returns a Color3 value containing a white color
  59957. * @returns a new Color3 object
  59958. */
  59959. static White(): Color3;
  59960. /**
  59961. * Returns a Color3 value containing a purple color
  59962. * @returns a new Color3 object
  59963. */
  59964. static Purple(): Color3;
  59965. /**
  59966. * Returns a Color3 value containing a magenta color
  59967. * @returns a new Color3 object
  59968. */
  59969. static Magenta(): Color3;
  59970. /**
  59971. * Returns a Color3 value containing a yellow color
  59972. * @returns a new Color3 object
  59973. */
  59974. static Yellow(): Color3;
  59975. /**
  59976. * Returns a Color3 value containing a gray color
  59977. * @returns a new Color3 object
  59978. */
  59979. static Gray(): Color3;
  59980. /**
  59981. * Returns a Color3 value containing a teal color
  59982. * @returns a new Color3 object
  59983. */
  59984. static Teal(): Color3;
  59985. /**
  59986. * Returns a Color3 value containing a random color
  59987. * @returns a new Color3 object
  59988. */
  59989. static Random(): Color3;
  59990. }
  59991. /**
  59992. * Class used to hold a RBGA color
  59993. */
  59994. export class Color4 {
  59995. /**
  59996. * Defines the red component (between 0 and 1, default is 0)
  59997. */
  59998. r: number;
  59999. /**
  60000. * Defines the green component (between 0 and 1, default is 0)
  60001. */
  60002. g: number;
  60003. /**
  60004. * Defines the blue component (between 0 and 1, default is 0)
  60005. */
  60006. b: number;
  60007. /**
  60008. * Defines the alpha component (between 0 and 1, default is 1)
  60009. */
  60010. a: number;
  60011. /**
  60012. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  60013. * @param r defines the red component (between 0 and 1, default is 0)
  60014. * @param g defines the green component (between 0 and 1, default is 0)
  60015. * @param b defines the blue component (between 0 and 1, default is 0)
  60016. * @param a defines the alpha component (between 0 and 1, default is 1)
  60017. */
  60018. constructor(
  60019. /**
  60020. * Defines the red component (between 0 and 1, default is 0)
  60021. */
  60022. r?: number,
  60023. /**
  60024. * Defines the green component (between 0 and 1, default is 0)
  60025. */
  60026. g?: number,
  60027. /**
  60028. * Defines the blue component (between 0 and 1, default is 0)
  60029. */
  60030. b?: number,
  60031. /**
  60032. * Defines the alpha component (between 0 and 1, default is 1)
  60033. */
  60034. a?: number);
  60035. /**
  60036. * Adds in place the given Color4 values to the current Color4 object
  60037. * @param right defines the second operand
  60038. * @returns the current updated Color4 object
  60039. */
  60040. addInPlace(right: DeepImmutable<Color4>): Color4;
  60041. /**
  60042. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  60043. * @returns the new array
  60044. */
  60045. asArray(): number[];
  60046. /**
  60047. * Stores from the starting index in the given array the Color4 successive values
  60048. * @param array defines the array where to store the r,g,b components
  60049. * @param index defines an optional index in the target array to define where to start storing values
  60050. * @returns the current Color4 object
  60051. */
  60052. toArray(array: number[], index?: number): Color4;
  60053. /**
  60054. * Determines equality between Color4 objects
  60055. * @param otherColor defines the second operand
  60056. * @returns true if the rgba values are equal to the given ones
  60057. */
  60058. equals(otherColor: DeepImmutable<Color4>): boolean;
  60059. /**
  60060. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  60061. * @param right defines the second operand
  60062. * @returns a new Color4 object
  60063. */
  60064. add(right: DeepImmutable<Color4>): Color4;
  60065. /**
  60066. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  60067. * @param right defines the second operand
  60068. * @returns a new Color4 object
  60069. */
  60070. subtract(right: DeepImmutable<Color4>): Color4;
  60071. /**
  60072. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  60073. * @param right defines the second operand
  60074. * @param result defines the Color4 object where to store the result
  60075. * @returns the current Color4 object
  60076. */
  60077. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  60078. /**
  60079. * Creates a new Color4 with the current Color4 values multiplied by scale
  60080. * @param scale defines the scaling factor to apply
  60081. * @returns a new Color4 object
  60082. */
  60083. scale(scale: number): Color4;
  60084. /**
  60085. * Multiplies the current Color4 values by scale and stores the result in "result"
  60086. * @param scale defines the scaling factor to apply
  60087. * @param result defines the Color4 object where to store the result
  60088. * @returns the current unmodified Color4
  60089. */
  60090. scaleToRef(scale: number, result: Color4): Color4;
  60091. /**
  60092. * Scale the current Color4 values by a factor and add the result to a given Color4
  60093. * @param scale defines the scale factor
  60094. * @param result defines the Color4 object where to store the result
  60095. * @returns the unmodified current Color4
  60096. */
  60097. scaleAndAddToRef(scale: number, result: Color4): Color4;
  60098. /**
  60099. * Clamps the rgb values by the min and max values and stores the result into "result"
  60100. * @param min defines minimum clamping value (default is 0)
  60101. * @param max defines maximum clamping value (default is 1)
  60102. * @param result defines color to store the result into.
  60103. * @returns the cuurent Color4
  60104. */
  60105. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  60106. /**
  60107. * Multipy an Color4 value by another and return a new Color4 object
  60108. * @param color defines the Color4 value to multiply by
  60109. * @returns a new Color4 object
  60110. */
  60111. multiply(color: Color4): Color4;
  60112. /**
  60113. * Multipy a Color4 value by another and push the result in a reference value
  60114. * @param color defines the Color4 value to multiply by
  60115. * @param result defines the Color4 to fill the result in
  60116. * @returns the result Color4
  60117. */
  60118. multiplyToRef(color: Color4, result: Color4): Color4;
  60119. /**
  60120. * Creates a string with the Color4 current values
  60121. * @returns the string representation of the Color4 object
  60122. */
  60123. toString(): string;
  60124. /**
  60125. * Returns the string "Color4"
  60126. * @returns "Color4"
  60127. */
  60128. getClassName(): string;
  60129. /**
  60130. * Compute the Color4 hash code
  60131. * @returns an unique number that can be used to hash Color4 objects
  60132. */
  60133. getHashCode(): number;
  60134. /**
  60135. * Creates a new Color4 copied from the current one
  60136. * @returns a new Color4 object
  60137. */
  60138. clone(): Color4;
  60139. /**
  60140. * Copies the given Color4 values into the current one
  60141. * @param source defines the source Color4 object
  60142. * @returns the current updated Color4 object
  60143. */
  60144. copyFrom(source: Color4): Color4;
  60145. /**
  60146. * Copies the given float values into the current one
  60147. * @param r defines the red component to read from
  60148. * @param g defines the green component to read from
  60149. * @param b defines the blue component to read from
  60150. * @param a defines the alpha component to read from
  60151. * @returns the current updated Color4 object
  60152. */
  60153. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  60154. /**
  60155. * Copies the given float values into the current one
  60156. * @param r defines the red component to read from
  60157. * @param g defines the green component to read from
  60158. * @param b defines the blue component to read from
  60159. * @param a defines the alpha component to read from
  60160. * @returns the current updated Color4 object
  60161. */
  60162. set(r: number, g: number, b: number, a: number): Color4;
  60163. /**
  60164. * Compute the Color4 hexadecimal code as a string
  60165. * @returns a string containing the hexadecimal representation of the Color4 object
  60166. */
  60167. toHexString(): string;
  60168. /**
  60169. * Computes a new Color4 converted from the current one to linear space
  60170. * @returns a new Color4 object
  60171. */
  60172. toLinearSpace(): Color4;
  60173. /**
  60174. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  60175. * @param convertedColor defines the Color4 object where to store the linear space version
  60176. * @returns the unmodified Color4
  60177. */
  60178. toLinearSpaceToRef(convertedColor: Color4): Color4;
  60179. /**
  60180. * Computes a new Color4 converted from the current one to gamma space
  60181. * @returns a new Color4 object
  60182. */
  60183. toGammaSpace(): Color4;
  60184. /**
  60185. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  60186. * @param convertedColor defines the Color4 object where to store the gamma space version
  60187. * @returns the unmodified Color4
  60188. */
  60189. toGammaSpaceToRef(convertedColor: Color4): Color4;
  60190. /**
  60191. * Creates a new Color4 from the string containing valid hexadecimal values
  60192. * @param hex defines a string containing valid hexadecimal values
  60193. * @returns a new Color4 object
  60194. */
  60195. static FromHexString(hex: string): Color4;
  60196. /**
  60197. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  60198. * @param left defines the start value
  60199. * @param right defines the end value
  60200. * @param amount defines the gradient factor
  60201. * @returns a new Color4 object
  60202. */
  60203. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  60204. /**
  60205. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  60206. * @param left defines the start value
  60207. * @param right defines the end value
  60208. * @param amount defines the gradient factor
  60209. * @param result defines the Color4 object where to store data
  60210. */
  60211. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  60212. /**
  60213. * Creates a new Color4 from a Color3 and an alpha value
  60214. * @param color3 defines the source Color3 to read from
  60215. * @param alpha defines the alpha component (1.0 by default)
  60216. * @returns a new Color4 object
  60217. */
  60218. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  60219. /**
  60220. * Creates a new Color4 from the starting index element of the given array
  60221. * @param array defines the source array to read from
  60222. * @param offset defines the offset in the source array
  60223. * @returns a new Color4 object
  60224. */
  60225. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  60226. /**
  60227. * Creates a new Color3 from integer values (< 256)
  60228. * @param r defines the red component to read from (value between 0 and 255)
  60229. * @param g defines the green component to read from (value between 0 and 255)
  60230. * @param b defines the blue component to read from (value between 0 and 255)
  60231. * @param a defines the alpha component to read from (value between 0 and 255)
  60232. * @returns a new Color3 object
  60233. */
  60234. static FromInts(r: number, g: number, b: number, a: number): Color4;
  60235. /**
  60236. * Check the content of a given array and convert it to an array containing RGBA data
  60237. * If the original array was already containing count * 4 values then it is returned directly
  60238. * @param colors defines the array to check
  60239. * @param count defines the number of RGBA data to expect
  60240. * @returns an array containing count * 4 values (RGBA)
  60241. */
  60242. static CheckColors4(colors: number[], count: number): number[];
  60243. }
  60244. /**
  60245. * Class representing a vector containing 2 coordinates
  60246. */
  60247. export class Vector2 {
  60248. /** defines the first coordinate */
  60249. x: number;
  60250. /** defines the second coordinate */
  60251. y: number;
  60252. /**
  60253. * Creates a new Vector2 from the given x and y coordinates
  60254. * @param x defines the first coordinate
  60255. * @param y defines the second coordinate
  60256. */
  60257. constructor(
  60258. /** defines the first coordinate */
  60259. x?: number,
  60260. /** defines the second coordinate */
  60261. y?: number);
  60262. /**
  60263. * Gets a string with the Vector2 coordinates
  60264. * @returns a string with the Vector2 coordinates
  60265. */
  60266. toString(): string;
  60267. /**
  60268. * Gets class name
  60269. * @returns the string "Vector2"
  60270. */
  60271. getClassName(): string;
  60272. /**
  60273. * Gets current vector hash code
  60274. * @returns the Vector2 hash code as a number
  60275. */
  60276. getHashCode(): number;
  60277. /**
  60278. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  60279. * @param array defines the source array
  60280. * @param index defines the offset in source array
  60281. * @returns the current Vector2
  60282. */
  60283. toArray(array: FloatArray, index?: number): Vector2;
  60284. /**
  60285. * Copy the current vector to an array
  60286. * @returns a new array with 2 elements: the Vector2 coordinates.
  60287. */
  60288. asArray(): number[];
  60289. /**
  60290. * Sets the Vector2 coordinates with the given Vector2 coordinates
  60291. * @param source defines the source Vector2
  60292. * @returns the current updated Vector2
  60293. */
  60294. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  60295. /**
  60296. * Sets the Vector2 coordinates with the given floats
  60297. * @param x defines the first coordinate
  60298. * @param y defines the second coordinate
  60299. * @returns the current updated Vector2
  60300. */
  60301. copyFromFloats(x: number, y: number): Vector2;
  60302. /**
  60303. * Sets the Vector2 coordinates with the given floats
  60304. * @param x defines the first coordinate
  60305. * @param y defines the second coordinate
  60306. * @returns the current updated Vector2
  60307. */
  60308. set(x: number, y: number): Vector2;
  60309. /**
  60310. * Add another vector with the current one
  60311. * @param otherVector defines the other vector
  60312. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  60313. */
  60314. add(otherVector: DeepImmutable<Vector2>): Vector2;
  60315. /**
  60316. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  60317. * @param otherVector defines the other vector
  60318. * @param result defines the target vector
  60319. * @returns the unmodified current Vector2
  60320. */
  60321. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60322. /**
  60323. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  60324. * @param otherVector defines the other vector
  60325. * @returns the current updated Vector2
  60326. */
  60327. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60328. /**
  60329. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  60330. * @param otherVector defines the other vector
  60331. * @returns a new Vector2
  60332. */
  60333. addVector3(otherVector: Vector3): Vector2;
  60334. /**
  60335. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  60336. * @param otherVector defines the other vector
  60337. * @returns a new Vector2
  60338. */
  60339. subtract(otherVector: Vector2): Vector2;
  60340. /**
  60341. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  60342. * @param otherVector defines the other vector
  60343. * @param result defines the target vector
  60344. * @returns the unmodified current Vector2
  60345. */
  60346. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60347. /**
  60348. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  60349. * @param otherVector defines the other vector
  60350. * @returns the current updated Vector2
  60351. */
  60352. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60353. /**
  60354. * Multiplies in place the current Vector2 coordinates by the given ones
  60355. * @param otherVector defines the other vector
  60356. * @returns the current updated Vector2
  60357. */
  60358. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60359. /**
  60360. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  60361. * @param otherVector defines the other vector
  60362. * @returns a new Vector2
  60363. */
  60364. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  60365. /**
  60366. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  60367. * @param otherVector defines the other vector
  60368. * @param result defines the target vector
  60369. * @returns the unmodified current Vector2
  60370. */
  60371. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60372. /**
  60373. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  60374. * @param x defines the first coordinate
  60375. * @param y defines the second coordinate
  60376. * @returns a new Vector2
  60377. */
  60378. multiplyByFloats(x: number, y: number): Vector2;
  60379. /**
  60380. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  60381. * @param otherVector defines the other vector
  60382. * @returns a new Vector2
  60383. */
  60384. divide(otherVector: Vector2): Vector2;
  60385. /**
  60386. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  60387. * @param otherVector defines the other vector
  60388. * @param result defines the target vector
  60389. * @returns the unmodified current Vector2
  60390. */
  60391. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60392. /**
  60393. * Divides the current Vector2 coordinates by the given ones
  60394. * @param otherVector defines the other vector
  60395. * @returns the current updated Vector2
  60396. */
  60397. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60398. /**
  60399. * Gets a new Vector2 with current Vector2 negated coordinates
  60400. * @returns a new Vector2
  60401. */
  60402. negate(): Vector2;
  60403. /**
  60404. * Multiply the Vector2 coordinates by scale
  60405. * @param scale defines the scaling factor
  60406. * @returns the current updated Vector2
  60407. */
  60408. scaleInPlace(scale: number): Vector2;
  60409. /**
  60410. * Returns a new Vector2 scaled by "scale" from the current Vector2
  60411. * @param scale defines the scaling factor
  60412. * @returns a new Vector2
  60413. */
  60414. scale(scale: number): Vector2;
  60415. /**
  60416. * Scale the current Vector2 values by a factor to a given Vector2
  60417. * @param scale defines the scale factor
  60418. * @param result defines the Vector2 object where to store the result
  60419. * @returns the unmodified current Vector2
  60420. */
  60421. scaleToRef(scale: number, result: Vector2): Vector2;
  60422. /**
  60423. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  60424. * @param scale defines the scale factor
  60425. * @param result defines the Vector2 object where to store the result
  60426. * @returns the unmodified current Vector2
  60427. */
  60428. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  60429. /**
  60430. * Gets a boolean if two vectors are equals
  60431. * @param otherVector defines the other vector
  60432. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  60433. */
  60434. equals(otherVector: DeepImmutable<Vector2>): boolean;
  60435. /**
  60436. * Gets a boolean if two vectors are equals (using an epsilon value)
  60437. * @param otherVector defines the other vector
  60438. * @param epsilon defines the minimal distance to consider equality
  60439. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  60440. */
  60441. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  60442. /**
  60443. * Gets a new Vector2 from current Vector2 floored values
  60444. * @returns a new Vector2
  60445. */
  60446. floor(): Vector2;
  60447. /**
  60448. * Gets a new Vector2 from current Vector2 floored values
  60449. * @returns a new Vector2
  60450. */
  60451. fract(): Vector2;
  60452. /**
  60453. * Gets the length of the vector
  60454. * @returns the vector length (float)
  60455. */
  60456. length(): number;
  60457. /**
  60458. * Gets the vector squared length
  60459. * @returns the vector squared length (float)
  60460. */
  60461. lengthSquared(): number;
  60462. /**
  60463. * Normalize the vector
  60464. * @returns the current updated Vector2
  60465. */
  60466. normalize(): Vector2;
  60467. /**
  60468. * Gets a new Vector2 copied from the Vector2
  60469. * @returns a new Vector2
  60470. */
  60471. clone(): Vector2;
  60472. /**
  60473. * Gets a new Vector2(0, 0)
  60474. * @returns a new Vector2
  60475. */
  60476. static Zero(): Vector2;
  60477. /**
  60478. * Gets a new Vector2(1, 1)
  60479. * @returns a new Vector2
  60480. */
  60481. static One(): Vector2;
  60482. /**
  60483. * Gets a new Vector2 set from the given index element of the given array
  60484. * @param array defines the data source
  60485. * @param offset defines the offset in the data source
  60486. * @returns a new Vector2
  60487. */
  60488. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  60489. /**
  60490. * Sets "result" from the given index element of the given array
  60491. * @param array defines the data source
  60492. * @param offset defines the offset in the data source
  60493. * @param result defines the target vector
  60494. */
  60495. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  60496. /**
  60497. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  60498. * @param value1 defines 1st point of control
  60499. * @param value2 defines 2nd point of control
  60500. * @param value3 defines 3rd point of control
  60501. * @param value4 defines 4th point of control
  60502. * @param amount defines the interpolation factor
  60503. * @returns a new Vector2
  60504. */
  60505. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  60506. /**
  60507. * 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".
  60508. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  60509. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  60510. * @param value defines the value to clamp
  60511. * @param min defines the lower limit
  60512. * @param max defines the upper limit
  60513. * @returns a new Vector2
  60514. */
  60515. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  60516. /**
  60517. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  60518. * @param value1 defines the 1st control point
  60519. * @param tangent1 defines the outgoing tangent
  60520. * @param value2 defines the 2nd control point
  60521. * @param tangent2 defines the incoming tangent
  60522. * @param amount defines the interpolation factor
  60523. * @returns a new Vector2
  60524. */
  60525. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  60526. /**
  60527. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  60528. * @param start defines the start vector
  60529. * @param end defines the end vector
  60530. * @param amount defines the interpolation factor
  60531. * @returns a new Vector2
  60532. */
  60533. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  60534. /**
  60535. * Gets the dot product of the vector "left" and the vector "right"
  60536. * @param left defines first vector
  60537. * @param right defines second vector
  60538. * @returns the dot product (float)
  60539. */
  60540. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  60541. /**
  60542. * Returns a new Vector2 equal to the normalized given vector
  60543. * @param vector defines the vector to normalize
  60544. * @returns a new Vector2
  60545. */
  60546. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  60547. /**
  60548. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  60549. * @param left defines 1st vector
  60550. * @param right defines 2nd vector
  60551. * @returns a new Vector2
  60552. */
  60553. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  60554. /**
  60555. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  60556. * @param left defines 1st vector
  60557. * @param right defines 2nd vector
  60558. * @returns a new Vector2
  60559. */
  60560. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  60561. /**
  60562. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  60563. * @param vector defines the vector to transform
  60564. * @param transformation defines the matrix to apply
  60565. * @returns a new Vector2
  60566. */
  60567. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  60568. /**
  60569. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  60570. * @param vector defines the vector to transform
  60571. * @param transformation defines the matrix to apply
  60572. * @param result defines the target vector
  60573. */
  60574. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  60575. /**
  60576. * Determines if a given vector is included in a triangle
  60577. * @param p defines the vector to test
  60578. * @param p0 defines 1st triangle point
  60579. * @param p1 defines 2nd triangle point
  60580. * @param p2 defines 3rd triangle point
  60581. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  60582. */
  60583. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  60584. /**
  60585. * Gets the distance between the vectors "value1" and "value2"
  60586. * @param value1 defines first vector
  60587. * @param value2 defines second vector
  60588. * @returns the distance between vectors
  60589. */
  60590. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  60591. /**
  60592. * Returns the squared distance between the vectors "value1" and "value2"
  60593. * @param value1 defines first vector
  60594. * @param value2 defines second vector
  60595. * @returns the squared distance between vectors
  60596. */
  60597. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  60598. /**
  60599. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  60600. * @param value1 defines first vector
  60601. * @param value2 defines second vector
  60602. * @returns a new Vector2
  60603. */
  60604. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  60605. /**
  60606. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  60607. * @param p defines the middle point
  60608. * @param segA defines one point of the segment
  60609. * @param segB defines the other point of the segment
  60610. * @returns the shortest distance
  60611. */
  60612. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  60613. }
  60614. /**
  60615. * Classed used to store (x,y,z) vector representation
  60616. * A Vector3 is the main object used in 3D geometry
  60617. * It can represent etiher the coordinates of a point the space, either a direction
  60618. * Reminder: js uses a left handed forward facing system
  60619. */
  60620. export class Vector3 {
  60621. /**
  60622. * Defines the first coordinates (on X axis)
  60623. */
  60624. x: number;
  60625. /**
  60626. * Defines the second coordinates (on Y axis)
  60627. */
  60628. y: number;
  60629. /**
  60630. * Defines the third coordinates (on Z axis)
  60631. */
  60632. z: number;
  60633. private static _UpReadOnly;
  60634. /**
  60635. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  60636. * @param x defines the first coordinates (on X axis)
  60637. * @param y defines the second coordinates (on Y axis)
  60638. * @param z defines the third coordinates (on Z axis)
  60639. */
  60640. constructor(
  60641. /**
  60642. * Defines the first coordinates (on X axis)
  60643. */
  60644. x?: number,
  60645. /**
  60646. * Defines the second coordinates (on Y axis)
  60647. */
  60648. y?: number,
  60649. /**
  60650. * Defines the third coordinates (on Z axis)
  60651. */
  60652. z?: number);
  60653. /**
  60654. * Creates a string representation of the Vector3
  60655. * @returns a string with the Vector3 coordinates.
  60656. */
  60657. toString(): string;
  60658. /**
  60659. * Gets the class name
  60660. * @returns the string "Vector3"
  60661. */
  60662. getClassName(): string;
  60663. /**
  60664. * Creates the Vector3 hash code
  60665. * @returns a number which tends to be unique between Vector3 instances
  60666. */
  60667. getHashCode(): number;
  60668. /**
  60669. * Creates an array containing three elements : the coordinates of the Vector3
  60670. * @returns a new array of numbers
  60671. */
  60672. asArray(): number[];
  60673. /**
  60674. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  60675. * @param array defines the destination array
  60676. * @param index defines the offset in the destination array
  60677. * @returns the current Vector3
  60678. */
  60679. toArray(array: FloatArray, index?: number): Vector3;
  60680. /**
  60681. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  60682. * @returns a new Quaternion object, computed from the Vector3 coordinates
  60683. */
  60684. toQuaternion(): Quaternion;
  60685. /**
  60686. * Adds the given vector to the current Vector3
  60687. * @param otherVector defines the second operand
  60688. * @returns the current updated Vector3
  60689. */
  60690. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  60691. /**
  60692. * Adds the given coordinates to the current Vector3
  60693. * @param x defines the x coordinate of the operand
  60694. * @param y defines the y coordinate of the operand
  60695. * @param z defines the z coordinate of the operand
  60696. * @returns the current updated Vector3
  60697. */
  60698. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  60699. /**
  60700. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  60701. * @param otherVector defines the second operand
  60702. * @returns the resulting Vector3
  60703. */
  60704. add(otherVector: DeepImmutable<Vector3>): Vector3;
  60705. /**
  60706. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  60707. * @param otherVector defines the second operand
  60708. * @param result defines the Vector3 object where to store the result
  60709. * @returns the current Vector3
  60710. */
  60711. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  60712. /**
  60713. * Subtract the given vector from the current Vector3
  60714. * @param otherVector defines the second operand
  60715. * @returns the current updated Vector3
  60716. */
  60717. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  60718. /**
  60719. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  60720. * @param otherVector defines the second operand
  60721. * @returns the resulting Vector3
  60722. */
  60723. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  60724. /**
  60725. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  60726. * @param otherVector defines the second operand
  60727. * @param result defines the Vector3 object where to store the result
  60728. * @returns the current Vector3
  60729. */
  60730. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  60731. /**
  60732. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  60733. * @param x defines the x coordinate of the operand
  60734. * @param y defines the y coordinate of the operand
  60735. * @param z defines the z coordinate of the operand
  60736. * @returns the resulting Vector3
  60737. */
  60738. subtractFromFloats(x: number, y: number, z: number): Vector3;
  60739. /**
  60740. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  60741. * @param x defines the x coordinate of the operand
  60742. * @param y defines the y coordinate of the operand
  60743. * @param z defines the z coordinate of the operand
  60744. * @param result defines the Vector3 object where to store the result
  60745. * @returns the current Vector3
  60746. */
  60747. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  60748. /**
  60749. * Gets a new Vector3 set with the current Vector3 negated coordinates
  60750. * @returns a new Vector3
  60751. */
  60752. negate(): Vector3;
  60753. /**
  60754. * Multiplies the Vector3 coordinates by the float "scale"
  60755. * @param scale defines the multiplier factor
  60756. * @returns the current updated Vector3
  60757. */
  60758. scaleInPlace(scale: number): Vector3;
  60759. /**
  60760. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  60761. * @param scale defines the multiplier factor
  60762. * @returns a new Vector3
  60763. */
  60764. scale(scale: number): Vector3;
  60765. /**
  60766. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  60767. * @param scale defines the multiplier factor
  60768. * @param result defines the Vector3 object where to store the result
  60769. * @returns the current Vector3
  60770. */
  60771. scaleToRef(scale: number, result: Vector3): Vector3;
  60772. /**
  60773. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  60774. * @param scale defines the scale factor
  60775. * @param result defines the Vector3 object where to store the result
  60776. * @returns the unmodified current Vector3
  60777. */
  60778. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  60779. /**
  60780. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  60781. * @param otherVector defines the second operand
  60782. * @returns true if both vectors are equals
  60783. */
  60784. equals(otherVector: DeepImmutable<Vector3>): boolean;
  60785. /**
  60786. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  60787. * @param otherVector defines the second operand
  60788. * @param epsilon defines the minimal distance to define values as equals
  60789. * @returns true if both vectors are distant less than epsilon
  60790. */
  60791. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  60792. /**
  60793. * Returns true if the current Vector3 coordinates equals the given floats
  60794. * @param x defines the x coordinate of the operand
  60795. * @param y defines the y coordinate of the operand
  60796. * @param z defines the z coordinate of the operand
  60797. * @returns true if both vectors are equals
  60798. */
  60799. equalsToFloats(x: number, y: number, z: number): boolean;
  60800. /**
  60801. * Multiplies the current Vector3 coordinates by the given ones
  60802. * @param otherVector defines the second operand
  60803. * @returns the current updated Vector3
  60804. */
  60805. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  60806. /**
  60807. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  60808. * @param otherVector defines the second operand
  60809. * @returns the new Vector3
  60810. */
  60811. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  60812. /**
  60813. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  60814. * @param otherVector defines the second operand
  60815. * @param result defines the Vector3 object where to store the result
  60816. * @returns the current Vector3
  60817. */
  60818. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  60819. /**
  60820. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  60821. * @param x defines the x coordinate of the operand
  60822. * @param y defines the y coordinate of the operand
  60823. * @param z defines the z coordinate of the operand
  60824. * @returns the new Vector3
  60825. */
  60826. multiplyByFloats(x: number, y: number, z: number): Vector3;
  60827. /**
  60828. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  60829. * @param otherVector defines the second operand
  60830. * @returns the new Vector3
  60831. */
  60832. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  60833. /**
  60834. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  60835. * @param otherVector defines the second operand
  60836. * @param result defines the Vector3 object where to store the result
  60837. * @returns the current Vector3
  60838. */
  60839. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  60840. /**
  60841. * Divides the current Vector3 coordinates by the given ones.
  60842. * @param otherVector defines the second operand
  60843. * @returns the current updated Vector3
  60844. */
  60845. divideInPlace(otherVector: Vector3): Vector3;
  60846. /**
  60847. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  60848. * @param other defines the second operand
  60849. * @returns the current updated Vector3
  60850. */
  60851. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  60852. /**
  60853. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  60854. * @param other defines the second operand
  60855. * @returns the current updated Vector3
  60856. */
  60857. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  60858. /**
  60859. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  60860. * @param x defines the x coordinate of the operand
  60861. * @param y defines the y coordinate of the operand
  60862. * @param z defines the z coordinate of the operand
  60863. * @returns the current updated Vector3
  60864. */
  60865. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  60866. /**
  60867. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  60868. * @param x defines the x coordinate of the operand
  60869. * @param y defines the y coordinate of the operand
  60870. * @param z defines the z coordinate of the operand
  60871. * @returns the current updated Vector3
  60872. */
  60873. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  60874. /**
  60875. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  60876. * Check if is non uniform within a certain amount of decimal places to account for this
  60877. * @param epsilon the amount the values can differ
  60878. * @returns if the the vector is non uniform to a certain number of decimal places
  60879. */
  60880. isNonUniformWithinEpsilon(epsilon: number): boolean;
  60881. /**
  60882. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  60883. */
  60884. readonly isNonUniform: boolean;
  60885. /**
  60886. * Gets a new Vector3 from current Vector3 floored values
  60887. * @returns a new Vector3
  60888. */
  60889. floor(): Vector3;
  60890. /**
  60891. * Gets a new Vector3 from current Vector3 floored values
  60892. * @returns a new Vector3
  60893. */
  60894. fract(): Vector3;
  60895. /**
  60896. * Gets the length of the Vector3
  60897. * @returns the length of the Vecto3
  60898. */
  60899. length(): number;
  60900. /**
  60901. * Gets the squared length of the Vector3
  60902. * @returns squared length of the Vector3
  60903. */
  60904. lengthSquared(): number;
  60905. /**
  60906. * Normalize the current Vector3.
  60907. * Please note that this is an in place operation.
  60908. * @returns the current updated Vector3
  60909. */
  60910. normalize(): Vector3;
  60911. /**
  60912. * Reorders the x y z properties of the vector in place
  60913. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  60914. * @returns the current updated vector
  60915. */
  60916. reorderInPlace(order: string): this;
  60917. /**
  60918. * Rotates the vector around 0,0,0 by a quaternion
  60919. * @param quaternion the rotation quaternion
  60920. * @param result vector to store the result
  60921. * @returns the resulting vector
  60922. */
  60923. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  60924. /**
  60925. * Rotates a vector around a given point
  60926. * @param quaternion the rotation quaternion
  60927. * @param point the point to rotate around
  60928. * @param result vector to store the result
  60929. * @returns the resulting vector
  60930. */
  60931. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  60932. /**
  60933. * Normalize the current Vector3 with the given input length.
  60934. * Please note that this is an in place operation.
  60935. * @param len the length of the vector
  60936. * @returns the current updated Vector3
  60937. */
  60938. normalizeFromLength(len: number): Vector3;
  60939. /**
  60940. * Normalize the current Vector3 to a new vector
  60941. * @returns the new Vector3
  60942. */
  60943. normalizeToNew(): Vector3;
  60944. /**
  60945. * Normalize the current Vector3 to the reference
  60946. * @param reference define the Vector3 to update
  60947. * @returns the updated Vector3
  60948. */
  60949. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  60950. /**
  60951. * Creates a new Vector3 copied from the current Vector3
  60952. * @returns the new Vector3
  60953. */
  60954. clone(): Vector3;
  60955. /**
  60956. * Copies the given vector coordinates to the current Vector3 ones
  60957. * @param source defines the source Vector3
  60958. * @returns the current updated Vector3
  60959. */
  60960. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  60961. /**
  60962. * Copies the given floats to the current Vector3 coordinates
  60963. * @param x defines the x coordinate of the operand
  60964. * @param y defines the y coordinate of the operand
  60965. * @param z defines the z coordinate of the operand
  60966. * @returns the current updated Vector3
  60967. */
  60968. copyFromFloats(x: number, y: number, z: number): Vector3;
  60969. /**
  60970. * Copies the given floats to the current Vector3 coordinates
  60971. * @param x defines the x coordinate of the operand
  60972. * @param y defines the y coordinate of the operand
  60973. * @param z defines the z coordinate of the operand
  60974. * @returns the current updated Vector3
  60975. */
  60976. set(x: number, y: number, z: number): Vector3;
  60977. /**
  60978. * Copies the given float to the current Vector3 coordinates
  60979. * @param v defines the x, y and z coordinates of the operand
  60980. * @returns the current updated Vector3
  60981. */
  60982. setAll(v: number): Vector3;
  60983. /**
  60984. * Get the clip factor between two vectors
  60985. * @param vector0 defines the first operand
  60986. * @param vector1 defines the second operand
  60987. * @param axis defines the axis to use
  60988. * @param size defines the size along the axis
  60989. * @returns the clip factor
  60990. */
  60991. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  60992. /**
  60993. * Get angle between two vectors
  60994. * @param vector0 angle between vector0 and vector1
  60995. * @param vector1 angle between vector0 and vector1
  60996. * @param normal direction of the normal
  60997. * @return the angle between vector0 and vector1
  60998. */
  60999. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  61000. /**
  61001. * Returns a new Vector3 set from the index "offset" of the given array
  61002. * @param array defines the source array
  61003. * @param offset defines the offset in the source array
  61004. * @returns the new Vector3
  61005. */
  61006. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  61007. /**
  61008. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  61009. * This function is deprecated. Use FromArray instead
  61010. * @param array defines the source array
  61011. * @param offset defines the offset in the source array
  61012. * @returns the new Vector3
  61013. */
  61014. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  61015. /**
  61016. * Sets the given vector "result" with the element values from the index "offset" of the given array
  61017. * @param array defines the source array
  61018. * @param offset defines the offset in the source array
  61019. * @param result defines the Vector3 where to store the result
  61020. */
  61021. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  61022. /**
  61023. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  61024. * This function is deprecated. Use FromArrayToRef instead.
  61025. * @param array defines the source array
  61026. * @param offset defines the offset in the source array
  61027. * @param result defines the Vector3 where to store the result
  61028. */
  61029. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  61030. /**
  61031. * Sets the given vector "result" with the given floats.
  61032. * @param x defines the x coordinate of the source
  61033. * @param y defines the y coordinate of the source
  61034. * @param z defines the z coordinate of the source
  61035. * @param result defines the Vector3 where to store the result
  61036. */
  61037. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  61038. /**
  61039. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  61040. * @returns a new empty Vector3
  61041. */
  61042. static Zero(): Vector3;
  61043. /**
  61044. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  61045. * @returns a new unit Vector3
  61046. */
  61047. static One(): Vector3;
  61048. /**
  61049. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  61050. * @returns a new up Vector3
  61051. */
  61052. static Up(): Vector3;
  61053. /**
  61054. * Gets a up Vector3 that must not be updated
  61055. */
  61056. static readonly UpReadOnly: DeepImmutable<Vector3>;
  61057. /**
  61058. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  61059. * @returns a new down Vector3
  61060. */
  61061. static Down(): Vector3;
  61062. /**
  61063. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  61064. * @returns a new forward Vector3
  61065. */
  61066. static Forward(): Vector3;
  61067. /**
  61068. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  61069. * @returns a new forward Vector3
  61070. */
  61071. static Backward(): Vector3;
  61072. /**
  61073. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  61074. * @returns a new right Vector3
  61075. */
  61076. static Right(): Vector3;
  61077. /**
  61078. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  61079. * @returns a new left Vector3
  61080. */
  61081. static Left(): Vector3;
  61082. /**
  61083. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  61084. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  61085. * @param vector defines the Vector3 to transform
  61086. * @param transformation defines the transformation matrix
  61087. * @returns the transformed Vector3
  61088. */
  61089. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  61090. /**
  61091. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  61092. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  61093. * @param vector defines the Vector3 to transform
  61094. * @param transformation defines the transformation matrix
  61095. * @param result defines the Vector3 where to store the result
  61096. */
  61097. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61098. /**
  61099. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  61100. * This method computes tranformed coordinates only, not transformed direction vectors
  61101. * @param x define the x coordinate of the source vector
  61102. * @param y define the y coordinate of the source vector
  61103. * @param z define the z coordinate of the source vector
  61104. * @param transformation defines the transformation matrix
  61105. * @param result defines the Vector3 where to store the result
  61106. */
  61107. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61108. /**
  61109. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  61110. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61111. * @param vector defines the Vector3 to transform
  61112. * @param transformation defines the transformation matrix
  61113. * @returns the new Vector3
  61114. */
  61115. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  61116. /**
  61117. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  61118. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61119. * @param vector defines the Vector3 to transform
  61120. * @param transformation defines the transformation matrix
  61121. * @param result defines the Vector3 where to store the result
  61122. */
  61123. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61124. /**
  61125. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  61126. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61127. * @param x define the x coordinate of the source vector
  61128. * @param y define the y coordinate of the source vector
  61129. * @param z define the z coordinate of the source vector
  61130. * @param transformation defines the transformation matrix
  61131. * @param result defines the Vector3 where to store the result
  61132. */
  61133. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61134. /**
  61135. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  61136. * @param value1 defines the first control point
  61137. * @param value2 defines the second control point
  61138. * @param value3 defines the third control point
  61139. * @param value4 defines the fourth control point
  61140. * @param amount defines the amount on the spline to use
  61141. * @returns the new Vector3
  61142. */
  61143. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  61144. /**
  61145. * 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"
  61146. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  61147. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  61148. * @param value defines the current value
  61149. * @param min defines the lower range value
  61150. * @param max defines the upper range value
  61151. * @returns the new Vector3
  61152. */
  61153. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  61154. /**
  61155. * 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"
  61156. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  61157. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  61158. * @param value defines the current value
  61159. * @param min defines the lower range value
  61160. * @param max defines the upper range value
  61161. * @param result defines the Vector3 where to store the result
  61162. */
  61163. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  61164. /**
  61165. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  61166. * @param value1 defines the first control point
  61167. * @param tangent1 defines the first tangent vector
  61168. * @param value2 defines the second control point
  61169. * @param tangent2 defines the second tangent vector
  61170. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  61171. * @returns the new Vector3
  61172. */
  61173. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  61174. /**
  61175. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  61176. * @param start defines the start value
  61177. * @param end defines the end value
  61178. * @param amount max defines amount between both (between 0 and 1)
  61179. * @returns the new Vector3
  61180. */
  61181. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  61182. /**
  61183. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  61184. * @param start defines the start value
  61185. * @param end defines the end value
  61186. * @param amount max defines amount between both (between 0 and 1)
  61187. * @param result defines the Vector3 where to store the result
  61188. */
  61189. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  61190. /**
  61191. * Returns the dot product (float) between the vectors "left" and "right"
  61192. * @param left defines the left operand
  61193. * @param right defines the right operand
  61194. * @returns the dot product
  61195. */
  61196. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  61197. /**
  61198. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  61199. * The cross product is then orthogonal to both "left" and "right"
  61200. * @param left defines the left operand
  61201. * @param right defines the right operand
  61202. * @returns the cross product
  61203. */
  61204. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61205. /**
  61206. * Sets the given vector "result" with the cross product of "left" and "right"
  61207. * The cross product is then orthogonal to both "left" and "right"
  61208. * @param left defines the left operand
  61209. * @param right defines the right operand
  61210. * @param result defines the Vector3 where to store the result
  61211. */
  61212. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  61213. /**
  61214. * Returns a new Vector3 as the normalization of the given vector
  61215. * @param vector defines the Vector3 to normalize
  61216. * @returns the new Vector3
  61217. */
  61218. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  61219. /**
  61220. * Sets the given vector "result" with the normalization of the given first vector
  61221. * @param vector defines the Vector3 to normalize
  61222. * @param result defines the Vector3 where to store the result
  61223. */
  61224. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  61225. /**
  61226. * Project a Vector3 onto screen space
  61227. * @param vector defines the Vector3 to project
  61228. * @param world defines the world matrix to use
  61229. * @param transform defines the transform (view x projection) matrix to use
  61230. * @param viewport defines the screen viewport to use
  61231. * @returns the new Vector3
  61232. */
  61233. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  61234. /** @hidden */
  61235. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  61236. /**
  61237. * Unproject from screen space to object space
  61238. * @param source defines the screen space Vector3 to use
  61239. * @param viewportWidth defines the current width of the viewport
  61240. * @param viewportHeight defines the current height of the viewport
  61241. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61242. * @param transform defines the transform (view x projection) matrix to use
  61243. * @returns the new Vector3
  61244. */
  61245. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  61246. /**
  61247. * Unproject from screen space to object space
  61248. * @param source defines the screen space Vector3 to use
  61249. * @param viewportWidth defines the current width of the viewport
  61250. * @param viewportHeight defines the current height of the viewport
  61251. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61252. * @param view defines the view matrix to use
  61253. * @param projection defines the projection matrix to use
  61254. * @returns the new Vector3
  61255. */
  61256. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  61257. /**
  61258. * Unproject from screen space to object space
  61259. * @param source defines the screen space Vector3 to use
  61260. * @param viewportWidth defines the current width of the viewport
  61261. * @param viewportHeight defines the current height of the viewport
  61262. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61263. * @param view defines the view matrix to use
  61264. * @param projection defines the projection matrix to use
  61265. * @param result defines the Vector3 where to store the result
  61266. */
  61267. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  61268. /**
  61269. * Unproject from screen space to object space
  61270. * @param sourceX defines the screen space x coordinate to use
  61271. * @param sourceY defines the screen space y coordinate to use
  61272. * @param sourceZ defines the screen space z coordinate to use
  61273. * @param viewportWidth defines the current width of the viewport
  61274. * @param viewportHeight defines the current height of the viewport
  61275. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61276. * @param view defines the view matrix to use
  61277. * @param projection defines the projection matrix to use
  61278. * @param result defines the Vector3 where to store the result
  61279. */
  61280. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  61281. /**
  61282. * Gets the minimal coordinate values between two Vector3
  61283. * @param left defines the first operand
  61284. * @param right defines the second operand
  61285. * @returns the new Vector3
  61286. */
  61287. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61288. /**
  61289. * Gets the maximal coordinate values between two Vector3
  61290. * @param left defines the first operand
  61291. * @param right defines the second operand
  61292. * @returns the new Vector3
  61293. */
  61294. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61295. /**
  61296. * Returns the distance between the vectors "value1" and "value2"
  61297. * @param value1 defines the first operand
  61298. * @param value2 defines the second operand
  61299. * @returns the distance
  61300. */
  61301. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  61302. /**
  61303. * Returns the squared distance between the vectors "value1" and "value2"
  61304. * @param value1 defines the first operand
  61305. * @param value2 defines the second operand
  61306. * @returns the squared distance
  61307. */
  61308. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  61309. /**
  61310. * Returns a new Vector3 located at the center between "value1" and "value2"
  61311. * @param value1 defines the first operand
  61312. * @param value2 defines the second operand
  61313. * @returns the new Vector3
  61314. */
  61315. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  61316. /**
  61317. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  61318. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  61319. * to something in order to rotate it from its local system to the given target system
  61320. * Note: axis1, axis2 and axis3 are normalized during this operation
  61321. * @param axis1 defines the first axis
  61322. * @param axis2 defines the second axis
  61323. * @param axis3 defines the third axis
  61324. * @returns a new Vector3
  61325. */
  61326. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  61327. /**
  61328. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  61329. * @param axis1 defines the first axis
  61330. * @param axis2 defines the second axis
  61331. * @param axis3 defines the third axis
  61332. * @param ref defines the Vector3 where to store the result
  61333. */
  61334. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  61335. }
  61336. /**
  61337. * Vector4 class created for EulerAngle class conversion to Quaternion
  61338. */
  61339. export class Vector4 {
  61340. /** x value of the vector */
  61341. x: number;
  61342. /** y value of the vector */
  61343. y: number;
  61344. /** z value of the vector */
  61345. z: number;
  61346. /** w value of the vector */
  61347. w: number;
  61348. /**
  61349. * Creates a Vector4 object from the given floats.
  61350. * @param x x value of the vector
  61351. * @param y y value of the vector
  61352. * @param z z value of the vector
  61353. * @param w w value of the vector
  61354. */
  61355. constructor(
  61356. /** x value of the vector */
  61357. x: number,
  61358. /** y value of the vector */
  61359. y: number,
  61360. /** z value of the vector */
  61361. z: number,
  61362. /** w value of the vector */
  61363. w: number);
  61364. /**
  61365. * Returns the string with the Vector4 coordinates.
  61366. * @returns a string containing all the vector values
  61367. */
  61368. toString(): string;
  61369. /**
  61370. * Returns the string "Vector4".
  61371. * @returns "Vector4"
  61372. */
  61373. getClassName(): string;
  61374. /**
  61375. * Returns the Vector4 hash code.
  61376. * @returns a unique hash code
  61377. */
  61378. getHashCode(): number;
  61379. /**
  61380. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  61381. * @returns the resulting array
  61382. */
  61383. asArray(): number[];
  61384. /**
  61385. * Populates the given array from the given index with the Vector4 coordinates.
  61386. * @param array array to populate
  61387. * @param index index of the array to start at (default: 0)
  61388. * @returns the Vector4.
  61389. */
  61390. toArray(array: FloatArray, index?: number): Vector4;
  61391. /**
  61392. * Adds the given vector to the current Vector4.
  61393. * @param otherVector the vector to add
  61394. * @returns the updated Vector4.
  61395. */
  61396. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61397. /**
  61398. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  61399. * @param otherVector the vector to add
  61400. * @returns the resulting vector
  61401. */
  61402. add(otherVector: DeepImmutable<Vector4>): Vector4;
  61403. /**
  61404. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  61405. * @param otherVector the vector to add
  61406. * @param result the vector to store the result
  61407. * @returns the current Vector4.
  61408. */
  61409. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61410. /**
  61411. * Subtract in place the given vector from the current Vector4.
  61412. * @param otherVector the vector to subtract
  61413. * @returns the updated Vector4.
  61414. */
  61415. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61416. /**
  61417. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  61418. * @param otherVector the vector to add
  61419. * @returns the new vector with the result
  61420. */
  61421. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  61422. /**
  61423. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  61424. * @param otherVector the vector to subtract
  61425. * @param result the vector to store the result
  61426. * @returns the current Vector4.
  61427. */
  61428. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61429. /**
  61430. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61431. */
  61432. /**
  61433. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61434. * @param x value to subtract
  61435. * @param y value to subtract
  61436. * @param z value to subtract
  61437. * @param w value to subtract
  61438. * @returns new vector containing the result
  61439. */
  61440. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  61441. /**
  61442. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61443. * @param x value to subtract
  61444. * @param y value to subtract
  61445. * @param z value to subtract
  61446. * @param w value to subtract
  61447. * @param result the vector to store the result in
  61448. * @returns the current Vector4.
  61449. */
  61450. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  61451. /**
  61452. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  61453. * @returns a new vector with the negated values
  61454. */
  61455. negate(): Vector4;
  61456. /**
  61457. * Multiplies the current Vector4 coordinates by scale (float).
  61458. * @param scale the number to scale with
  61459. * @returns the updated Vector4.
  61460. */
  61461. scaleInPlace(scale: number): Vector4;
  61462. /**
  61463. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  61464. * @param scale the number to scale with
  61465. * @returns a new vector with the result
  61466. */
  61467. scale(scale: number): Vector4;
  61468. /**
  61469. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  61470. * @param scale the number to scale with
  61471. * @param result a vector to store the result in
  61472. * @returns the current Vector4.
  61473. */
  61474. scaleToRef(scale: number, result: Vector4): Vector4;
  61475. /**
  61476. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  61477. * @param scale defines the scale factor
  61478. * @param result defines the Vector4 object where to store the result
  61479. * @returns the unmodified current Vector4
  61480. */
  61481. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  61482. /**
  61483. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  61484. * @param otherVector the vector to compare against
  61485. * @returns true if they are equal
  61486. */
  61487. equals(otherVector: DeepImmutable<Vector4>): boolean;
  61488. /**
  61489. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  61490. * @param otherVector vector to compare against
  61491. * @param epsilon (Default: very small number)
  61492. * @returns true if they are equal
  61493. */
  61494. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  61495. /**
  61496. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  61497. * @param x x value to compare against
  61498. * @param y y value to compare against
  61499. * @param z z value to compare against
  61500. * @param w w value to compare against
  61501. * @returns true if equal
  61502. */
  61503. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  61504. /**
  61505. * Multiplies in place the current Vector4 by the given one.
  61506. * @param otherVector vector to multiple with
  61507. * @returns the updated Vector4.
  61508. */
  61509. multiplyInPlace(otherVector: Vector4): Vector4;
  61510. /**
  61511. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  61512. * @param otherVector vector to multiple with
  61513. * @returns resulting new vector
  61514. */
  61515. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  61516. /**
  61517. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  61518. * @param otherVector vector to multiple with
  61519. * @param result vector to store the result
  61520. * @returns the current Vector4.
  61521. */
  61522. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61523. /**
  61524. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  61525. * @param x x value multiply with
  61526. * @param y y value multiply with
  61527. * @param z z value multiply with
  61528. * @param w w value multiply with
  61529. * @returns resulting new vector
  61530. */
  61531. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  61532. /**
  61533. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  61534. * @param otherVector vector to devide with
  61535. * @returns resulting new vector
  61536. */
  61537. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  61538. /**
  61539. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  61540. * @param otherVector vector to devide with
  61541. * @param result vector to store the result
  61542. * @returns the current Vector4.
  61543. */
  61544. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61545. /**
  61546. * Divides the current Vector3 coordinates by the given ones.
  61547. * @param otherVector vector to devide with
  61548. * @returns the updated Vector3.
  61549. */
  61550. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61551. /**
  61552. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  61553. * @param other defines the second operand
  61554. * @returns the current updated Vector4
  61555. */
  61556. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  61557. /**
  61558. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  61559. * @param other defines the second operand
  61560. * @returns the current updated Vector4
  61561. */
  61562. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  61563. /**
  61564. * Gets a new Vector4 from current Vector4 floored values
  61565. * @returns a new Vector4
  61566. */
  61567. floor(): Vector4;
  61568. /**
  61569. * Gets a new Vector4 from current Vector3 floored values
  61570. * @returns a new Vector4
  61571. */
  61572. fract(): Vector4;
  61573. /**
  61574. * Returns the Vector4 length (float).
  61575. * @returns the length
  61576. */
  61577. length(): number;
  61578. /**
  61579. * Returns the Vector4 squared length (float).
  61580. * @returns the length squared
  61581. */
  61582. lengthSquared(): number;
  61583. /**
  61584. * Normalizes in place the Vector4.
  61585. * @returns the updated Vector4.
  61586. */
  61587. normalize(): Vector4;
  61588. /**
  61589. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  61590. * @returns this converted to a new vector3
  61591. */
  61592. toVector3(): Vector3;
  61593. /**
  61594. * Returns a new Vector4 copied from the current one.
  61595. * @returns the new cloned vector
  61596. */
  61597. clone(): Vector4;
  61598. /**
  61599. * Updates the current Vector4 with the given one coordinates.
  61600. * @param source the source vector to copy from
  61601. * @returns the updated Vector4.
  61602. */
  61603. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  61604. /**
  61605. * Updates the current Vector4 coordinates with the given floats.
  61606. * @param x float to copy from
  61607. * @param y float to copy from
  61608. * @param z float to copy from
  61609. * @param w float to copy from
  61610. * @returns the updated Vector4.
  61611. */
  61612. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  61613. /**
  61614. * Updates the current Vector4 coordinates with the given floats.
  61615. * @param x float to set from
  61616. * @param y float to set from
  61617. * @param z float to set from
  61618. * @param w float to set from
  61619. * @returns the updated Vector4.
  61620. */
  61621. set(x: number, y: number, z: number, w: number): Vector4;
  61622. /**
  61623. * Copies the given float to the current Vector3 coordinates
  61624. * @param v defines the x, y, z and w coordinates of the operand
  61625. * @returns the current updated Vector3
  61626. */
  61627. setAll(v: number): Vector4;
  61628. /**
  61629. * Returns a new Vector4 set from the starting index of the given array.
  61630. * @param array the array to pull values from
  61631. * @param offset the offset into the array to start at
  61632. * @returns the new vector
  61633. */
  61634. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  61635. /**
  61636. * Updates the given vector "result" from the starting index of the given array.
  61637. * @param array the array to pull values from
  61638. * @param offset the offset into the array to start at
  61639. * @param result the vector to store the result in
  61640. */
  61641. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  61642. /**
  61643. * Updates the given vector "result" from the starting index of the given Float32Array.
  61644. * @param array the array to pull values from
  61645. * @param offset the offset into the array to start at
  61646. * @param result the vector to store the result in
  61647. */
  61648. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  61649. /**
  61650. * Updates the given vector "result" coordinates from the given floats.
  61651. * @param x float to set from
  61652. * @param y float to set from
  61653. * @param z float to set from
  61654. * @param w float to set from
  61655. * @param result the vector to the floats in
  61656. */
  61657. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  61658. /**
  61659. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  61660. * @returns the new vector
  61661. */
  61662. static Zero(): Vector4;
  61663. /**
  61664. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  61665. * @returns the new vector
  61666. */
  61667. static One(): Vector4;
  61668. /**
  61669. * Returns a new normalized Vector4 from the given one.
  61670. * @param vector the vector to normalize
  61671. * @returns the vector
  61672. */
  61673. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  61674. /**
  61675. * Updates the given vector "result" from the normalization of the given one.
  61676. * @param vector the vector to normalize
  61677. * @param result the vector to store the result in
  61678. */
  61679. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  61680. /**
  61681. * Returns a vector with the minimum values from the left and right vectors
  61682. * @param left left vector to minimize
  61683. * @param right right vector to minimize
  61684. * @returns a new vector with the minimum of the left and right vector values
  61685. */
  61686. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  61687. /**
  61688. * Returns a vector with the maximum values from the left and right vectors
  61689. * @param left left vector to maximize
  61690. * @param right right vector to maximize
  61691. * @returns a new vector with the maximum of the left and right vector values
  61692. */
  61693. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  61694. /**
  61695. * Returns the distance (float) between the vectors "value1" and "value2".
  61696. * @param value1 value to calulate the distance between
  61697. * @param value2 value to calulate the distance between
  61698. * @return the distance between the two vectors
  61699. */
  61700. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  61701. /**
  61702. * Returns the squared distance (float) between the vectors "value1" and "value2".
  61703. * @param value1 value to calulate the distance between
  61704. * @param value2 value to calulate the distance between
  61705. * @return the distance between the two vectors squared
  61706. */
  61707. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  61708. /**
  61709. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  61710. * @param value1 value to calulate the center between
  61711. * @param value2 value to calulate the center between
  61712. * @return the center between the two vectors
  61713. */
  61714. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  61715. /**
  61716. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  61717. * This methods computes transformed normalized direction vectors only.
  61718. * @param vector the vector to transform
  61719. * @param transformation the transformation matrix to apply
  61720. * @returns the new vector
  61721. */
  61722. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  61723. /**
  61724. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  61725. * This methods computes transformed normalized direction vectors only.
  61726. * @param vector the vector to transform
  61727. * @param transformation the transformation matrix to apply
  61728. * @param result the vector to store the result in
  61729. */
  61730. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  61731. /**
  61732. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  61733. * This methods computes transformed normalized direction vectors only.
  61734. * @param x value to transform
  61735. * @param y value to transform
  61736. * @param z value to transform
  61737. * @param w value to transform
  61738. * @param transformation the transformation matrix to apply
  61739. * @param result the vector to store the results in
  61740. */
  61741. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  61742. /**
  61743. * Creates a new Vector4 from a Vector3
  61744. * @param source defines the source data
  61745. * @param w defines the 4th component (default is 0)
  61746. * @returns a new Vector4
  61747. */
  61748. static FromVector3(source: Vector3, w?: number): Vector4;
  61749. }
  61750. /**
  61751. * Interface for the size containing width and height
  61752. */
  61753. export interface ISize {
  61754. /**
  61755. * Width
  61756. */
  61757. width: number;
  61758. /**
  61759. * Heighht
  61760. */
  61761. height: number;
  61762. }
  61763. /**
  61764. * Size containing widht and height
  61765. */
  61766. export class Size implements ISize {
  61767. /**
  61768. * Width
  61769. */
  61770. width: number;
  61771. /**
  61772. * Height
  61773. */
  61774. height: number;
  61775. /**
  61776. * Creates a Size object from the given width and height (floats).
  61777. * @param width width of the new size
  61778. * @param height height of the new size
  61779. */
  61780. constructor(width: number, height: number);
  61781. /**
  61782. * Returns a string with the Size width and height
  61783. * @returns a string with the Size width and height
  61784. */
  61785. toString(): string;
  61786. /**
  61787. * "Size"
  61788. * @returns the string "Size"
  61789. */
  61790. getClassName(): string;
  61791. /**
  61792. * Returns the Size hash code.
  61793. * @returns a hash code for a unique width and height
  61794. */
  61795. getHashCode(): number;
  61796. /**
  61797. * Updates the current size from the given one.
  61798. * @param src the given size
  61799. */
  61800. copyFrom(src: Size): void;
  61801. /**
  61802. * Updates in place the current Size from the given floats.
  61803. * @param width width of the new size
  61804. * @param height height of the new size
  61805. * @returns the updated Size.
  61806. */
  61807. copyFromFloats(width: number, height: number): Size;
  61808. /**
  61809. * Updates in place the current Size from the given floats.
  61810. * @param width width to set
  61811. * @param height height to set
  61812. * @returns the updated Size.
  61813. */
  61814. set(width: number, height: number): Size;
  61815. /**
  61816. * Multiplies the width and height by numbers
  61817. * @param w factor to multiple the width by
  61818. * @param h factor to multiple the height by
  61819. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  61820. */
  61821. multiplyByFloats(w: number, h: number): Size;
  61822. /**
  61823. * Clones the size
  61824. * @returns a new Size copied from the given one.
  61825. */
  61826. clone(): Size;
  61827. /**
  61828. * True if the current Size and the given one width and height are strictly equal.
  61829. * @param other the other size to compare against
  61830. * @returns True if the current Size and the given one width and height are strictly equal.
  61831. */
  61832. equals(other: Size): boolean;
  61833. /**
  61834. * The surface of the Size : width * height (float).
  61835. */
  61836. readonly surface: number;
  61837. /**
  61838. * Create a new size of zero
  61839. * @returns a new Size set to (0.0, 0.0)
  61840. */
  61841. static Zero(): Size;
  61842. /**
  61843. * Sums the width and height of two sizes
  61844. * @param otherSize size to add to this size
  61845. * @returns a new Size set as the addition result of the current Size and the given one.
  61846. */
  61847. add(otherSize: Size): Size;
  61848. /**
  61849. * Subtracts the width and height of two
  61850. * @param otherSize size to subtract to this size
  61851. * @returns a new Size set as the subtraction result of the given one from the current Size.
  61852. */
  61853. subtract(otherSize: Size): Size;
  61854. /**
  61855. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  61856. * @param start starting size to lerp between
  61857. * @param end end size to lerp between
  61858. * @param amount amount to lerp between the start and end values
  61859. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  61860. */
  61861. static Lerp(start: Size, end: Size, amount: number): Size;
  61862. }
  61863. /**
  61864. * Class used to store quaternion data
  61865. * @see https://en.wikipedia.org/wiki/Quaternion
  61866. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  61867. */
  61868. export class Quaternion {
  61869. /** defines the first component (0 by default) */
  61870. x: number;
  61871. /** defines the second component (0 by default) */
  61872. y: number;
  61873. /** defines the third component (0 by default) */
  61874. z: number;
  61875. /** defines the fourth component (1.0 by default) */
  61876. w: number;
  61877. /**
  61878. * Creates a new Quaternion from the given floats
  61879. * @param x defines the first component (0 by default)
  61880. * @param y defines the second component (0 by default)
  61881. * @param z defines the third component (0 by default)
  61882. * @param w defines the fourth component (1.0 by default)
  61883. */
  61884. constructor(
  61885. /** defines the first component (0 by default) */
  61886. x?: number,
  61887. /** defines the second component (0 by default) */
  61888. y?: number,
  61889. /** defines the third component (0 by default) */
  61890. z?: number,
  61891. /** defines the fourth component (1.0 by default) */
  61892. w?: number);
  61893. /**
  61894. * Gets a string representation for the current quaternion
  61895. * @returns a string with the Quaternion coordinates
  61896. */
  61897. toString(): string;
  61898. /**
  61899. * Gets the class name of the quaternion
  61900. * @returns the string "Quaternion"
  61901. */
  61902. getClassName(): string;
  61903. /**
  61904. * Gets a hash code for this quaternion
  61905. * @returns the quaternion hash code
  61906. */
  61907. getHashCode(): number;
  61908. /**
  61909. * Copy the quaternion to an array
  61910. * @returns a new array populated with 4 elements from the quaternion coordinates
  61911. */
  61912. asArray(): number[];
  61913. /**
  61914. * Check if two quaternions are equals
  61915. * @param otherQuaternion defines the second operand
  61916. * @return true if the current quaternion and the given one coordinates are strictly equals
  61917. */
  61918. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  61919. /**
  61920. * Clone the current quaternion
  61921. * @returns a new quaternion copied from the current one
  61922. */
  61923. clone(): Quaternion;
  61924. /**
  61925. * Copy a quaternion to the current one
  61926. * @param other defines the other quaternion
  61927. * @returns the updated current quaternion
  61928. */
  61929. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  61930. /**
  61931. * Updates the current quaternion with the given float coordinates
  61932. * @param x defines the x coordinate
  61933. * @param y defines the y coordinate
  61934. * @param z defines the z coordinate
  61935. * @param w defines the w coordinate
  61936. * @returns the updated current quaternion
  61937. */
  61938. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  61939. /**
  61940. * Updates the current quaternion from the given float coordinates
  61941. * @param x defines the x coordinate
  61942. * @param y defines the y coordinate
  61943. * @param z defines the z coordinate
  61944. * @param w defines the w coordinate
  61945. * @returns the updated current quaternion
  61946. */
  61947. set(x: number, y: number, z: number, w: number): Quaternion;
  61948. /**
  61949. * Adds two quaternions
  61950. * @param other defines the second operand
  61951. * @returns a new quaternion as the addition result of the given one and the current quaternion
  61952. */
  61953. add(other: DeepImmutable<Quaternion>): Quaternion;
  61954. /**
  61955. * Add a quaternion to the current one
  61956. * @param other defines the quaternion to add
  61957. * @returns the current quaternion
  61958. */
  61959. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  61960. /**
  61961. * Subtract two quaternions
  61962. * @param other defines the second operand
  61963. * @returns a new quaternion as the subtraction result of the given one from the current one
  61964. */
  61965. subtract(other: Quaternion): Quaternion;
  61966. /**
  61967. * Multiplies the current quaternion by a scale factor
  61968. * @param value defines the scale factor
  61969. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  61970. */
  61971. scale(value: number): Quaternion;
  61972. /**
  61973. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  61974. * @param scale defines the scale factor
  61975. * @param result defines the Quaternion object where to store the result
  61976. * @returns the unmodified current quaternion
  61977. */
  61978. scaleToRef(scale: number, result: Quaternion): Quaternion;
  61979. /**
  61980. * Multiplies in place the current quaternion by a scale factor
  61981. * @param value defines the scale factor
  61982. * @returns the current modified quaternion
  61983. */
  61984. scaleInPlace(value: number): Quaternion;
  61985. /**
  61986. * Scale the current quaternion values by a factor and add the result to a given quaternion
  61987. * @param scale defines the scale factor
  61988. * @param result defines the Quaternion object where to store the result
  61989. * @returns the unmodified current quaternion
  61990. */
  61991. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  61992. /**
  61993. * Multiplies two quaternions
  61994. * @param q1 defines the second operand
  61995. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  61996. */
  61997. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  61998. /**
  61999. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  62000. * @param q1 defines the second operand
  62001. * @param result defines the target quaternion
  62002. * @returns the current quaternion
  62003. */
  62004. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  62005. /**
  62006. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  62007. * @param q1 defines the second operand
  62008. * @returns the currentupdated quaternion
  62009. */
  62010. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  62011. /**
  62012. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  62013. * @param ref defines the target quaternion
  62014. * @returns the current quaternion
  62015. */
  62016. conjugateToRef(ref: Quaternion): Quaternion;
  62017. /**
  62018. * Conjugates in place (1-q) the current quaternion
  62019. * @returns the current updated quaternion
  62020. */
  62021. conjugateInPlace(): Quaternion;
  62022. /**
  62023. * Conjugates in place (1-q) the current quaternion
  62024. * @returns a new quaternion
  62025. */
  62026. conjugate(): Quaternion;
  62027. /**
  62028. * Gets length of current quaternion
  62029. * @returns the quaternion length (float)
  62030. */
  62031. length(): number;
  62032. /**
  62033. * Normalize in place the current quaternion
  62034. * @returns the current updated quaternion
  62035. */
  62036. normalize(): Quaternion;
  62037. /**
  62038. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  62039. * @param order is a reserved parameter and is ignore for now
  62040. * @returns a new Vector3 containing the Euler angles
  62041. */
  62042. toEulerAngles(order?: string): Vector3;
  62043. /**
  62044. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  62045. * @param result defines the vector which will be filled with the Euler angles
  62046. * @param order is a reserved parameter and is ignore for now
  62047. * @returns the current unchanged quaternion
  62048. */
  62049. toEulerAnglesToRef(result: Vector3): Quaternion;
  62050. /**
  62051. * Updates the given rotation matrix with the current quaternion values
  62052. * @param result defines the target matrix
  62053. * @returns the current unchanged quaternion
  62054. */
  62055. toRotationMatrix(result: Matrix): Quaternion;
  62056. /**
  62057. * Updates the current quaternion from the given rotation matrix values
  62058. * @param matrix defines the source matrix
  62059. * @returns the current updated quaternion
  62060. */
  62061. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  62062. /**
  62063. * Creates a new quaternion from a rotation matrix
  62064. * @param matrix defines the source matrix
  62065. * @returns a new quaternion created from the given rotation matrix values
  62066. */
  62067. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  62068. /**
  62069. * Updates the given quaternion with the given rotation matrix values
  62070. * @param matrix defines the source matrix
  62071. * @param result defines the target quaternion
  62072. */
  62073. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  62074. /**
  62075. * Returns the dot product (float) between the quaternions "left" and "right"
  62076. * @param left defines the left operand
  62077. * @param right defines the right operand
  62078. * @returns the dot product
  62079. */
  62080. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  62081. /**
  62082. * Checks if the two quaternions are close to each other
  62083. * @param quat0 defines the first quaternion to check
  62084. * @param quat1 defines the second quaternion to check
  62085. * @returns true if the two quaternions are close to each other
  62086. */
  62087. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  62088. /**
  62089. * Creates an empty quaternion
  62090. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  62091. */
  62092. static Zero(): Quaternion;
  62093. /**
  62094. * Inverse a given quaternion
  62095. * @param q defines the source quaternion
  62096. * @returns a new quaternion as the inverted current quaternion
  62097. */
  62098. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  62099. /**
  62100. * Inverse a given quaternion
  62101. * @param q defines the source quaternion
  62102. * @param result the quaternion the result will be stored in
  62103. * @returns the result quaternion
  62104. */
  62105. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  62106. /**
  62107. * Creates an identity quaternion
  62108. * @returns the identity quaternion
  62109. */
  62110. static Identity(): Quaternion;
  62111. /**
  62112. * Gets a boolean indicating if the given quaternion is identity
  62113. * @param quaternion defines the quaternion to check
  62114. * @returns true if the quaternion is identity
  62115. */
  62116. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  62117. /**
  62118. * Creates a quaternion from a rotation around an axis
  62119. * @param axis defines the axis to use
  62120. * @param angle defines the angle to use
  62121. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  62122. */
  62123. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  62124. /**
  62125. * Creates a rotation around an axis and stores it into the given quaternion
  62126. * @param axis defines the axis to use
  62127. * @param angle defines the angle to use
  62128. * @param result defines the target quaternion
  62129. * @returns the target quaternion
  62130. */
  62131. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  62132. /**
  62133. * Creates a new quaternion from data stored into an array
  62134. * @param array defines the data source
  62135. * @param offset defines the offset in the source array where the data starts
  62136. * @returns a new quaternion
  62137. */
  62138. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  62139. /**
  62140. * Create a quaternion from Euler rotation angles
  62141. * @param x Pitch
  62142. * @param y Yaw
  62143. * @param z Roll
  62144. * @returns the new Quaternion
  62145. */
  62146. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  62147. /**
  62148. * Updates a quaternion from Euler rotation angles
  62149. * @param x Pitch
  62150. * @param y Yaw
  62151. * @param z Roll
  62152. * @param result the quaternion to store the result
  62153. * @returns the updated quaternion
  62154. */
  62155. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  62156. /**
  62157. * Create a quaternion from Euler rotation vector
  62158. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  62159. * @returns the new Quaternion
  62160. */
  62161. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  62162. /**
  62163. * Updates a quaternion from Euler rotation vector
  62164. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  62165. * @param result the quaternion to store the result
  62166. * @returns the updated quaternion
  62167. */
  62168. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  62169. /**
  62170. * Creates a new quaternion from the given Euler float angles (y, x, z)
  62171. * @param yaw defines the rotation around Y axis
  62172. * @param pitch defines the rotation around X axis
  62173. * @param roll defines the rotation around Z axis
  62174. * @returns the new quaternion
  62175. */
  62176. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  62177. /**
  62178. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  62179. * @param yaw defines the rotation around Y axis
  62180. * @param pitch defines the rotation around X axis
  62181. * @param roll defines the rotation around Z axis
  62182. * @param result defines the target quaternion
  62183. */
  62184. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  62185. /**
  62186. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  62187. * @param alpha defines the rotation around first axis
  62188. * @param beta defines the rotation around second axis
  62189. * @param gamma defines the rotation around third axis
  62190. * @returns the new quaternion
  62191. */
  62192. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  62193. /**
  62194. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  62195. * @param alpha defines the rotation around first axis
  62196. * @param beta defines the rotation around second axis
  62197. * @param gamma defines the rotation around third axis
  62198. * @param result defines the target quaternion
  62199. */
  62200. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  62201. /**
  62202. * 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)
  62203. * @param axis1 defines the first axis
  62204. * @param axis2 defines the second axis
  62205. * @param axis3 defines the third axis
  62206. * @returns the new quaternion
  62207. */
  62208. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  62209. /**
  62210. * 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
  62211. * @param axis1 defines the first axis
  62212. * @param axis2 defines the second axis
  62213. * @param axis3 defines the third axis
  62214. * @param ref defines the target quaternion
  62215. */
  62216. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  62217. /**
  62218. * Interpolates between two quaternions
  62219. * @param left defines first quaternion
  62220. * @param right defines second quaternion
  62221. * @param amount defines the gradient to use
  62222. * @returns the new interpolated quaternion
  62223. */
  62224. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  62225. /**
  62226. * Interpolates between two quaternions and stores it into a target quaternion
  62227. * @param left defines first quaternion
  62228. * @param right defines second quaternion
  62229. * @param amount defines the gradient to use
  62230. * @param result defines the target quaternion
  62231. */
  62232. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  62233. /**
  62234. * Interpolate between two quaternions using Hermite interpolation
  62235. * @param value1 defines first quaternion
  62236. * @param tangent1 defines the incoming tangent
  62237. * @param value2 defines second quaternion
  62238. * @param tangent2 defines the outgoing tangent
  62239. * @param amount defines the target quaternion
  62240. * @returns the new interpolated quaternion
  62241. */
  62242. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  62243. }
  62244. /**
  62245. * Class used to store matrix data (4x4)
  62246. */
  62247. export class Matrix {
  62248. private static _updateFlagSeed;
  62249. private static _identityReadOnly;
  62250. private _isIdentity;
  62251. private _isIdentityDirty;
  62252. private _isIdentity3x2;
  62253. private _isIdentity3x2Dirty;
  62254. /**
  62255. * Gets the update flag of the matrix which is an unique number for the matrix.
  62256. * It will be incremented every time the matrix data change.
  62257. * You can use it to speed the comparison between two versions of the same matrix.
  62258. */
  62259. updateFlag: number;
  62260. private readonly _m;
  62261. /**
  62262. * Gets the internal data of the matrix
  62263. */
  62264. readonly m: DeepImmutable<Float32Array>;
  62265. /** @hidden */
  62266. _markAsUpdated(): void;
  62267. /** @hidden */
  62268. private _updateIdentityStatus;
  62269. /**
  62270. * Creates an empty matrix (filled with zeros)
  62271. */
  62272. constructor();
  62273. /**
  62274. * Check if the current matrix is identity
  62275. * @returns true is the matrix is the identity matrix
  62276. */
  62277. isIdentity(): boolean;
  62278. /**
  62279. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  62280. * @returns true is the matrix is the identity matrix
  62281. */
  62282. isIdentityAs3x2(): boolean;
  62283. /**
  62284. * Gets the determinant of the matrix
  62285. * @returns the matrix determinant
  62286. */
  62287. determinant(): number;
  62288. /**
  62289. * Returns the matrix as a Float32Array
  62290. * @returns the matrix underlying array
  62291. */
  62292. toArray(): DeepImmutable<Float32Array>;
  62293. /**
  62294. * Returns the matrix as a Float32Array
  62295. * @returns the matrix underlying array.
  62296. */
  62297. asArray(): DeepImmutable<Float32Array>;
  62298. /**
  62299. * Inverts the current matrix in place
  62300. * @returns the current inverted matrix
  62301. */
  62302. invert(): Matrix;
  62303. /**
  62304. * Sets all the matrix elements to zero
  62305. * @returns the current matrix
  62306. */
  62307. reset(): Matrix;
  62308. /**
  62309. * Adds the current matrix with a second one
  62310. * @param other defines the matrix to add
  62311. * @returns a new matrix as the addition of the current matrix and the given one
  62312. */
  62313. add(other: DeepImmutable<Matrix>): Matrix;
  62314. /**
  62315. * Sets the given matrix "result" to the addition of the current matrix and the given one
  62316. * @param other defines the matrix to add
  62317. * @param result defines the target matrix
  62318. * @returns the current matrix
  62319. */
  62320. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  62321. /**
  62322. * Adds in place the given matrix to the current matrix
  62323. * @param other defines the second operand
  62324. * @returns the current updated matrix
  62325. */
  62326. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  62327. /**
  62328. * Sets the given matrix to the current inverted Matrix
  62329. * @param other defines the target matrix
  62330. * @returns the unmodified current matrix
  62331. */
  62332. invertToRef(other: Matrix): Matrix;
  62333. /**
  62334. * add a value at the specified position in the current Matrix
  62335. * @param index the index of the value within the matrix. between 0 and 15.
  62336. * @param value the value to be added
  62337. * @returns the current updated matrix
  62338. */
  62339. addAtIndex(index: number, value: number): Matrix;
  62340. /**
  62341. * mutiply the specified position in the current Matrix by a value
  62342. * @param index the index of the value within the matrix. between 0 and 15.
  62343. * @param value the value to be added
  62344. * @returns the current updated matrix
  62345. */
  62346. multiplyAtIndex(index: number, value: number): Matrix;
  62347. /**
  62348. * Inserts the translation vector (using 3 floats) in the current matrix
  62349. * @param x defines the 1st component of the translation
  62350. * @param y defines the 2nd component of the translation
  62351. * @param z defines the 3rd component of the translation
  62352. * @returns the current updated matrix
  62353. */
  62354. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  62355. /**
  62356. * Adds the translation vector (using 3 floats) in the current matrix
  62357. * @param x defines the 1st component of the translation
  62358. * @param y defines the 2nd component of the translation
  62359. * @param z defines the 3rd component of the translation
  62360. * @returns the current updated matrix
  62361. */
  62362. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  62363. /**
  62364. * Inserts the translation vector in the current matrix
  62365. * @param vector3 defines the translation to insert
  62366. * @returns the current updated matrix
  62367. */
  62368. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  62369. /**
  62370. * Gets the translation value of the current matrix
  62371. * @returns a new Vector3 as the extracted translation from the matrix
  62372. */
  62373. getTranslation(): Vector3;
  62374. /**
  62375. * Fill a Vector3 with the extracted translation from the matrix
  62376. * @param result defines the Vector3 where to store the translation
  62377. * @returns the current matrix
  62378. */
  62379. getTranslationToRef(result: Vector3): Matrix;
  62380. /**
  62381. * Remove rotation and scaling part from the matrix
  62382. * @returns the updated matrix
  62383. */
  62384. removeRotationAndScaling(): Matrix;
  62385. /**
  62386. * Multiply two matrices
  62387. * @param other defines the second operand
  62388. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  62389. */
  62390. multiply(other: DeepImmutable<Matrix>): Matrix;
  62391. /**
  62392. * Copy the current matrix from the given one
  62393. * @param other defines the source matrix
  62394. * @returns the current updated matrix
  62395. */
  62396. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  62397. /**
  62398. * Populates the given array from the starting index with the current matrix values
  62399. * @param array defines the target array
  62400. * @param offset defines the offset in the target array where to start storing values
  62401. * @returns the current matrix
  62402. */
  62403. copyToArray(array: Float32Array, offset?: number): Matrix;
  62404. /**
  62405. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  62406. * @param other defines the second operand
  62407. * @param result defines the matrix where to store the multiplication
  62408. * @returns the current matrix
  62409. */
  62410. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  62411. /**
  62412. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  62413. * @param other defines the second operand
  62414. * @param result defines the array where to store the multiplication
  62415. * @param offset defines the offset in the target array where to start storing values
  62416. * @returns the current matrix
  62417. */
  62418. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  62419. /**
  62420. * Check equality between this matrix and a second one
  62421. * @param value defines the second matrix to compare
  62422. * @returns true is the current matrix and the given one values are strictly equal
  62423. */
  62424. equals(value: DeepImmutable<Matrix>): boolean;
  62425. /**
  62426. * Clone the current matrix
  62427. * @returns a new matrix from the current matrix
  62428. */
  62429. clone(): Matrix;
  62430. /**
  62431. * Returns the name of the current matrix class
  62432. * @returns the string "Matrix"
  62433. */
  62434. getClassName(): string;
  62435. /**
  62436. * Gets the hash code of the current matrix
  62437. * @returns the hash code
  62438. */
  62439. getHashCode(): number;
  62440. /**
  62441. * Decomposes the current Matrix into a translation, rotation and scaling components
  62442. * @param scale defines the scale vector3 given as a reference to update
  62443. * @param rotation defines the rotation quaternion given as a reference to update
  62444. * @param translation defines the translation vector3 given as a reference to update
  62445. * @returns true if operation was successful
  62446. */
  62447. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  62448. /**
  62449. * Gets specific row of the matrix
  62450. * @param index defines the number of the row to get
  62451. * @returns the index-th row of the current matrix as a new Vector4
  62452. */
  62453. getRow(index: number): Nullable<Vector4>;
  62454. /**
  62455. * Sets the index-th row of the current matrix to the vector4 values
  62456. * @param index defines the number of the row to set
  62457. * @param row defines the target vector4
  62458. * @returns the updated current matrix
  62459. */
  62460. setRow(index: number, row: Vector4): Matrix;
  62461. /**
  62462. * Compute the transpose of the matrix
  62463. * @returns the new transposed matrix
  62464. */
  62465. transpose(): Matrix;
  62466. /**
  62467. * Compute the transpose of the matrix and store it in a given matrix
  62468. * @param result defines the target matrix
  62469. * @returns the current matrix
  62470. */
  62471. transposeToRef(result: Matrix): Matrix;
  62472. /**
  62473. * Sets the index-th row of the current matrix with the given 4 x float values
  62474. * @param index defines the row index
  62475. * @param x defines the x component to set
  62476. * @param y defines the y component to set
  62477. * @param z defines the z component to set
  62478. * @param w defines the w component to set
  62479. * @returns the updated current matrix
  62480. */
  62481. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  62482. /**
  62483. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  62484. * @param scale defines the scale factor
  62485. * @returns a new matrix
  62486. */
  62487. scale(scale: number): Matrix;
  62488. /**
  62489. * Scale the current matrix values by a factor to a given result matrix
  62490. * @param scale defines the scale factor
  62491. * @param result defines the matrix to store the result
  62492. * @returns the current matrix
  62493. */
  62494. scaleToRef(scale: number, result: Matrix): Matrix;
  62495. /**
  62496. * Scale the current matrix values by a factor and add the result to a given matrix
  62497. * @param scale defines the scale factor
  62498. * @param result defines the Matrix to store the result
  62499. * @returns the current matrix
  62500. */
  62501. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  62502. /**
  62503. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  62504. * @param ref matrix to store the result
  62505. */
  62506. toNormalMatrix(ref: Matrix): void;
  62507. /**
  62508. * Gets only rotation part of the current matrix
  62509. * @returns a new matrix sets to the extracted rotation matrix from the current one
  62510. */
  62511. getRotationMatrix(): Matrix;
  62512. /**
  62513. * Extracts the rotation matrix from the current one and sets it as the given "result"
  62514. * @param result defines the target matrix to store data to
  62515. * @returns the current matrix
  62516. */
  62517. getRotationMatrixToRef(result: Matrix): Matrix;
  62518. /**
  62519. * Toggles model matrix from being right handed to left handed in place and vice versa
  62520. */
  62521. toggleModelMatrixHandInPlace(): void;
  62522. /**
  62523. * Toggles projection matrix from being right handed to left handed in place and vice versa
  62524. */
  62525. toggleProjectionMatrixHandInPlace(): void;
  62526. /**
  62527. * Creates a matrix from an array
  62528. * @param array defines the source array
  62529. * @param offset defines an offset in the source array
  62530. * @returns a new Matrix set from the starting index of the given array
  62531. */
  62532. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  62533. /**
  62534. * Copy the content of an array into a given matrix
  62535. * @param array defines the source array
  62536. * @param offset defines an offset in the source array
  62537. * @param result defines the target matrix
  62538. */
  62539. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  62540. /**
  62541. * Stores an array into a matrix after having multiplied each component by a given factor
  62542. * @param array defines the source array
  62543. * @param offset defines the offset in the source array
  62544. * @param scale defines the scaling factor
  62545. * @param result defines the target matrix
  62546. */
  62547. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  62548. /**
  62549. * Gets an identity matrix that must not be updated
  62550. */
  62551. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  62552. /**
  62553. * Stores a list of values (16) inside a given matrix
  62554. * @param initialM11 defines 1st value of 1st row
  62555. * @param initialM12 defines 2nd value of 1st row
  62556. * @param initialM13 defines 3rd value of 1st row
  62557. * @param initialM14 defines 4th value of 1st row
  62558. * @param initialM21 defines 1st value of 2nd row
  62559. * @param initialM22 defines 2nd value of 2nd row
  62560. * @param initialM23 defines 3rd value of 2nd row
  62561. * @param initialM24 defines 4th value of 2nd row
  62562. * @param initialM31 defines 1st value of 3rd row
  62563. * @param initialM32 defines 2nd value of 3rd row
  62564. * @param initialM33 defines 3rd value of 3rd row
  62565. * @param initialM34 defines 4th value of 3rd row
  62566. * @param initialM41 defines 1st value of 4th row
  62567. * @param initialM42 defines 2nd value of 4th row
  62568. * @param initialM43 defines 3rd value of 4th row
  62569. * @param initialM44 defines 4th value of 4th row
  62570. * @param result defines the target matrix
  62571. */
  62572. 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;
  62573. /**
  62574. * Creates new matrix from a list of values (16)
  62575. * @param initialM11 defines 1st value of 1st row
  62576. * @param initialM12 defines 2nd value of 1st row
  62577. * @param initialM13 defines 3rd value of 1st row
  62578. * @param initialM14 defines 4th value of 1st row
  62579. * @param initialM21 defines 1st value of 2nd row
  62580. * @param initialM22 defines 2nd value of 2nd row
  62581. * @param initialM23 defines 3rd value of 2nd row
  62582. * @param initialM24 defines 4th value of 2nd row
  62583. * @param initialM31 defines 1st value of 3rd row
  62584. * @param initialM32 defines 2nd value of 3rd row
  62585. * @param initialM33 defines 3rd value of 3rd row
  62586. * @param initialM34 defines 4th value of 3rd row
  62587. * @param initialM41 defines 1st value of 4th row
  62588. * @param initialM42 defines 2nd value of 4th row
  62589. * @param initialM43 defines 3rd value of 4th row
  62590. * @param initialM44 defines 4th value of 4th row
  62591. * @returns the new matrix
  62592. */
  62593. 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;
  62594. /**
  62595. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  62596. * @param scale defines the scale vector3
  62597. * @param rotation defines the rotation quaternion
  62598. * @param translation defines the translation vector3
  62599. * @returns a new matrix
  62600. */
  62601. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  62602. /**
  62603. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  62604. * @param scale defines the scale vector3
  62605. * @param rotation defines the rotation quaternion
  62606. * @param translation defines the translation vector3
  62607. * @param result defines the target matrix
  62608. */
  62609. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  62610. /**
  62611. * Creates a new identity matrix
  62612. * @returns a new identity matrix
  62613. */
  62614. static Identity(): Matrix;
  62615. /**
  62616. * Creates a new identity matrix and stores the result in a given matrix
  62617. * @param result defines the target matrix
  62618. */
  62619. static IdentityToRef(result: Matrix): void;
  62620. /**
  62621. * Creates a new zero matrix
  62622. * @returns a new zero matrix
  62623. */
  62624. static Zero(): Matrix;
  62625. /**
  62626. * Creates a new rotation matrix for "angle" radians around the X axis
  62627. * @param angle defines the angle (in radians) to use
  62628. * @return the new matrix
  62629. */
  62630. static RotationX(angle: number): Matrix;
  62631. /**
  62632. * Creates a new matrix as the invert of a given matrix
  62633. * @param source defines the source matrix
  62634. * @returns the new matrix
  62635. */
  62636. static Invert(source: DeepImmutable<Matrix>): Matrix;
  62637. /**
  62638. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  62639. * @param angle defines the angle (in radians) to use
  62640. * @param result defines the target matrix
  62641. */
  62642. static RotationXToRef(angle: number, result: Matrix): void;
  62643. /**
  62644. * Creates a new rotation matrix for "angle" radians around the Y axis
  62645. * @param angle defines the angle (in radians) to use
  62646. * @return the new matrix
  62647. */
  62648. static RotationY(angle: number): Matrix;
  62649. /**
  62650. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  62651. * @param angle defines the angle (in radians) to use
  62652. * @param result defines the target matrix
  62653. */
  62654. static RotationYToRef(angle: number, result: Matrix): void;
  62655. /**
  62656. * Creates a new rotation matrix for "angle" radians around the Z axis
  62657. * @param angle defines the angle (in radians) to use
  62658. * @return the new matrix
  62659. */
  62660. static RotationZ(angle: number): Matrix;
  62661. /**
  62662. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  62663. * @param angle defines the angle (in radians) to use
  62664. * @param result defines the target matrix
  62665. */
  62666. static RotationZToRef(angle: number, result: Matrix): void;
  62667. /**
  62668. * Creates a new rotation matrix for "angle" radians around the given axis
  62669. * @param axis defines the axis to use
  62670. * @param angle defines the angle (in radians) to use
  62671. * @return the new matrix
  62672. */
  62673. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  62674. /**
  62675. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  62676. * @param axis defines the axis to use
  62677. * @param angle defines the angle (in radians) to use
  62678. * @param result defines the target matrix
  62679. */
  62680. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  62681. /**
  62682. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  62683. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  62684. * @param from defines the vector to align
  62685. * @param to defines the vector to align to
  62686. * @param result defines the target matrix
  62687. */
  62688. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  62689. /**
  62690. * Creates a rotation matrix
  62691. * @param yaw defines the yaw angle in radians (Y axis)
  62692. * @param pitch defines the pitch angle in radians (X axis)
  62693. * @param roll defines the roll angle in radians (X axis)
  62694. * @returns the new rotation matrix
  62695. */
  62696. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  62697. /**
  62698. * Creates a rotation matrix and stores it in a given matrix
  62699. * @param yaw defines the yaw angle in radians (Y axis)
  62700. * @param pitch defines the pitch angle in radians (X axis)
  62701. * @param roll defines the roll angle in radians (X axis)
  62702. * @param result defines the target matrix
  62703. */
  62704. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  62705. /**
  62706. * Creates a scaling matrix
  62707. * @param x defines the scale factor on X axis
  62708. * @param y defines the scale factor on Y axis
  62709. * @param z defines the scale factor on Z axis
  62710. * @returns the new matrix
  62711. */
  62712. static Scaling(x: number, y: number, z: number): Matrix;
  62713. /**
  62714. * Creates a scaling matrix and stores it in a given matrix
  62715. * @param x defines the scale factor on X axis
  62716. * @param y defines the scale factor on Y axis
  62717. * @param z defines the scale factor on Z axis
  62718. * @param result defines the target matrix
  62719. */
  62720. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  62721. /**
  62722. * Creates a translation matrix
  62723. * @param x defines the translation on X axis
  62724. * @param y defines the translation on Y axis
  62725. * @param z defines the translationon Z axis
  62726. * @returns the new matrix
  62727. */
  62728. static Translation(x: number, y: number, z: number): Matrix;
  62729. /**
  62730. * Creates a translation matrix and stores it in a given matrix
  62731. * @param x defines the translation on X axis
  62732. * @param y defines the translation on Y axis
  62733. * @param z defines the translationon Z axis
  62734. * @param result defines the target matrix
  62735. */
  62736. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  62737. /**
  62738. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  62739. * @param startValue defines the start value
  62740. * @param endValue defines the end value
  62741. * @param gradient defines the gradient factor
  62742. * @returns the new matrix
  62743. */
  62744. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  62745. /**
  62746. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  62747. * @param startValue defines the start value
  62748. * @param endValue defines the end value
  62749. * @param gradient defines the gradient factor
  62750. * @param result defines the Matrix object where to store data
  62751. */
  62752. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  62753. /**
  62754. * Builds a new matrix whose values are computed by:
  62755. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  62756. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  62757. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  62758. * @param startValue defines the first matrix
  62759. * @param endValue defines the second matrix
  62760. * @param gradient defines the gradient between the two matrices
  62761. * @returns the new matrix
  62762. */
  62763. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  62764. /**
  62765. * Update a matrix to values which are computed by:
  62766. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  62767. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  62768. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  62769. * @param startValue defines the first matrix
  62770. * @param endValue defines the second matrix
  62771. * @param gradient defines the gradient between the two matrices
  62772. * @param result defines the target matrix
  62773. */
  62774. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  62775. /**
  62776. * 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"
  62777. * This function works in left handed mode
  62778. * @param eye defines the final position of the entity
  62779. * @param target defines where the entity should look at
  62780. * @param up defines the up vector for the entity
  62781. * @returns the new matrix
  62782. */
  62783. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  62784. /**
  62785. * 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".
  62786. * This function works in left handed mode
  62787. * @param eye defines the final position of the entity
  62788. * @param target defines where the entity should look at
  62789. * @param up defines the up vector for the entity
  62790. * @param result defines the target matrix
  62791. */
  62792. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  62793. /**
  62794. * 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"
  62795. * This function works in right handed mode
  62796. * @param eye defines the final position of the entity
  62797. * @param target defines where the entity should look at
  62798. * @param up defines the up vector for the entity
  62799. * @returns the new matrix
  62800. */
  62801. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  62802. /**
  62803. * 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".
  62804. * This function works in right handed mode
  62805. * @param eye defines the final position of the entity
  62806. * @param target defines where the entity should look at
  62807. * @param up defines the up vector for the entity
  62808. * @param result defines the target matrix
  62809. */
  62810. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  62811. /**
  62812. * Create a left-handed orthographic projection matrix
  62813. * @param width defines the viewport width
  62814. * @param height defines the viewport height
  62815. * @param znear defines the near clip plane
  62816. * @param zfar defines the far clip plane
  62817. * @returns a new matrix as a left-handed orthographic projection matrix
  62818. */
  62819. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  62820. /**
  62821. * Store a left-handed orthographic projection to a given matrix
  62822. * @param width defines the viewport width
  62823. * @param height defines the viewport height
  62824. * @param znear defines the near clip plane
  62825. * @param zfar defines the far clip plane
  62826. * @param result defines the target matrix
  62827. */
  62828. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  62829. /**
  62830. * Create a left-handed orthographic projection matrix
  62831. * @param left defines the viewport left coordinate
  62832. * @param right defines the viewport right coordinate
  62833. * @param bottom defines the viewport bottom coordinate
  62834. * @param top defines the viewport top coordinate
  62835. * @param znear defines the near clip plane
  62836. * @param zfar defines the far clip plane
  62837. * @returns a new matrix as a left-handed orthographic projection matrix
  62838. */
  62839. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  62840. /**
  62841. * Stores a left-handed orthographic projection into a given matrix
  62842. * @param left defines the viewport left coordinate
  62843. * @param right defines the viewport right coordinate
  62844. * @param bottom defines the viewport bottom coordinate
  62845. * @param top defines the viewport top coordinate
  62846. * @param znear defines the near clip plane
  62847. * @param zfar defines the far clip plane
  62848. * @param result defines the target matrix
  62849. */
  62850. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  62851. /**
  62852. * Creates a right-handed orthographic projection matrix
  62853. * @param left defines the viewport left coordinate
  62854. * @param right defines the viewport right coordinate
  62855. * @param bottom defines the viewport bottom coordinate
  62856. * @param top defines the viewport top coordinate
  62857. * @param znear defines the near clip plane
  62858. * @param zfar defines the far clip plane
  62859. * @returns a new matrix as a right-handed orthographic projection matrix
  62860. */
  62861. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  62862. /**
  62863. * Stores a right-handed orthographic projection into a given matrix
  62864. * @param left defines the viewport left coordinate
  62865. * @param right defines the viewport right coordinate
  62866. * @param bottom defines the viewport bottom coordinate
  62867. * @param top defines the viewport top coordinate
  62868. * @param znear defines the near clip plane
  62869. * @param zfar defines the far clip plane
  62870. * @param result defines the target matrix
  62871. */
  62872. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  62873. /**
  62874. * Creates a left-handed perspective projection matrix
  62875. * @param width defines the viewport width
  62876. * @param height defines the viewport height
  62877. * @param znear defines the near clip plane
  62878. * @param zfar defines the far clip plane
  62879. * @returns a new matrix as a left-handed perspective projection matrix
  62880. */
  62881. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  62882. /**
  62883. * Creates a left-handed perspective projection matrix
  62884. * @param fov defines the horizontal field of view
  62885. * @param aspect defines the aspect ratio
  62886. * @param znear defines the near clip plane
  62887. * @param zfar defines the far clip plane
  62888. * @returns a new matrix as a left-handed perspective projection matrix
  62889. */
  62890. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  62891. /**
  62892. * Stores a left-handed perspective projection into a given matrix
  62893. * @param fov defines the horizontal field of view
  62894. * @param aspect defines the aspect ratio
  62895. * @param znear defines the near clip plane
  62896. * @param zfar defines the far clip plane
  62897. * @param result defines the target matrix
  62898. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  62899. */
  62900. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  62901. /**
  62902. * Creates a right-handed perspective projection matrix
  62903. * @param fov defines the horizontal field of view
  62904. * @param aspect defines the aspect ratio
  62905. * @param znear defines the near clip plane
  62906. * @param zfar defines the far clip plane
  62907. * @returns a new matrix as a right-handed perspective projection matrix
  62908. */
  62909. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  62910. /**
  62911. * Stores a right-handed perspective projection into a given matrix
  62912. * @param fov defines the horizontal field of view
  62913. * @param aspect defines the aspect ratio
  62914. * @param znear defines the near clip plane
  62915. * @param zfar defines the far clip plane
  62916. * @param result defines the target matrix
  62917. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  62918. */
  62919. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  62920. /**
  62921. * Stores a perspective projection for WebVR info a given matrix
  62922. * @param fov defines the field of view
  62923. * @param znear defines the near clip plane
  62924. * @param zfar defines the far clip plane
  62925. * @param result defines the target matrix
  62926. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  62927. */
  62928. static PerspectiveFovWebVRToRef(fov: {
  62929. upDegrees: number;
  62930. downDegrees: number;
  62931. leftDegrees: number;
  62932. rightDegrees: number;
  62933. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  62934. /**
  62935. * Computes a complete transformation matrix
  62936. * @param viewport defines the viewport to use
  62937. * @param world defines the world matrix
  62938. * @param view defines the view matrix
  62939. * @param projection defines the projection matrix
  62940. * @param zmin defines the near clip plane
  62941. * @param zmax defines the far clip plane
  62942. * @returns the transformation matrix
  62943. */
  62944. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  62945. /**
  62946. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  62947. * @param matrix defines the matrix to use
  62948. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  62949. */
  62950. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  62951. /**
  62952. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  62953. * @param matrix defines the matrix to use
  62954. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  62955. */
  62956. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  62957. /**
  62958. * Compute the transpose of a given matrix
  62959. * @param matrix defines the matrix to transpose
  62960. * @returns the new matrix
  62961. */
  62962. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  62963. /**
  62964. * Compute the transpose of a matrix and store it in a target matrix
  62965. * @param matrix defines the matrix to transpose
  62966. * @param result defines the target matrix
  62967. */
  62968. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  62969. /**
  62970. * Computes a reflection matrix from a plane
  62971. * @param plane defines the reflection plane
  62972. * @returns a new matrix
  62973. */
  62974. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  62975. /**
  62976. * Computes a reflection matrix from a plane
  62977. * @param plane defines the reflection plane
  62978. * @param result defines the target matrix
  62979. */
  62980. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  62981. /**
  62982. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  62983. * @param xaxis defines the value of the 1st axis
  62984. * @param yaxis defines the value of the 2nd axis
  62985. * @param zaxis defines the value of the 3rd axis
  62986. * @param result defines the target matrix
  62987. */
  62988. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  62989. /**
  62990. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  62991. * @param quat defines the quaternion to use
  62992. * @param result defines the target matrix
  62993. */
  62994. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  62995. }
  62996. /**
  62997. * Represens a plane by the equation ax + by + cz + d = 0
  62998. */
  62999. export class Plane {
  63000. /**
  63001. * Normal of the plane (a,b,c)
  63002. */
  63003. normal: Vector3;
  63004. /**
  63005. * d component of the plane
  63006. */
  63007. d: number;
  63008. /**
  63009. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  63010. * @param a a component of the plane
  63011. * @param b b component of the plane
  63012. * @param c c component of the plane
  63013. * @param d d component of the plane
  63014. */
  63015. constructor(a: number, b: number, c: number, d: number);
  63016. /**
  63017. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  63018. */
  63019. asArray(): number[];
  63020. /**
  63021. * @returns a new plane copied from the current Plane.
  63022. */
  63023. clone(): Plane;
  63024. /**
  63025. * @returns the string "Plane".
  63026. */
  63027. getClassName(): string;
  63028. /**
  63029. * @returns the Plane hash code.
  63030. */
  63031. getHashCode(): number;
  63032. /**
  63033. * Normalize the current Plane in place.
  63034. * @returns the updated Plane.
  63035. */
  63036. normalize(): Plane;
  63037. /**
  63038. * Applies a transformation the plane and returns the result
  63039. * @param transformation the transformation matrix to be applied to the plane
  63040. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  63041. */
  63042. transform(transformation: DeepImmutable<Matrix>): Plane;
  63043. /**
  63044. * Calcualtte the dot product between the point and the plane normal
  63045. * @param point point to calculate the dot product with
  63046. * @returns the dot product (float) of the point coordinates and the plane normal.
  63047. */
  63048. dotCoordinate(point: DeepImmutable<Vector3>): number;
  63049. /**
  63050. * Updates the current Plane from the plane defined by the three given points.
  63051. * @param point1 one of the points used to contruct the plane
  63052. * @param point2 one of the points used to contruct the plane
  63053. * @param point3 one of the points used to contruct the plane
  63054. * @returns the updated Plane.
  63055. */
  63056. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  63057. /**
  63058. * Checks if the plane is facing a given direction
  63059. * @param direction the direction to check if the plane is facing
  63060. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  63061. * @returns True is the vector "direction" is the same side than the plane normal.
  63062. */
  63063. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  63064. /**
  63065. * Calculates the distance to a point
  63066. * @param point point to calculate distance to
  63067. * @returns the signed distance (float) from the given point to the Plane.
  63068. */
  63069. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  63070. /**
  63071. * Creates a plane from an array
  63072. * @param array the array to create a plane from
  63073. * @returns a new Plane from the given array.
  63074. */
  63075. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  63076. /**
  63077. * Creates a plane from three points
  63078. * @param point1 point used to create the plane
  63079. * @param point2 point used to create the plane
  63080. * @param point3 point used to create the plane
  63081. * @returns a new Plane defined by the three given points.
  63082. */
  63083. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  63084. /**
  63085. * Creates a plane from an origin point and a normal
  63086. * @param origin origin of the plane to be constructed
  63087. * @param normal normal of the plane to be constructed
  63088. * @returns a new Plane the normal vector to this plane at the given origin point.
  63089. * Note : the vector "normal" is updated because normalized.
  63090. */
  63091. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  63092. /**
  63093. * Calculates the distance from a plane and a point
  63094. * @param origin origin of the plane to be constructed
  63095. * @param normal normal of the plane to be constructed
  63096. * @param point point to calculate distance to
  63097. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  63098. */
  63099. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  63100. }
  63101. /**
  63102. * Class used to represent a viewport on screen
  63103. */
  63104. export class Viewport {
  63105. /** viewport left coordinate */
  63106. x: number;
  63107. /** viewport top coordinate */
  63108. y: number;
  63109. /**viewport width */
  63110. width: number;
  63111. /** viewport height */
  63112. height: number;
  63113. /**
  63114. * Creates a Viewport object located at (x, y) and sized (width, height)
  63115. * @param x defines viewport left coordinate
  63116. * @param y defines viewport top coordinate
  63117. * @param width defines the viewport width
  63118. * @param height defines the viewport height
  63119. */
  63120. constructor(
  63121. /** viewport left coordinate */
  63122. x: number,
  63123. /** viewport top coordinate */
  63124. y: number,
  63125. /**viewport width */
  63126. width: number,
  63127. /** viewport height */
  63128. height: number);
  63129. /**
  63130. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  63131. * @param renderWidth defines the rendering width
  63132. * @param renderHeight defines the rendering height
  63133. * @returns a new Viewport
  63134. */
  63135. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  63136. /**
  63137. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  63138. * @param renderWidth defines the rendering width
  63139. * @param renderHeight defines the rendering height
  63140. * @param ref defines the target viewport
  63141. * @returns the current viewport
  63142. */
  63143. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  63144. /**
  63145. * Returns a new Viewport copied from the current one
  63146. * @returns a new Viewport
  63147. */
  63148. clone(): Viewport;
  63149. }
  63150. /**
  63151. * Reprasents a camera frustum
  63152. */
  63153. export class Frustum {
  63154. /**
  63155. * Gets the planes representing the frustum
  63156. * @param transform matrix to be applied to the returned planes
  63157. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  63158. */
  63159. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  63160. /**
  63161. * Gets the near frustum plane transformed by the transform matrix
  63162. * @param transform transformation matrix to be applied to the resulting frustum plane
  63163. * @param frustumPlane the resuling frustum plane
  63164. */
  63165. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63166. /**
  63167. * Gets the far frustum plane transformed by the transform matrix
  63168. * @param transform transformation matrix to be applied to the resulting frustum plane
  63169. * @param frustumPlane the resuling frustum plane
  63170. */
  63171. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63172. /**
  63173. * Gets the left frustum plane transformed by the transform matrix
  63174. * @param transform transformation matrix to be applied to the resulting frustum plane
  63175. * @param frustumPlane the resuling frustum plane
  63176. */
  63177. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63178. /**
  63179. * Gets the right frustum plane transformed by the transform matrix
  63180. * @param transform transformation matrix to be applied to the resulting frustum plane
  63181. * @param frustumPlane the resuling frustum plane
  63182. */
  63183. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63184. /**
  63185. * Gets the top frustum plane transformed by the transform matrix
  63186. * @param transform transformation matrix to be applied to the resulting frustum plane
  63187. * @param frustumPlane the resuling frustum plane
  63188. */
  63189. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63190. /**
  63191. * Gets the bottom frustum plane transformed by the transform matrix
  63192. * @param transform transformation matrix to be applied to the resulting frustum plane
  63193. * @param frustumPlane the resuling frustum plane
  63194. */
  63195. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63196. /**
  63197. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  63198. * @param transform transformation matrix to be applied to the resulting frustum planes
  63199. * @param frustumPlanes the resuling frustum planes
  63200. */
  63201. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  63202. }
  63203. /** Defines supported spaces */
  63204. export enum Space {
  63205. /** Local (object) space */
  63206. LOCAL = 0,
  63207. /** World space */
  63208. WORLD = 1,
  63209. /** Bone space */
  63210. BONE = 2
  63211. }
  63212. /** Defines the 3 main axes */
  63213. export class Axis {
  63214. /** X axis */
  63215. static X: Vector3;
  63216. /** Y axis */
  63217. static Y: Vector3;
  63218. /** Z axis */
  63219. static Z: Vector3;
  63220. }
  63221. /** Class used to represent a Bezier curve */
  63222. export class BezierCurve {
  63223. /**
  63224. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  63225. * @param t defines the time
  63226. * @param x1 defines the left coordinate on X axis
  63227. * @param y1 defines the left coordinate on Y axis
  63228. * @param x2 defines the right coordinate on X axis
  63229. * @param y2 defines the right coordinate on Y axis
  63230. * @returns the interpolated value
  63231. */
  63232. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  63233. }
  63234. /**
  63235. * Defines potential orientation for back face culling
  63236. */
  63237. export enum Orientation {
  63238. /**
  63239. * Clockwise
  63240. */
  63241. CW = 0,
  63242. /** Counter clockwise */
  63243. CCW = 1
  63244. }
  63245. /**
  63246. * Defines angle representation
  63247. */
  63248. export class Angle {
  63249. private _radians;
  63250. /**
  63251. * Creates an Angle object of "radians" radians (float).
  63252. * @param radians the angle in radians
  63253. */
  63254. constructor(radians: number);
  63255. /**
  63256. * Get value in degrees
  63257. * @returns the Angle value in degrees (float)
  63258. */
  63259. degrees(): number;
  63260. /**
  63261. * Get value in radians
  63262. * @returns the Angle value in radians (float)
  63263. */
  63264. radians(): number;
  63265. /**
  63266. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  63267. * @param a defines first vector
  63268. * @param b defines second vector
  63269. * @returns a new Angle
  63270. */
  63271. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  63272. /**
  63273. * Gets a new Angle object from the given float in radians
  63274. * @param radians defines the angle value in radians
  63275. * @returns a new Angle
  63276. */
  63277. static FromRadians(radians: number): Angle;
  63278. /**
  63279. * Gets a new Angle object from the given float in degrees
  63280. * @param degrees defines the angle value in degrees
  63281. * @returns a new Angle
  63282. */
  63283. static FromDegrees(degrees: number): Angle;
  63284. }
  63285. /**
  63286. * This represents an arc in a 2d space.
  63287. */
  63288. export class Arc2 {
  63289. /** Defines the start point of the arc */
  63290. startPoint: Vector2;
  63291. /** Defines the mid point of the arc */
  63292. midPoint: Vector2;
  63293. /** Defines the end point of the arc */
  63294. endPoint: Vector2;
  63295. /**
  63296. * Defines the center point of the arc.
  63297. */
  63298. centerPoint: Vector2;
  63299. /**
  63300. * Defines the radius of the arc.
  63301. */
  63302. radius: number;
  63303. /**
  63304. * Defines the angle of the arc (from mid point to end point).
  63305. */
  63306. angle: Angle;
  63307. /**
  63308. * Defines the start angle of the arc (from start point to middle point).
  63309. */
  63310. startAngle: Angle;
  63311. /**
  63312. * Defines the orientation of the arc (clock wise/counter clock wise).
  63313. */
  63314. orientation: Orientation;
  63315. /**
  63316. * Creates an Arc object from the three given points : start, middle and end.
  63317. * @param startPoint Defines the start point of the arc
  63318. * @param midPoint Defines the midlle point of the arc
  63319. * @param endPoint Defines the end point of the arc
  63320. */
  63321. constructor(
  63322. /** Defines the start point of the arc */
  63323. startPoint: Vector2,
  63324. /** Defines the mid point of the arc */
  63325. midPoint: Vector2,
  63326. /** Defines the end point of the arc */
  63327. endPoint: Vector2);
  63328. }
  63329. /**
  63330. * Represents a 2D path made up of multiple 2D points
  63331. */
  63332. export class Path2 {
  63333. private _points;
  63334. private _length;
  63335. /**
  63336. * If the path start and end point are the same
  63337. */
  63338. closed: boolean;
  63339. /**
  63340. * Creates a Path2 object from the starting 2D coordinates x and y.
  63341. * @param x the starting points x value
  63342. * @param y the starting points y value
  63343. */
  63344. constructor(x: number, y: number);
  63345. /**
  63346. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  63347. * @param x the added points x value
  63348. * @param y the added points y value
  63349. * @returns the updated Path2.
  63350. */
  63351. addLineTo(x: number, y: number): Path2;
  63352. /**
  63353. * 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.
  63354. * @param midX middle point x value
  63355. * @param midY middle point y value
  63356. * @param endX end point x value
  63357. * @param endY end point y value
  63358. * @param numberOfSegments (default: 36)
  63359. * @returns the updated Path2.
  63360. */
  63361. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  63362. /**
  63363. * Closes the Path2.
  63364. * @returns the Path2.
  63365. */
  63366. close(): Path2;
  63367. /**
  63368. * Gets the sum of the distance between each sequential point in the path
  63369. * @returns the Path2 total length (float).
  63370. */
  63371. length(): number;
  63372. /**
  63373. * Gets the points which construct the path
  63374. * @returns the Path2 internal array of points.
  63375. */
  63376. getPoints(): Vector2[];
  63377. /**
  63378. * Retreives the point at the distance aways from the starting point
  63379. * @param normalizedLengthPosition the length along the path to retreive the point from
  63380. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  63381. */
  63382. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  63383. /**
  63384. * Creates a new path starting from an x and y position
  63385. * @param x starting x value
  63386. * @param y starting y value
  63387. * @returns a new Path2 starting at the coordinates (x, y).
  63388. */
  63389. static StartingAt(x: number, y: number): Path2;
  63390. }
  63391. /**
  63392. * Represents a 3D path made up of multiple 3D points
  63393. */
  63394. export class Path3D {
  63395. /**
  63396. * an array of Vector3, the curve axis of the Path3D
  63397. */
  63398. path: Vector3[];
  63399. private _curve;
  63400. private _distances;
  63401. private _tangents;
  63402. private _normals;
  63403. private _binormals;
  63404. private _raw;
  63405. /**
  63406. * new Path3D(path, normal, raw)
  63407. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  63408. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  63409. * @param path an array of Vector3, the curve axis of the Path3D
  63410. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  63411. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  63412. */
  63413. constructor(
  63414. /**
  63415. * an array of Vector3, the curve axis of the Path3D
  63416. */
  63417. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  63418. /**
  63419. * Returns the Path3D array of successive Vector3 designing its curve.
  63420. * @returns the Path3D array of successive Vector3 designing its curve.
  63421. */
  63422. getCurve(): Vector3[];
  63423. /**
  63424. * Returns an array populated with tangent vectors on each Path3D curve point.
  63425. * @returns an array populated with tangent vectors on each Path3D curve point.
  63426. */
  63427. getTangents(): Vector3[];
  63428. /**
  63429. * Returns an array populated with normal vectors on each Path3D curve point.
  63430. * @returns an array populated with normal vectors on each Path3D curve point.
  63431. */
  63432. getNormals(): Vector3[];
  63433. /**
  63434. * Returns an array populated with binormal vectors on each Path3D curve point.
  63435. * @returns an array populated with binormal vectors on each Path3D curve point.
  63436. */
  63437. getBinormals(): Vector3[];
  63438. /**
  63439. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  63440. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  63441. */
  63442. getDistances(): number[];
  63443. /**
  63444. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  63445. * @param path path which all values are copied into the curves points
  63446. * @param firstNormal which should be projected onto the curve
  63447. * @returns the same object updated.
  63448. */
  63449. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  63450. private _compute;
  63451. private _getFirstNonNullVector;
  63452. private _getLastNonNullVector;
  63453. private _normalVector;
  63454. }
  63455. /**
  63456. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  63457. * A Curve3 is designed from a series of successive Vector3.
  63458. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  63459. */
  63460. export class Curve3 {
  63461. private _points;
  63462. private _length;
  63463. /**
  63464. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  63465. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  63466. * @param v1 (Vector3) the control point
  63467. * @param v2 (Vector3) the end point of the Quadratic Bezier
  63468. * @param nbPoints (integer) the wanted number of points in the curve
  63469. * @returns the created Curve3
  63470. */
  63471. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63472. /**
  63473. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  63474. * @param v0 (Vector3) the origin point of the Cubic Bezier
  63475. * @param v1 (Vector3) the first control point
  63476. * @param v2 (Vector3) the second control point
  63477. * @param v3 (Vector3) the end point of the Cubic Bezier
  63478. * @param nbPoints (integer) the wanted number of points in the curve
  63479. * @returns the created Curve3
  63480. */
  63481. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63482. /**
  63483. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  63484. * @param p1 (Vector3) the origin point of the Hermite Spline
  63485. * @param t1 (Vector3) the tangent vector at the origin point
  63486. * @param p2 (Vector3) the end point of the Hermite Spline
  63487. * @param t2 (Vector3) the tangent vector at the end point
  63488. * @param nbPoints (integer) the wanted number of points in the curve
  63489. * @returns the created Curve3
  63490. */
  63491. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63492. /**
  63493. * Returns a Curve3 object along a CatmullRom Spline curve :
  63494. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  63495. * @param nbPoints (integer) the wanted number of points between each curve control points
  63496. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  63497. * @returns the created Curve3
  63498. */
  63499. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  63500. /**
  63501. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  63502. * A Curve3 is designed from a series of successive Vector3.
  63503. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  63504. * @param points points which make up the curve
  63505. */
  63506. constructor(points: Vector3[]);
  63507. /**
  63508. * @returns the Curve3 stored array of successive Vector3
  63509. */
  63510. getPoints(): Vector3[];
  63511. /**
  63512. * @returns the computed length (float) of the curve.
  63513. */
  63514. length(): number;
  63515. /**
  63516. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  63517. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  63518. * curveA and curveB keep unchanged.
  63519. * @param curve the curve to continue from this curve
  63520. * @returns the newly constructed curve
  63521. */
  63522. continue(curve: DeepImmutable<Curve3>): Curve3;
  63523. private _computeLength;
  63524. }
  63525. /**
  63526. * Contains position and normal vectors for a vertex
  63527. */
  63528. export class PositionNormalVertex {
  63529. /** the position of the vertex (defaut: 0,0,0) */
  63530. position: Vector3;
  63531. /** the normal of the vertex (defaut: 0,1,0) */
  63532. normal: Vector3;
  63533. /**
  63534. * Creates a PositionNormalVertex
  63535. * @param position the position of the vertex (defaut: 0,0,0)
  63536. * @param normal the normal of the vertex (defaut: 0,1,0)
  63537. */
  63538. constructor(
  63539. /** the position of the vertex (defaut: 0,0,0) */
  63540. position?: Vector3,
  63541. /** the normal of the vertex (defaut: 0,1,0) */
  63542. normal?: Vector3);
  63543. /**
  63544. * Clones the PositionNormalVertex
  63545. * @returns the cloned PositionNormalVertex
  63546. */
  63547. clone(): PositionNormalVertex;
  63548. }
  63549. /**
  63550. * Contains position, normal and uv vectors for a vertex
  63551. */
  63552. export class PositionNormalTextureVertex {
  63553. /** the position of the vertex (defaut: 0,0,0) */
  63554. position: Vector3;
  63555. /** the normal of the vertex (defaut: 0,1,0) */
  63556. normal: Vector3;
  63557. /** the uv of the vertex (default: 0,0) */
  63558. uv: Vector2;
  63559. /**
  63560. * Creates a PositionNormalTextureVertex
  63561. * @param position the position of the vertex (defaut: 0,0,0)
  63562. * @param normal the normal of the vertex (defaut: 0,1,0)
  63563. * @param uv the uv of the vertex (default: 0,0)
  63564. */
  63565. constructor(
  63566. /** the position of the vertex (defaut: 0,0,0) */
  63567. position?: Vector3,
  63568. /** the normal of the vertex (defaut: 0,1,0) */
  63569. normal?: Vector3,
  63570. /** the uv of the vertex (default: 0,0) */
  63571. uv?: Vector2);
  63572. /**
  63573. * Clones the PositionNormalTextureVertex
  63574. * @returns the cloned PositionNormalTextureVertex
  63575. */
  63576. clone(): PositionNormalTextureVertex;
  63577. }
  63578. /**
  63579. * @hidden
  63580. */
  63581. export class Tmp {
  63582. static Color3: Color3[];
  63583. static Color4: Color4[];
  63584. static Vector2: Vector2[];
  63585. static Vector3: Vector3[];
  63586. static Vector4: Vector4[];
  63587. static Quaternion: Quaternion[];
  63588. static Matrix: Matrix[];
  63589. }
  63590. }
  63591. declare module BABYLON {
  63592. /**
  63593. * Class used to enable access to offline support
  63594. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  63595. */
  63596. export interface IOfflineProvider {
  63597. /**
  63598. * Gets a boolean indicating if scene must be saved in the database
  63599. */
  63600. enableSceneOffline: boolean;
  63601. /**
  63602. * Gets a boolean indicating if textures must be saved in the database
  63603. */
  63604. enableTexturesOffline: boolean;
  63605. /**
  63606. * Open the offline support and make it available
  63607. * @param successCallback defines the callback to call on success
  63608. * @param errorCallback defines the callback to call on error
  63609. */
  63610. open(successCallback: () => void, errorCallback: () => void): void;
  63611. /**
  63612. * Loads an image from the offline support
  63613. * @param url defines the url to load from
  63614. * @param image defines the target DOM image
  63615. */
  63616. loadImage(url: string, image: HTMLImageElement): void;
  63617. /**
  63618. * Loads a file from offline support
  63619. * @param url defines the URL to load from
  63620. * @param sceneLoaded defines a callback to call on success
  63621. * @param progressCallBack defines a callback to call when progress changed
  63622. * @param errorCallback defines a callback to call on error
  63623. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  63624. */
  63625. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  63626. }
  63627. }
  63628. declare module BABYLON {
  63629. /**
  63630. * A class serves as a medium between the observable and its observers
  63631. */
  63632. export class EventState {
  63633. /**
  63634. * Create a new EventState
  63635. * @param mask defines the mask associated with this state
  63636. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  63637. * @param target defines the original target of the state
  63638. * @param currentTarget defines the current target of the state
  63639. */
  63640. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63641. /**
  63642. * Initialize the current event state
  63643. * @param mask defines the mask associated with this state
  63644. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  63645. * @param target defines the original target of the state
  63646. * @param currentTarget defines the current target of the state
  63647. * @returns the current event state
  63648. */
  63649. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  63650. /**
  63651. * An Observer can set this property to true to prevent subsequent observers of being notified
  63652. */
  63653. skipNextObservers: boolean;
  63654. /**
  63655. * Get the mask value that were used to trigger the event corresponding to this EventState object
  63656. */
  63657. mask: number;
  63658. /**
  63659. * The object that originally notified the event
  63660. */
  63661. target?: any;
  63662. /**
  63663. * The current object in the bubbling phase
  63664. */
  63665. currentTarget?: any;
  63666. /**
  63667. * This will be populated with the return value of the last function that was executed.
  63668. * If it is the first function in the callback chain it will be the event data.
  63669. */
  63670. lastReturnValue?: any;
  63671. }
  63672. /**
  63673. * Represent an Observer registered to a given Observable object.
  63674. */
  63675. export class Observer<T> {
  63676. /**
  63677. * Defines the callback to call when the observer is notified
  63678. */
  63679. callback: (eventData: T, eventState: EventState) => void;
  63680. /**
  63681. * Defines the mask of the observer (used to filter notifications)
  63682. */
  63683. mask: number;
  63684. /**
  63685. * Defines the current scope used to restore the JS context
  63686. */
  63687. scope: any;
  63688. /** @hidden */
  63689. _willBeUnregistered: boolean;
  63690. /**
  63691. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  63692. */
  63693. unregisterOnNextCall: boolean;
  63694. /**
  63695. * Creates a new observer
  63696. * @param callback defines the callback to call when the observer is notified
  63697. * @param mask defines the mask of the observer (used to filter notifications)
  63698. * @param scope defines the current scope used to restore the JS context
  63699. */
  63700. constructor(
  63701. /**
  63702. * Defines the callback to call when the observer is notified
  63703. */
  63704. callback: (eventData: T, eventState: EventState) => void,
  63705. /**
  63706. * Defines the mask of the observer (used to filter notifications)
  63707. */
  63708. mask: number,
  63709. /**
  63710. * Defines the current scope used to restore the JS context
  63711. */
  63712. scope?: any);
  63713. }
  63714. /**
  63715. * Represent a list of observers registered to multiple Observables object.
  63716. */
  63717. export class MultiObserver<T> {
  63718. private _observers;
  63719. private _observables;
  63720. /**
  63721. * Release associated resources
  63722. */
  63723. dispose(): void;
  63724. /**
  63725. * Raise a callback when one of the observable will notify
  63726. * @param observables defines a list of observables to watch
  63727. * @param callback defines the callback to call on notification
  63728. * @param mask defines the mask used to filter notifications
  63729. * @param scope defines the current scope used to restore the JS context
  63730. * @returns the new MultiObserver
  63731. */
  63732. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  63733. }
  63734. /**
  63735. * The Observable class is a simple implementation of the Observable pattern.
  63736. *
  63737. * 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.
  63738. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  63739. * 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).
  63740. * 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.
  63741. */
  63742. export class Observable<T> {
  63743. private _observers;
  63744. private _eventState;
  63745. private _onObserverAdded;
  63746. /**
  63747. * Creates a new observable
  63748. * @param onObserverAdded defines a callback to call when a new observer is added
  63749. */
  63750. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  63751. /**
  63752. * Create a new Observer with the specified callback
  63753. * @param callback the callback that will be executed for that Observer
  63754. * @param mask the mask used to filter observers
  63755. * @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.
  63756. * @param scope optional scope for the callback to be called from
  63757. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  63758. * @returns the new observer created for the callback
  63759. */
  63760. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  63761. /**
  63762. * Create a new Observer with the specified callback and unregisters after the next notification
  63763. * @param callback the callback that will be executed for that Observer
  63764. * @returns the new observer created for the callback
  63765. */
  63766. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  63767. /**
  63768. * Remove an Observer from the Observable object
  63769. * @param observer the instance of the Observer to remove
  63770. * @returns false if it doesn't belong to this Observable
  63771. */
  63772. remove(observer: Nullable<Observer<T>>): boolean;
  63773. /**
  63774. * Remove a callback from the Observable object
  63775. * @param callback the callback to remove
  63776. * @param scope optional scope. If used only the callbacks with this scope will be removed
  63777. * @returns false if it doesn't belong to this Observable
  63778. */
  63779. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  63780. private _deferUnregister;
  63781. private _remove;
  63782. /**
  63783. * Moves the observable to the top of the observer list making it get called first when notified
  63784. * @param observer the observer to move
  63785. */
  63786. makeObserverTopPriority(observer: Observer<T>): void;
  63787. /**
  63788. * Moves the observable to the bottom of the observer list making it get called last when notified
  63789. * @param observer the observer to move
  63790. */
  63791. makeObserverBottomPriority(observer: Observer<T>): void;
  63792. /**
  63793. * Notify all Observers by calling their respective callback with the given data
  63794. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  63795. * @param eventData defines the data to send to all observers
  63796. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  63797. * @param target defines the original target of the state
  63798. * @param currentTarget defines the current target of the state
  63799. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  63800. */
  63801. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  63802. /**
  63803. * Calling this will execute each callback, expecting it to be a promise or return a value.
  63804. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  63805. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  63806. * and it is crucial that all callbacks will be executed.
  63807. * The order of the callbacks is kept, callbacks are not executed parallel.
  63808. *
  63809. * @param eventData The data to be sent to each callback
  63810. * @param mask is used to filter observers defaults to -1
  63811. * @param target defines the callback target (see EventState)
  63812. * @param currentTarget defines he current object in the bubbling phase
  63813. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  63814. */
  63815. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  63816. /**
  63817. * Notify a specific observer
  63818. * @param observer defines the observer to notify
  63819. * @param eventData defines the data to be sent to each callback
  63820. * @param mask is used to filter observers defaults to -1
  63821. */
  63822. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  63823. /**
  63824. * Gets a boolean indicating if the observable has at least one observer
  63825. * @returns true is the Observable has at least one Observer registered
  63826. */
  63827. hasObservers(): boolean;
  63828. /**
  63829. * Clear the list of observers
  63830. */
  63831. clear(): void;
  63832. /**
  63833. * Clone the current observable
  63834. * @returns a new observable
  63835. */
  63836. clone(): Observable<T>;
  63837. /**
  63838. * Does this observable handles observer registered with a given mask
  63839. * @param mask defines the mask to be tested
  63840. * @return whether or not one observer registered with the given mask is handeled
  63841. **/
  63842. hasSpecificMask(mask?: number): boolean;
  63843. }
  63844. }
  63845. declare module BABYLON {
  63846. /**
  63847. * Class used to help managing file picking and drag'n'drop
  63848. * File Storage
  63849. */
  63850. export class FilesInputStore {
  63851. /**
  63852. * List of files ready to be loaded
  63853. */
  63854. static FilesToLoad: {
  63855. [key: string]: File;
  63856. };
  63857. }
  63858. }
  63859. declare module BABYLON {
  63860. /** Defines the cross module used constants to avoid circular dependncies */
  63861. export class Constants {
  63862. /** Defines that alpha blending is disabled */
  63863. static readonly ALPHA_DISABLE: number;
  63864. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  63865. static readonly ALPHA_ADD: number;
  63866. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  63867. static readonly ALPHA_COMBINE: number;
  63868. /** Defines that alpha blending to DEST - SRC * DEST */
  63869. static readonly ALPHA_SUBTRACT: number;
  63870. /** Defines that alpha blending to SRC * DEST */
  63871. static readonly ALPHA_MULTIPLY: number;
  63872. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  63873. static readonly ALPHA_MAXIMIZED: number;
  63874. /** Defines that alpha blending to SRC + DEST */
  63875. static readonly ALPHA_ONEONE: number;
  63876. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  63877. static readonly ALPHA_PREMULTIPLIED: number;
  63878. /**
  63879. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  63880. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  63881. */
  63882. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  63883. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  63884. static readonly ALPHA_INTERPOLATE: number;
  63885. /**
  63886. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  63887. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  63888. */
  63889. static readonly ALPHA_SCREENMODE: number;
  63890. /** Defines that the ressource is not delayed*/
  63891. static readonly DELAYLOADSTATE_NONE: number;
  63892. /** Defines that the ressource was successfully delay loaded */
  63893. static readonly DELAYLOADSTATE_LOADED: number;
  63894. /** Defines that the ressource is currently delay loading */
  63895. static readonly DELAYLOADSTATE_LOADING: number;
  63896. /** Defines that the ressource is delayed and has not started loading */
  63897. static readonly DELAYLOADSTATE_NOTLOADED: number;
  63898. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  63899. static readonly NEVER: number;
  63900. /** 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 */
  63901. static readonly ALWAYS: number;
  63902. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  63903. static readonly LESS: number;
  63904. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  63905. static readonly EQUAL: number;
  63906. /** 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 */
  63907. static readonly LEQUAL: number;
  63908. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  63909. static readonly GREATER: number;
  63910. /** 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 */
  63911. static readonly GEQUAL: number;
  63912. /** 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 */
  63913. static readonly NOTEQUAL: number;
  63914. /** Passed to stencilOperation to specify that stencil value must be kept */
  63915. static readonly KEEP: number;
  63916. /** Passed to stencilOperation to specify that stencil value must be replaced */
  63917. static readonly REPLACE: number;
  63918. /** Passed to stencilOperation to specify that stencil value must be incremented */
  63919. static readonly INCR: number;
  63920. /** Passed to stencilOperation to specify that stencil value must be decremented */
  63921. static readonly DECR: number;
  63922. /** Passed to stencilOperation to specify that stencil value must be inverted */
  63923. static readonly INVERT: number;
  63924. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  63925. static readonly INCR_WRAP: number;
  63926. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  63927. static readonly DECR_WRAP: number;
  63928. /** Texture is not repeating outside of 0..1 UVs */
  63929. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  63930. /** Texture is repeating outside of 0..1 UVs */
  63931. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  63932. /** Texture is repeating and mirrored */
  63933. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  63934. /** ALPHA */
  63935. static readonly TEXTUREFORMAT_ALPHA: number;
  63936. /** LUMINANCE */
  63937. static readonly TEXTUREFORMAT_LUMINANCE: number;
  63938. /** LUMINANCE_ALPHA */
  63939. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  63940. /** RGB */
  63941. static readonly TEXTUREFORMAT_RGB: number;
  63942. /** RGBA */
  63943. static readonly TEXTUREFORMAT_RGBA: number;
  63944. /** RED */
  63945. static readonly TEXTUREFORMAT_RED: number;
  63946. /** RED (2nd reference) */
  63947. static readonly TEXTUREFORMAT_R: number;
  63948. /** RG */
  63949. static readonly TEXTUREFORMAT_RG: number;
  63950. /** RED_INTEGER */
  63951. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  63952. /** RED_INTEGER (2nd reference) */
  63953. static readonly TEXTUREFORMAT_R_INTEGER: number;
  63954. /** RG_INTEGER */
  63955. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  63956. /** RGB_INTEGER */
  63957. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  63958. /** RGBA_INTEGER */
  63959. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  63960. /** UNSIGNED_BYTE */
  63961. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  63962. /** UNSIGNED_BYTE (2nd reference) */
  63963. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  63964. /** FLOAT */
  63965. static readonly TEXTURETYPE_FLOAT: number;
  63966. /** HALF_FLOAT */
  63967. static readonly TEXTURETYPE_HALF_FLOAT: number;
  63968. /** BYTE */
  63969. static readonly TEXTURETYPE_BYTE: number;
  63970. /** SHORT */
  63971. static readonly TEXTURETYPE_SHORT: number;
  63972. /** UNSIGNED_SHORT */
  63973. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  63974. /** INT */
  63975. static readonly TEXTURETYPE_INT: number;
  63976. /** UNSIGNED_INT */
  63977. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  63978. /** UNSIGNED_SHORT_4_4_4_4 */
  63979. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  63980. /** UNSIGNED_SHORT_5_5_5_1 */
  63981. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  63982. /** UNSIGNED_SHORT_5_6_5 */
  63983. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  63984. /** UNSIGNED_INT_2_10_10_10_REV */
  63985. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  63986. /** UNSIGNED_INT_24_8 */
  63987. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  63988. /** UNSIGNED_INT_10F_11F_11F_REV */
  63989. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  63990. /** UNSIGNED_INT_5_9_9_9_REV */
  63991. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  63992. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  63993. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  63994. /** nearest is mag = nearest and min = nearest and mip = linear */
  63995. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  63996. /** Bilinear is mag = linear and min = linear and mip = nearest */
  63997. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  63998. /** Trilinear is mag = linear and min = linear and mip = linear */
  63999. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  64000. /** nearest is mag = nearest and min = nearest and mip = linear */
  64001. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  64002. /** Bilinear is mag = linear and min = linear and mip = nearest */
  64003. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  64004. /** Trilinear is mag = linear and min = linear and mip = linear */
  64005. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  64006. /** mag = nearest and min = nearest and mip = nearest */
  64007. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  64008. /** mag = nearest and min = linear and mip = nearest */
  64009. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  64010. /** mag = nearest and min = linear and mip = linear */
  64011. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  64012. /** mag = nearest and min = linear and mip = none */
  64013. static readonly TEXTURE_NEAREST_LINEAR: number;
  64014. /** mag = nearest and min = nearest and mip = none */
  64015. static readonly TEXTURE_NEAREST_NEAREST: number;
  64016. /** mag = linear and min = nearest and mip = nearest */
  64017. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  64018. /** mag = linear and min = nearest and mip = linear */
  64019. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  64020. /** mag = linear and min = linear and mip = none */
  64021. static readonly TEXTURE_LINEAR_LINEAR: number;
  64022. /** mag = linear and min = nearest and mip = none */
  64023. static readonly TEXTURE_LINEAR_NEAREST: number;
  64024. /** Explicit coordinates mode */
  64025. static readonly TEXTURE_EXPLICIT_MODE: number;
  64026. /** Spherical coordinates mode */
  64027. static readonly TEXTURE_SPHERICAL_MODE: number;
  64028. /** Planar coordinates mode */
  64029. static readonly TEXTURE_PLANAR_MODE: number;
  64030. /** Cubic coordinates mode */
  64031. static readonly TEXTURE_CUBIC_MODE: number;
  64032. /** Projection coordinates mode */
  64033. static readonly TEXTURE_PROJECTION_MODE: number;
  64034. /** Skybox coordinates mode */
  64035. static readonly TEXTURE_SKYBOX_MODE: number;
  64036. /** Inverse Cubic coordinates mode */
  64037. static readonly TEXTURE_INVCUBIC_MODE: number;
  64038. /** Equirectangular coordinates mode */
  64039. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  64040. /** Equirectangular Fixed coordinates mode */
  64041. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  64042. /** Equirectangular Fixed Mirrored coordinates mode */
  64043. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  64044. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  64045. static readonly SCALEMODE_FLOOR: number;
  64046. /** Defines that texture rescaling will look for the nearest power of 2 size */
  64047. static readonly SCALEMODE_NEAREST: number;
  64048. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  64049. static readonly SCALEMODE_CEILING: number;
  64050. /**
  64051. * The dirty texture flag value
  64052. */
  64053. static readonly MATERIAL_TextureDirtyFlag: number;
  64054. /**
  64055. * The dirty light flag value
  64056. */
  64057. static readonly MATERIAL_LightDirtyFlag: number;
  64058. /**
  64059. * The dirty fresnel flag value
  64060. */
  64061. static readonly MATERIAL_FresnelDirtyFlag: number;
  64062. /**
  64063. * The dirty attribute flag value
  64064. */
  64065. static readonly MATERIAL_AttributesDirtyFlag: number;
  64066. /**
  64067. * The dirty misc flag value
  64068. */
  64069. static readonly MATERIAL_MiscDirtyFlag: number;
  64070. /**
  64071. * The all dirty flag value
  64072. */
  64073. static readonly MATERIAL_AllDirtyFlag: number;
  64074. /**
  64075. * Returns the triangle fill mode
  64076. */
  64077. static readonly MATERIAL_TriangleFillMode: number;
  64078. /**
  64079. * Returns the wireframe mode
  64080. */
  64081. static readonly MATERIAL_WireFrameFillMode: number;
  64082. /**
  64083. * Returns the point fill mode
  64084. */
  64085. static readonly MATERIAL_PointFillMode: number;
  64086. /**
  64087. * Returns the point list draw mode
  64088. */
  64089. static readonly MATERIAL_PointListDrawMode: number;
  64090. /**
  64091. * Returns the line list draw mode
  64092. */
  64093. static readonly MATERIAL_LineListDrawMode: number;
  64094. /**
  64095. * Returns the line loop draw mode
  64096. */
  64097. static readonly MATERIAL_LineLoopDrawMode: number;
  64098. /**
  64099. * Returns the line strip draw mode
  64100. */
  64101. static readonly MATERIAL_LineStripDrawMode: number;
  64102. /**
  64103. * Returns the triangle strip draw mode
  64104. */
  64105. static readonly MATERIAL_TriangleStripDrawMode: number;
  64106. /**
  64107. * Returns the triangle fan draw mode
  64108. */
  64109. static readonly MATERIAL_TriangleFanDrawMode: number;
  64110. /**
  64111. * Stores the clock-wise side orientation
  64112. */
  64113. static readonly MATERIAL_ClockWiseSideOrientation: number;
  64114. /**
  64115. * Stores the counter clock-wise side orientation
  64116. */
  64117. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  64118. /**
  64119. * Nothing
  64120. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64121. */
  64122. static readonly ACTION_NothingTrigger: number;
  64123. /**
  64124. * On pick
  64125. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64126. */
  64127. static readonly ACTION_OnPickTrigger: number;
  64128. /**
  64129. * On left pick
  64130. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64131. */
  64132. static readonly ACTION_OnLeftPickTrigger: number;
  64133. /**
  64134. * On right pick
  64135. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64136. */
  64137. static readonly ACTION_OnRightPickTrigger: number;
  64138. /**
  64139. * On center pick
  64140. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64141. */
  64142. static readonly ACTION_OnCenterPickTrigger: number;
  64143. /**
  64144. * On pick down
  64145. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64146. */
  64147. static readonly ACTION_OnPickDownTrigger: number;
  64148. /**
  64149. * On double pick
  64150. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64151. */
  64152. static readonly ACTION_OnDoublePickTrigger: number;
  64153. /**
  64154. * On pick up
  64155. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64156. */
  64157. static readonly ACTION_OnPickUpTrigger: number;
  64158. /**
  64159. * On pick out.
  64160. * This trigger will only be raised if you also declared a OnPickDown
  64161. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64162. */
  64163. static readonly ACTION_OnPickOutTrigger: number;
  64164. /**
  64165. * On long press
  64166. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64167. */
  64168. static readonly ACTION_OnLongPressTrigger: number;
  64169. /**
  64170. * On pointer over
  64171. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64172. */
  64173. static readonly ACTION_OnPointerOverTrigger: number;
  64174. /**
  64175. * On pointer out
  64176. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64177. */
  64178. static readonly ACTION_OnPointerOutTrigger: number;
  64179. /**
  64180. * On every frame
  64181. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64182. */
  64183. static readonly ACTION_OnEveryFrameTrigger: number;
  64184. /**
  64185. * On intersection enter
  64186. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64187. */
  64188. static readonly ACTION_OnIntersectionEnterTrigger: number;
  64189. /**
  64190. * On intersection exit
  64191. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64192. */
  64193. static readonly ACTION_OnIntersectionExitTrigger: number;
  64194. /**
  64195. * On key down
  64196. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64197. */
  64198. static readonly ACTION_OnKeyDownTrigger: number;
  64199. /**
  64200. * On key up
  64201. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64202. */
  64203. static readonly ACTION_OnKeyUpTrigger: number;
  64204. /**
  64205. * Billboard mode will only apply to Y axis
  64206. */
  64207. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  64208. /**
  64209. * Billboard mode will apply to all axes
  64210. */
  64211. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  64212. /**
  64213. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  64214. */
  64215. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  64216. /**
  64217. * Gets or sets base Assets URL
  64218. */
  64219. static readonly PARTICLES_BaseAssetsUrl: string;
  64220. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  64221. * Test order :
  64222. * Is the bounding sphere outside the frustum ?
  64223. * If not, are the bounding box vertices outside the frustum ?
  64224. * It not, then the cullable object is in the frustum.
  64225. */
  64226. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  64227. /** Culling strategy : Bounding Sphere Only.
  64228. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  64229. * It's also less accurate than the standard because some not visible objects can still be selected.
  64230. * Test : is the bounding sphere outside the frustum ?
  64231. * If not, then the cullable object is in the frustum.
  64232. */
  64233. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  64234. /** Culling strategy : Optimistic Inclusion.
  64235. * This in an inclusion test first, then the standard exclusion test.
  64236. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  64237. * 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.
  64238. * Anyway, it's as accurate as the standard strategy.
  64239. * Test :
  64240. * Is the cullable object bounding sphere center in the frustum ?
  64241. * If not, apply the default culling strategy.
  64242. */
  64243. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  64244. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  64245. * This in an inclusion test first, then the bounding sphere only exclusion test.
  64246. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  64247. * 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.
  64248. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  64249. * Test :
  64250. * Is the cullable object bounding sphere center in the frustum ?
  64251. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  64252. */
  64253. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  64254. /**
  64255. * No logging while loading
  64256. */
  64257. static readonly SCENELOADER_NO_LOGGING: number;
  64258. /**
  64259. * Minimal logging while loading
  64260. */
  64261. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  64262. /**
  64263. * Summary logging while loading
  64264. */
  64265. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  64266. /**
  64267. * Detailled logging while loading
  64268. */
  64269. static readonly SCENELOADER_DETAILED_LOGGING: number;
  64270. }
  64271. }
  64272. declare module BABYLON {
  64273. /**
  64274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  64275. * Babylon.js
  64276. */
  64277. export class DomManagement {
  64278. /**
  64279. * Checks if the window object exists
  64280. * @returns true if the window object exists
  64281. */
  64282. static IsWindowObjectExist(): boolean;
  64283. /**
  64284. * Extracts text content from a DOM element hierarchy
  64285. * @param element defines the root element
  64286. * @returns a string
  64287. */
  64288. static GetDOMTextContent(element: HTMLElement): string;
  64289. }
  64290. }
  64291. declare module BABYLON {
  64292. /**
  64293. * Logger used througouht the application to allow configuration of
  64294. * the log level required for the messages.
  64295. */
  64296. export class Logger {
  64297. /**
  64298. * No log
  64299. */
  64300. static readonly NoneLogLevel: number;
  64301. /**
  64302. * Only message logs
  64303. */
  64304. static readonly MessageLogLevel: number;
  64305. /**
  64306. * Only warning logs
  64307. */
  64308. static readonly WarningLogLevel: number;
  64309. /**
  64310. * Only error logs
  64311. */
  64312. static readonly ErrorLogLevel: number;
  64313. /**
  64314. * All logs
  64315. */
  64316. static readonly AllLogLevel: number;
  64317. private static _LogCache;
  64318. /**
  64319. * Gets a value indicating the number of loading errors
  64320. * @ignorenaming
  64321. */
  64322. static errorsCount: number;
  64323. /**
  64324. * Callback called when a new log is added
  64325. */
  64326. static OnNewCacheEntry: (entry: string) => void;
  64327. private static _AddLogEntry;
  64328. private static _FormatMessage;
  64329. private static _LogDisabled;
  64330. private static _LogEnabled;
  64331. private static _WarnDisabled;
  64332. private static _WarnEnabled;
  64333. private static _ErrorDisabled;
  64334. private static _ErrorEnabled;
  64335. /**
  64336. * Log a message to the console
  64337. */
  64338. static Log: (message: string) => void;
  64339. /**
  64340. * Write a warning message to the console
  64341. */
  64342. static Warn: (message: string) => void;
  64343. /**
  64344. * Write an error message to the console
  64345. */
  64346. static Error: (message: string) => void;
  64347. /**
  64348. * Gets current log cache (list of logs)
  64349. */
  64350. static readonly LogCache: string;
  64351. /**
  64352. * Clears the log cache
  64353. */
  64354. static ClearLogCache(): void;
  64355. /**
  64356. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  64357. */
  64358. static LogLevels: number;
  64359. }
  64360. }
  64361. declare module BABYLON {
  64362. /** @hidden */
  64363. export class _TypeStore {
  64364. /** @hidden */
  64365. static RegisteredTypes: {
  64366. [key: string]: Object;
  64367. };
  64368. /** @hidden */
  64369. static GetClass(fqdn: string): any;
  64370. }
  64371. }
  64372. declare module BABYLON {
  64373. /**
  64374. * Class containing a set of static utilities functions for deep copy.
  64375. */
  64376. export class DeepCopier {
  64377. /**
  64378. * Tries to copy an object by duplicating every property
  64379. * @param source defines the source object
  64380. * @param destination defines the target object
  64381. * @param doNotCopyList defines a list of properties to avoid
  64382. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  64383. */
  64384. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  64385. }
  64386. }
  64387. declare module BABYLON {
  64388. /**
  64389. * Class containing a set of static utilities functions for precision date
  64390. */
  64391. export class PrecisionDate {
  64392. /**
  64393. * Gets either window.performance.now() if supported or Date.now() else
  64394. */
  64395. static readonly Now: number;
  64396. }
  64397. }
  64398. declare module BABYLON {
  64399. /** @hidden */
  64400. export class _DevTools {
  64401. static WarnImport(name: string): string;
  64402. }
  64403. }
  64404. declare module BABYLON {
  64405. /**
  64406. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  64407. */
  64408. export class WebRequest {
  64409. private _xhr;
  64410. /**
  64411. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  64412. * i.e. when loading files, where the server/service expects an Authorization header
  64413. */
  64414. static CustomRequestHeaders: {
  64415. [key: string]: string;
  64416. };
  64417. /**
  64418. * Add callback functions in this array to update all the requests before they get sent to the network
  64419. */
  64420. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  64421. private _injectCustomRequestHeaders;
  64422. /**
  64423. * Gets or sets a function to be called when loading progress changes
  64424. */
  64425. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  64426. /**
  64427. * Returns client's state
  64428. */
  64429. readonly readyState: number;
  64430. /**
  64431. * Returns client's status
  64432. */
  64433. readonly status: number;
  64434. /**
  64435. * Returns client's status as a text
  64436. */
  64437. readonly statusText: string;
  64438. /**
  64439. * Returns client's response
  64440. */
  64441. readonly response: any;
  64442. /**
  64443. * Returns client's response url
  64444. */
  64445. readonly responseURL: string;
  64446. /**
  64447. * Returns client's response as text
  64448. */
  64449. readonly responseText: string;
  64450. /**
  64451. * Gets or sets the expected response type
  64452. */
  64453. responseType: XMLHttpRequestResponseType;
  64454. /** @hidden */
  64455. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  64456. /** @hidden */
  64457. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  64458. /**
  64459. * Cancels any network activity
  64460. */
  64461. abort(): void;
  64462. /**
  64463. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  64464. * @param body defines an optional request body
  64465. */
  64466. send(body?: Document | BodyInit | null): void;
  64467. /**
  64468. * Sets the request method, request URL
  64469. * @param method defines the method to use (GET, POST, etc..)
  64470. * @param url defines the url to connect with
  64471. */
  64472. open(method: string, url: string): void;
  64473. }
  64474. }
  64475. declare module BABYLON {
  64476. /**
  64477. * Class used to evalaute queries containing `and` and `or` operators
  64478. */
  64479. export class AndOrNotEvaluator {
  64480. /**
  64481. * Evaluate a query
  64482. * @param query defines the query to evaluate
  64483. * @param evaluateCallback defines the callback used to filter result
  64484. * @returns true if the query matches
  64485. */
  64486. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  64487. private static _HandleParenthesisContent;
  64488. private static _SimplifyNegation;
  64489. }
  64490. }
  64491. declare module BABYLON {
  64492. /**
  64493. * Class used to store custom tags
  64494. */
  64495. export class Tags {
  64496. /**
  64497. * Adds support for tags on the given object
  64498. * @param obj defines the object to use
  64499. */
  64500. static EnableFor(obj: any): void;
  64501. /**
  64502. * Removes tags support
  64503. * @param obj defines the object to use
  64504. */
  64505. static DisableFor(obj: any): void;
  64506. /**
  64507. * Gets a boolean indicating if the given object has tags
  64508. * @param obj defines the object to use
  64509. * @returns a boolean
  64510. */
  64511. static HasTags(obj: any): boolean;
  64512. /**
  64513. * Gets the tags available on a given object
  64514. * @param obj defines the object to use
  64515. * @param asString defines if the tags must be returned as a string instead of an array of strings
  64516. * @returns the tags
  64517. */
  64518. static GetTags(obj: any, asString?: boolean): any;
  64519. /**
  64520. * Adds tags to an object
  64521. * @param obj defines the object to use
  64522. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  64523. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  64524. */
  64525. static AddTagsTo(obj: any, tagsString: string): void;
  64526. /**
  64527. * @hidden
  64528. */
  64529. static _AddTagTo(obj: any, tag: string): void;
  64530. /**
  64531. * Removes specific tags from a specific object
  64532. * @param obj defines the object to use
  64533. * @param tagsString defines the tags to remove
  64534. */
  64535. static RemoveTagsFrom(obj: any, tagsString: string): void;
  64536. /**
  64537. * @hidden
  64538. */
  64539. static _RemoveTagFrom(obj: any, tag: string): void;
  64540. /**
  64541. * Defines if tags hosted on an object match a given query
  64542. * @param obj defines the object to use
  64543. * @param tagsQuery defines the tag query
  64544. * @returns a boolean
  64545. */
  64546. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  64547. }
  64548. }
  64549. declare module BABYLON {
  64550. /**
  64551. * Manages the defines for the Material
  64552. */
  64553. export class MaterialDefines {
  64554. private _keys;
  64555. private _isDirty;
  64556. /** @hidden */
  64557. _renderId: number;
  64558. /** @hidden */
  64559. _areLightsDirty: boolean;
  64560. /** @hidden */
  64561. _areAttributesDirty: boolean;
  64562. /** @hidden */
  64563. _areTexturesDirty: boolean;
  64564. /** @hidden */
  64565. _areFresnelDirty: boolean;
  64566. /** @hidden */
  64567. _areMiscDirty: boolean;
  64568. /** @hidden */
  64569. _areImageProcessingDirty: boolean;
  64570. /** @hidden */
  64571. _normals: boolean;
  64572. /** @hidden */
  64573. _uvs: boolean;
  64574. /** @hidden */
  64575. _needNormals: boolean;
  64576. /** @hidden */
  64577. _needUVs: boolean;
  64578. /**
  64579. * Specifies if the material needs to be re-calculated
  64580. */
  64581. readonly isDirty: boolean;
  64582. /**
  64583. * Marks the material to indicate that it has been re-calculated
  64584. */
  64585. markAsProcessed(): void;
  64586. /**
  64587. * Marks the material to indicate that it needs to be re-calculated
  64588. */
  64589. markAsUnprocessed(): void;
  64590. /**
  64591. * Marks the material to indicate all of its defines need to be re-calculated
  64592. */
  64593. markAllAsDirty(): void;
  64594. /**
  64595. * Marks the material to indicate that image processing needs to be re-calculated
  64596. */
  64597. markAsImageProcessingDirty(): void;
  64598. /**
  64599. * Marks the material to indicate the lights need to be re-calculated
  64600. */
  64601. markAsLightDirty(): void;
  64602. /**
  64603. * Marks the attribute state as changed
  64604. */
  64605. markAsAttributesDirty(): void;
  64606. /**
  64607. * Marks the texture state as changed
  64608. */
  64609. markAsTexturesDirty(): void;
  64610. /**
  64611. * Marks the fresnel state as changed
  64612. */
  64613. markAsFresnelDirty(): void;
  64614. /**
  64615. * Marks the misc state as changed
  64616. */
  64617. markAsMiscDirty(): void;
  64618. /**
  64619. * Rebuilds the material defines
  64620. */
  64621. rebuild(): void;
  64622. /**
  64623. * Specifies if two material defines are equal
  64624. * @param other - A material define instance to compare to
  64625. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  64626. */
  64627. isEqual(other: MaterialDefines): boolean;
  64628. /**
  64629. * Clones this instance's defines to another instance
  64630. * @param other - material defines to clone values to
  64631. */
  64632. cloneTo(other: MaterialDefines): void;
  64633. /**
  64634. * Resets the material define values
  64635. */
  64636. reset(): void;
  64637. /**
  64638. * Converts the material define values to a string
  64639. * @returns - String of material define information
  64640. */
  64641. toString(): string;
  64642. }
  64643. }
  64644. declare module BABYLON {
  64645. /**
  64646. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  64647. */
  64648. export class PerformanceMonitor {
  64649. private _enabled;
  64650. private _rollingFrameTime;
  64651. private _lastFrameTimeMs;
  64652. /**
  64653. * constructor
  64654. * @param frameSampleSize The number of samples required to saturate the sliding window
  64655. */
  64656. constructor(frameSampleSize?: number);
  64657. /**
  64658. * Samples current frame
  64659. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  64660. */
  64661. sampleFrame(timeMs?: number): void;
  64662. /**
  64663. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  64664. */
  64665. readonly averageFrameTime: number;
  64666. /**
  64667. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  64668. */
  64669. readonly averageFrameTimeVariance: number;
  64670. /**
  64671. * Returns the frame time of the most recent frame
  64672. */
  64673. readonly instantaneousFrameTime: number;
  64674. /**
  64675. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  64676. */
  64677. readonly averageFPS: number;
  64678. /**
  64679. * Returns the average framerate in frames per second using the most recent frame time
  64680. */
  64681. readonly instantaneousFPS: number;
  64682. /**
  64683. * Returns true if enough samples have been taken to completely fill the sliding window
  64684. */
  64685. readonly isSaturated: boolean;
  64686. /**
  64687. * Enables contributions to the sliding window sample set
  64688. */
  64689. enable(): void;
  64690. /**
  64691. * Disables contributions to the sliding window sample set
  64692. * Samples will not be interpolated over the disabled period
  64693. */
  64694. disable(): void;
  64695. /**
  64696. * Returns true if sampling is enabled
  64697. */
  64698. readonly isEnabled: boolean;
  64699. /**
  64700. * Resets performance monitor
  64701. */
  64702. reset(): void;
  64703. }
  64704. /**
  64705. * RollingAverage
  64706. *
  64707. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  64708. */
  64709. export class RollingAverage {
  64710. /**
  64711. * Current average
  64712. */
  64713. average: number;
  64714. /**
  64715. * Current variance
  64716. */
  64717. variance: number;
  64718. protected _samples: Array<number>;
  64719. protected _sampleCount: number;
  64720. protected _pos: number;
  64721. protected _m2: number;
  64722. /**
  64723. * constructor
  64724. * @param length The number of samples required to saturate the sliding window
  64725. */
  64726. constructor(length: number);
  64727. /**
  64728. * Adds a sample to the sample set
  64729. * @param v The sample value
  64730. */
  64731. add(v: number): void;
  64732. /**
  64733. * Returns previously added values or null if outside of history or outside the sliding window domain
  64734. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  64735. * @return Value previously recorded with add() or null if outside of range
  64736. */
  64737. history(i: number): number;
  64738. /**
  64739. * Returns true if enough samples have been taken to completely fill the sliding window
  64740. * @return true if sample-set saturated
  64741. */
  64742. isSaturated(): boolean;
  64743. /**
  64744. * Resets the rolling average (equivalent to 0 samples taken so far)
  64745. */
  64746. reset(): void;
  64747. /**
  64748. * Wraps a value around the sample range boundaries
  64749. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  64750. * @return Wrapped position in sample range
  64751. */
  64752. protected _wrapPosition(i: number): number;
  64753. }
  64754. }
  64755. declare module BABYLON {
  64756. /**
  64757. * This class implement a typical dictionary using a string as key and the generic type T as value.
  64758. * The underlying implementation relies on an associative array to ensure the best performances.
  64759. * The value can be anything including 'null' but except 'undefined'
  64760. */
  64761. export class StringDictionary<T> {
  64762. /**
  64763. * This will clear this dictionary and copy the content from the 'source' one.
  64764. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  64765. * @param source the dictionary to take the content from and copy to this dictionary
  64766. */
  64767. copyFrom(source: StringDictionary<T>): void;
  64768. /**
  64769. * Get a value based from its key
  64770. * @param key the given key to get the matching value from
  64771. * @return the value if found, otherwise undefined is returned
  64772. */
  64773. get(key: string): T | undefined;
  64774. /**
  64775. * Get a value from its key or add it if it doesn't exist.
  64776. * This method will ensure you that a given key/data will be present in the dictionary.
  64777. * @param key the given key to get the matching value from
  64778. * @param factory the factory that will create the value if the key is not present in the dictionary.
  64779. * The factory will only be invoked if there's no data for the given key.
  64780. * @return the value corresponding to the key.
  64781. */
  64782. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  64783. /**
  64784. * Get a value from its key if present in the dictionary otherwise add it
  64785. * @param key the key to get the value from
  64786. * @param val if there's no such key/value pair in the dictionary add it with this value
  64787. * @return the value corresponding to the key
  64788. */
  64789. getOrAdd(key: string, val: T): T;
  64790. /**
  64791. * Check if there's a given key in the dictionary
  64792. * @param key the key to check for
  64793. * @return true if the key is present, false otherwise
  64794. */
  64795. contains(key: string): boolean;
  64796. /**
  64797. * Add a new key and its corresponding value
  64798. * @param key the key to add
  64799. * @param value the value corresponding to the key
  64800. * @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
  64801. */
  64802. add(key: string, value: T): boolean;
  64803. /**
  64804. * Update a specific value associated to a key
  64805. * @param key defines the key to use
  64806. * @param value defines the value to store
  64807. * @returns true if the value was updated (or false if the key was not found)
  64808. */
  64809. set(key: string, value: T): boolean;
  64810. /**
  64811. * Get the element of the given key and remove it from the dictionary
  64812. * @param key defines the key to search
  64813. * @returns the value associated with the key or null if not found
  64814. */
  64815. getAndRemove(key: string): Nullable<T>;
  64816. /**
  64817. * Remove a key/value from the dictionary.
  64818. * @param key the key to remove
  64819. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  64820. */
  64821. remove(key: string): boolean;
  64822. /**
  64823. * Clear the whole content of the dictionary
  64824. */
  64825. clear(): void;
  64826. /**
  64827. * Gets the current count
  64828. */
  64829. readonly count: number;
  64830. /**
  64831. * Execute a callback on each key/val of the dictionary.
  64832. * Note that you can remove any element in this dictionary in the callback implementation
  64833. * @param callback the callback to execute on a given key/value pair
  64834. */
  64835. forEach(callback: (key: string, val: T) => void): void;
  64836. /**
  64837. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  64838. * If the callback returns null or undefined the method will iterate to the next key/value pair
  64839. * Note that you can remove any element in this dictionary in the callback implementation
  64840. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  64841. * @returns the first item
  64842. */
  64843. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  64844. private _count;
  64845. private _data;
  64846. }
  64847. }
  64848. declare module BABYLON {
  64849. /**
  64850. * Helper class that provides a small promise polyfill
  64851. */
  64852. export class PromisePolyfill {
  64853. /**
  64854. * Static function used to check if the polyfill is required
  64855. * If this is the case then the function will inject the polyfill to window.Promise
  64856. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  64857. */
  64858. static Apply(force?: boolean): void;
  64859. }
  64860. }
  64861. declare module BABYLON {
  64862. /**
  64863. * Class used to store data that will be store in GPU memory
  64864. */
  64865. export class Buffer {
  64866. private _engine;
  64867. private _buffer;
  64868. /** @hidden */
  64869. _data: Nullable<DataArray>;
  64870. private _updatable;
  64871. private _instanced;
  64872. /**
  64873. * Gets the byte stride.
  64874. */
  64875. readonly byteStride: number;
  64876. /**
  64877. * Constructor
  64878. * @param engine the engine
  64879. * @param data the data to use for this buffer
  64880. * @param updatable whether the data is updatable
  64881. * @param stride the stride (optional)
  64882. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  64883. * @param instanced whether the buffer is instanced (optional)
  64884. * @param useBytes set to true if the stride in in bytes (optional)
  64885. */
  64886. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  64887. /**
  64888. * Create a new VertexBuffer based on the current buffer
  64889. * @param kind defines the vertex buffer kind (position, normal, etc.)
  64890. * @param offset defines offset in the buffer (0 by default)
  64891. * @param size defines the size in floats of attributes (position is 3 for instance)
  64892. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  64893. * @param instanced defines if the vertex buffer contains indexed data
  64894. * @param useBytes defines if the offset and stride are in bytes
  64895. * @returns the new vertex buffer
  64896. */
  64897. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  64898. /**
  64899. * Gets a boolean indicating if the Buffer is updatable?
  64900. * @returns true if the buffer is updatable
  64901. */
  64902. isUpdatable(): boolean;
  64903. /**
  64904. * Gets current buffer's data
  64905. * @returns a DataArray or null
  64906. */
  64907. getData(): Nullable<DataArray>;
  64908. /**
  64909. * Gets underlying native buffer
  64910. * @returns underlying native buffer
  64911. */
  64912. getBuffer(): Nullable<WebGLBuffer>;
  64913. /**
  64914. * Gets the stride in float32 units (i.e. byte stride / 4).
  64915. * May not be an integer if the byte stride is not divisible by 4.
  64916. * DEPRECATED. Use byteStride instead.
  64917. * @returns the stride in float32 units
  64918. */
  64919. getStrideSize(): number;
  64920. /**
  64921. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  64922. * @param data defines the data to store
  64923. */
  64924. create(data?: Nullable<DataArray>): void;
  64925. /** @hidden */
  64926. _rebuild(): void;
  64927. /**
  64928. * Update current buffer data
  64929. * @param data defines the data to store
  64930. */
  64931. update(data: DataArray): void;
  64932. /**
  64933. * Updates the data directly.
  64934. * @param data the new data
  64935. * @param offset the new offset
  64936. * @param vertexCount the vertex count (optional)
  64937. * @param useBytes set to true if the offset is in bytes
  64938. */
  64939. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  64940. /**
  64941. * Release all resources
  64942. */
  64943. dispose(): void;
  64944. }
  64945. /**
  64946. * Specialized buffer used to store vertex data
  64947. */
  64948. export class VertexBuffer {
  64949. /** @hidden */
  64950. _buffer: Buffer;
  64951. private _kind;
  64952. private _size;
  64953. private _ownsBuffer;
  64954. private _instanced;
  64955. private _instanceDivisor;
  64956. /**
  64957. * The byte type.
  64958. */
  64959. static readonly BYTE: number;
  64960. /**
  64961. * The unsigned byte type.
  64962. */
  64963. static readonly UNSIGNED_BYTE: number;
  64964. /**
  64965. * The short type.
  64966. */
  64967. static readonly SHORT: number;
  64968. /**
  64969. * The unsigned short type.
  64970. */
  64971. static readonly UNSIGNED_SHORT: number;
  64972. /**
  64973. * The integer type.
  64974. */
  64975. static readonly INT: number;
  64976. /**
  64977. * The unsigned integer type.
  64978. */
  64979. static readonly UNSIGNED_INT: number;
  64980. /**
  64981. * The float type.
  64982. */
  64983. static readonly FLOAT: number;
  64984. /**
  64985. * Gets or sets the instance divisor when in instanced mode
  64986. */
  64987. instanceDivisor: number;
  64988. /**
  64989. * Gets the byte stride.
  64990. */
  64991. readonly byteStride: number;
  64992. /**
  64993. * Gets the byte offset.
  64994. */
  64995. readonly byteOffset: number;
  64996. /**
  64997. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  64998. */
  64999. readonly normalized: boolean;
  65000. /**
  65001. * Gets the data type of each component in the array.
  65002. */
  65003. readonly type: number;
  65004. /**
  65005. * Constructor
  65006. * @param engine the engine
  65007. * @param data the data to use for this vertex buffer
  65008. * @param kind the vertex buffer kind
  65009. * @param updatable whether the data is updatable
  65010. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  65011. * @param stride the stride (optional)
  65012. * @param instanced whether the buffer is instanced (optional)
  65013. * @param offset the offset of the data (optional)
  65014. * @param size the number of components (optional)
  65015. * @param type the type of the component (optional)
  65016. * @param normalized whether the data contains normalized data (optional)
  65017. * @param useBytes set to true if stride and offset are in bytes (optional)
  65018. */
  65019. 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);
  65020. /** @hidden */
  65021. _rebuild(): void;
  65022. /**
  65023. * Returns the kind of the VertexBuffer (string)
  65024. * @returns a string
  65025. */
  65026. getKind(): string;
  65027. /**
  65028. * Gets a boolean indicating if the VertexBuffer is updatable?
  65029. * @returns true if the buffer is updatable
  65030. */
  65031. isUpdatable(): boolean;
  65032. /**
  65033. * Gets current buffer's data
  65034. * @returns a DataArray or null
  65035. */
  65036. getData(): Nullable<DataArray>;
  65037. /**
  65038. * Gets underlying native buffer
  65039. * @returns underlying native buffer
  65040. */
  65041. getBuffer(): Nullable<WebGLBuffer>;
  65042. /**
  65043. * Gets the stride in float32 units (i.e. byte stride / 4).
  65044. * May not be an integer if the byte stride is not divisible by 4.
  65045. * DEPRECATED. Use byteStride instead.
  65046. * @returns the stride in float32 units
  65047. */
  65048. getStrideSize(): number;
  65049. /**
  65050. * Returns the offset as a multiple of the type byte length.
  65051. * DEPRECATED. Use byteOffset instead.
  65052. * @returns the offset in bytes
  65053. */
  65054. getOffset(): number;
  65055. /**
  65056. * Returns the number of components per vertex attribute (integer)
  65057. * @returns the size in float
  65058. */
  65059. getSize(): number;
  65060. /**
  65061. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  65062. * @returns true if this buffer is instanced
  65063. */
  65064. getIsInstanced(): boolean;
  65065. /**
  65066. * Returns the instancing divisor, zero for non-instanced (integer).
  65067. * @returns a number
  65068. */
  65069. getInstanceDivisor(): number;
  65070. /**
  65071. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65072. * @param data defines the data to store
  65073. */
  65074. create(data?: DataArray): void;
  65075. /**
  65076. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  65077. * This function will create a new buffer if the current one is not updatable
  65078. * @param data defines the data to store
  65079. */
  65080. update(data: DataArray): void;
  65081. /**
  65082. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  65083. * Returns the directly updated WebGLBuffer.
  65084. * @param data the new data
  65085. * @param offset the new offset
  65086. * @param useBytes set to true if the offset is in bytes
  65087. */
  65088. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  65089. /**
  65090. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  65091. */
  65092. dispose(): void;
  65093. /**
  65094. * Enumerates each value of this vertex buffer as numbers.
  65095. * @param count the number of values to enumerate
  65096. * @param callback the callback function called for each value
  65097. */
  65098. forEach(count: number, callback: (value: number, index: number) => void): void;
  65099. /**
  65100. * Positions
  65101. */
  65102. static readonly PositionKind: string;
  65103. /**
  65104. * Normals
  65105. */
  65106. static readonly NormalKind: string;
  65107. /**
  65108. * Tangents
  65109. */
  65110. static readonly TangentKind: string;
  65111. /**
  65112. * Texture coordinates
  65113. */
  65114. static readonly UVKind: string;
  65115. /**
  65116. * Texture coordinates 2
  65117. */
  65118. static readonly UV2Kind: string;
  65119. /**
  65120. * Texture coordinates 3
  65121. */
  65122. static readonly UV3Kind: string;
  65123. /**
  65124. * Texture coordinates 4
  65125. */
  65126. static readonly UV4Kind: string;
  65127. /**
  65128. * Texture coordinates 5
  65129. */
  65130. static readonly UV5Kind: string;
  65131. /**
  65132. * Texture coordinates 6
  65133. */
  65134. static readonly UV6Kind: string;
  65135. /**
  65136. * Colors
  65137. */
  65138. static readonly ColorKind: string;
  65139. /**
  65140. * Matrix indices (for bones)
  65141. */
  65142. static readonly MatricesIndicesKind: string;
  65143. /**
  65144. * Matrix weights (for bones)
  65145. */
  65146. static readonly MatricesWeightsKind: string;
  65147. /**
  65148. * Additional matrix indices (for bones)
  65149. */
  65150. static readonly MatricesIndicesExtraKind: string;
  65151. /**
  65152. * Additional matrix weights (for bones)
  65153. */
  65154. static readonly MatricesWeightsExtraKind: string;
  65155. /**
  65156. * Deduces the stride given a kind.
  65157. * @param kind The kind string to deduce
  65158. * @returns The deduced stride
  65159. */
  65160. static DeduceStride(kind: string): number;
  65161. /**
  65162. * Gets the byte length of the given type.
  65163. * @param type the type
  65164. * @returns the number of bytes
  65165. */
  65166. static GetTypeByteLength(type: number): number;
  65167. /**
  65168. * Enumerates each value of the given parameters as numbers.
  65169. * @param data the data to enumerate
  65170. * @param byteOffset the byte offset of the data
  65171. * @param byteStride the byte stride of the data
  65172. * @param componentCount the number of components per element
  65173. * @param componentType the type of the component
  65174. * @param count the total number of components
  65175. * @param normalized whether the data is normalized
  65176. * @param callback the callback function called for each value
  65177. */
  65178. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  65179. private static _GetFloatValue;
  65180. }
  65181. }
  65182. declare module BABYLON {
  65183. /**
  65184. * Class representing spherical polynomial coefficients to the 3rd degree
  65185. */
  65186. export class SphericalPolynomial {
  65187. /**
  65188. * The x coefficients of the spherical polynomial
  65189. */
  65190. x: Vector3;
  65191. /**
  65192. * The y coefficients of the spherical polynomial
  65193. */
  65194. y: Vector3;
  65195. /**
  65196. * The z coefficients of the spherical polynomial
  65197. */
  65198. z: Vector3;
  65199. /**
  65200. * The xx coefficients of the spherical polynomial
  65201. */
  65202. xx: Vector3;
  65203. /**
  65204. * The yy coefficients of the spherical polynomial
  65205. */
  65206. yy: Vector3;
  65207. /**
  65208. * The zz coefficients of the spherical polynomial
  65209. */
  65210. zz: Vector3;
  65211. /**
  65212. * The xy coefficients of the spherical polynomial
  65213. */
  65214. xy: Vector3;
  65215. /**
  65216. * The yz coefficients of the spherical polynomial
  65217. */
  65218. yz: Vector3;
  65219. /**
  65220. * The zx coefficients of the spherical polynomial
  65221. */
  65222. zx: Vector3;
  65223. /**
  65224. * Adds an ambient color to the spherical polynomial
  65225. * @param color the color to add
  65226. */
  65227. addAmbient(color: Color3): void;
  65228. /**
  65229. * Scales the spherical polynomial by the given amount
  65230. * @param scale the amount to scale
  65231. */
  65232. scale(scale: number): void;
  65233. /**
  65234. * Gets the spherical polynomial from harmonics
  65235. * @param harmonics the spherical harmonics
  65236. * @returns the spherical polynomial
  65237. */
  65238. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  65239. /**
  65240. * Constructs a spherical polynomial from an array.
  65241. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  65242. * @returns the spherical polynomial
  65243. */
  65244. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  65245. }
  65246. /**
  65247. * Class representing spherical harmonics coefficients to the 3rd degree
  65248. */
  65249. export class SphericalHarmonics {
  65250. /**
  65251. * The l0,0 coefficients of the spherical harmonics
  65252. */
  65253. l00: Vector3;
  65254. /**
  65255. * The l1,-1 coefficients of the spherical harmonics
  65256. */
  65257. l1_1: Vector3;
  65258. /**
  65259. * The l1,0 coefficients of the spherical harmonics
  65260. */
  65261. l10: Vector3;
  65262. /**
  65263. * The l1,1 coefficients of the spherical harmonics
  65264. */
  65265. l11: Vector3;
  65266. /**
  65267. * The l2,-2 coefficients of the spherical harmonics
  65268. */
  65269. l2_2: Vector3;
  65270. /**
  65271. * The l2,-1 coefficients of the spherical harmonics
  65272. */
  65273. l2_1: Vector3;
  65274. /**
  65275. * The l2,0 coefficients of the spherical harmonics
  65276. */
  65277. l20: Vector3;
  65278. /**
  65279. * The l2,1 coefficients of the spherical harmonics
  65280. */
  65281. l21: Vector3;
  65282. /**
  65283. * The l2,2 coefficients of the spherical harmonics
  65284. */
  65285. lL22: Vector3;
  65286. /**
  65287. * Adds a light to the spherical harmonics
  65288. * @param direction the direction of the light
  65289. * @param color the color of the light
  65290. * @param deltaSolidAngle the delta solid angle of the light
  65291. */
  65292. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  65293. /**
  65294. * Scales the spherical harmonics by the given amount
  65295. * @param scale the amount to scale
  65296. */
  65297. scale(scale: number): void;
  65298. /**
  65299. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  65300. *
  65301. * ```
  65302. * E_lm = A_l * L_lm
  65303. * ```
  65304. *
  65305. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  65306. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  65307. * the scaling factors are given in equation 9.
  65308. */
  65309. convertIncidentRadianceToIrradiance(): void;
  65310. /**
  65311. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  65312. *
  65313. * ```
  65314. * L = (1/pi) * E * rho
  65315. * ```
  65316. *
  65317. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  65318. */
  65319. convertIrradianceToLambertianRadiance(): void;
  65320. /**
  65321. * Gets the spherical harmonics from polynomial
  65322. * @param polynomial the spherical polynomial
  65323. * @returns the spherical harmonics
  65324. */
  65325. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  65326. /**
  65327. * Constructs a spherical harmonics from an array.
  65328. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  65329. * @returns the spherical harmonics
  65330. */
  65331. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  65332. }
  65333. }
  65334. declare module BABYLON {
  65335. /**
  65336. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  65337. */
  65338. export interface CubeMapInfo {
  65339. /**
  65340. * The pixel array for the front face.
  65341. * This is stored in format, left to right, up to down format.
  65342. */
  65343. front: Nullable<ArrayBufferView>;
  65344. /**
  65345. * The pixel array for the back face.
  65346. * This is stored in format, left to right, up to down format.
  65347. */
  65348. back: Nullable<ArrayBufferView>;
  65349. /**
  65350. * The pixel array for the left face.
  65351. * This is stored in format, left to right, up to down format.
  65352. */
  65353. left: Nullable<ArrayBufferView>;
  65354. /**
  65355. * The pixel array for the right face.
  65356. * This is stored in format, left to right, up to down format.
  65357. */
  65358. right: Nullable<ArrayBufferView>;
  65359. /**
  65360. * The pixel array for the up face.
  65361. * This is stored in format, left to right, up to down format.
  65362. */
  65363. up: Nullable<ArrayBufferView>;
  65364. /**
  65365. * The pixel array for the down face.
  65366. * This is stored in format, left to right, up to down format.
  65367. */
  65368. down: Nullable<ArrayBufferView>;
  65369. /**
  65370. * The size of the cubemap stored.
  65371. *
  65372. * Each faces will be size * size pixels.
  65373. */
  65374. size: number;
  65375. /**
  65376. * The format of the texture.
  65377. *
  65378. * RGBA, RGB.
  65379. */
  65380. format: number;
  65381. /**
  65382. * The type of the texture data.
  65383. *
  65384. * UNSIGNED_INT, FLOAT.
  65385. */
  65386. type: number;
  65387. /**
  65388. * Specifies whether the texture is in gamma space.
  65389. */
  65390. gammaSpace: boolean;
  65391. }
  65392. /**
  65393. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  65394. */
  65395. export class PanoramaToCubeMapTools {
  65396. private static FACE_FRONT;
  65397. private static FACE_BACK;
  65398. private static FACE_RIGHT;
  65399. private static FACE_LEFT;
  65400. private static FACE_DOWN;
  65401. private static FACE_UP;
  65402. /**
  65403. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  65404. *
  65405. * @param float32Array The source data.
  65406. * @param inputWidth The width of the input panorama.
  65407. * @param inputHeight The height of the input panorama.
  65408. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  65409. * @return The cubemap data
  65410. */
  65411. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  65412. private static CreateCubemapTexture;
  65413. private static CalcProjectionSpherical;
  65414. }
  65415. }
  65416. declare module BABYLON {
  65417. /**
  65418. * Helper class dealing with the extraction of spherical polynomial dataArray
  65419. * from a cube map.
  65420. */
  65421. export class CubeMapToSphericalPolynomialTools {
  65422. private static FileFaces;
  65423. /**
  65424. * Converts a texture to the according Spherical Polynomial data.
  65425. * This extracts the first 3 orders only as they are the only one used in the lighting.
  65426. *
  65427. * @param texture The texture to extract the information from.
  65428. * @return The Spherical Polynomial data.
  65429. */
  65430. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  65431. /**
  65432. * Converts a cubemap to the according Spherical Polynomial data.
  65433. * This extracts the first 3 orders only as they are the only one used in the lighting.
  65434. *
  65435. * @param cubeInfo The Cube map to extract the information from.
  65436. * @return The Spherical Polynomial data.
  65437. */
  65438. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  65439. }
  65440. }
  65441. declare module BABYLON {
  65442. /**
  65443. * The engine store class is responsible to hold all the instances of Engine and Scene created
  65444. * during the life time of the application.
  65445. */
  65446. export class EngineStore {
  65447. /** Gets the list of created engines */
  65448. static Instances: Engine[];
  65449. /**
  65450. * Gets the latest created engine
  65451. */
  65452. static readonly LastCreatedEngine: Nullable<Engine>;
  65453. /**
  65454. * Gets the latest created scene
  65455. */
  65456. static readonly LastCreatedScene: Nullable<Scene>;
  65457. }
  65458. }
  65459. declare module BABYLON {
  65460. /**
  65461. * Define options used to create a render target texture
  65462. */
  65463. export class RenderTargetCreationOptions {
  65464. /**
  65465. * Specifies is mipmaps must be generated
  65466. */
  65467. generateMipMaps?: boolean;
  65468. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  65469. generateDepthBuffer?: boolean;
  65470. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  65471. generateStencilBuffer?: boolean;
  65472. /** Defines texture type (int by default) */
  65473. type?: number;
  65474. /** Defines sampling mode (trilinear by default) */
  65475. samplingMode?: number;
  65476. /** Defines format (RGBA by default) */
  65477. format?: number;
  65478. }
  65479. }
  65480. declare module BABYLON {
  65481. /**
  65482. * @hidden
  65483. **/
  65484. export class _AlphaState {
  65485. private _isAlphaBlendDirty;
  65486. private _isBlendFunctionParametersDirty;
  65487. private _isBlendEquationParametersDirty;
  65488. private _isBlendConstantsDirty;
  65489. private _alphaBlend;
  65490. private _blendFunctionParameters;
  65491. private _blendEquationParameters;
  65492. private _blendConstants;
  65493. /**
  65494. * Initializes the state.
  65495. */
  65496. constructor();
  65497. readonly isDirty: boolean;
  65498. alphaBlend: boolean;
  65499. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  65500. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  65501. setAlphaEquationParameters(rgb: number, alpha: number): void;
  65502. reset(): void;
  65503. apply(gl: WebGLRenderingContext): void;
  65504. }
  65505. }
  65506. declare module BABYLON {
  65507. /**
  65508. * @hidden
  65509. **/
  65510. export class _DepthCullingState {
  65511. private _isDepthTestDirty;
  65512. private _isDepthMaskDirty;
  65513. private _isDepthFuncDirty;
  65514. private _isCullFaceDirty;
  65515. private _isCullDirty;
  65516. private _isZOffsetDirty;
  65517. private _isFrontFaceDirty;
  65518. private _depthTest;
  65519. private _depthMask;
  65520. private _depthFunc;
  65521. private _cull;
  65522. private _cullFace;
  65523. private _zOffset;
  65524. private _frontFace;
  65525. /**
  65526. * Initializes the state.
  65527. */
  65528. constructor();
  65529. readonly isDirty: boolean;
  65530. zOffset: number;
  65531. cullFace: Nullable<number>;
  65532. cull: Nullable<boolean>;
  65533. depthFunc: Nullable<number>;
  65534. depthMask: boolean;
  65535. depthTest: boolean;
  65536. frontFace: Nullable<number>;
  65537. reset(): void;
  65538. apply(gl: WebGLRenderingContext): void;
  65539. }
  65540. }
  65541. declare module BABYLON {
  65542. /**
  65543. * @hidden
  65544. **/
  65545. export class _StencilState {
  65546. /** 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 */
  65547. static readonly ALWAYS: number;
  65548. /** Passed to stencilOperation to specify that stencil value must be kept */
  65549. static readonly KEEP: number;
  65550. /** Passed to stencilOperation to specify that stencil value must be replaced */
  65551. static readonly REPLACE: number;
  65552. private _isStencilTestDirty;
  65553. private _isStencilMaskDirty;
  65554. private _isStencilFuncDirty;
  65555. private _isStencilOpDirty;
  65556. private _stencilTest;
  65557. private _stencilMask;
  65558. private _stencilFunc;
  65559. private _stencilFuncRef;
  65560. private _stencilFuncMask;
  65561. private _stencilOpStencilFail;
  65562. private _stencilOpDepthFail;
  65563. private _stencilOpStencilDepthPass;
  65564. readonly isDirty: boolean;
  65565. stencilFunc: number;
  65566. stencilFuncRef: number;
  65567. stencilFuncMask: number;
  65568. stencilOpStencilFail: number;
  65569. stencilOpDepthFail: number;
  65570. stencilOpStencilDepthPass: number;
  65571. stencilMask: number;
  65572. stencilTest: boolean;
  65573. constructor();
  65574. reset(): void;
  65575. apply(gl: WebGLRenderingContext): void;
  65576. }
  65577. }
  65578. declare module BABYLON {
  65579. /**
  65580. * @hidden
  65581. **/
  65582. export class _TimeToken {
  65583. _startTimeQuery: Nullable<WebGLQuery>;
  65584. _endTimeQuery: Nullable<WebGLQuery>;
  65585. _timeElapsedQuery: Nullable<WebGLQuery>;
  65586. _timeElapsedQueryEnded: boolean;
  65587. }
  65588. }
  65589. declare module BABYLON {
  65590. /**
  65591. * Class used to store data associated with WebGL texture data for the engine
  65592. * This class should not be used directly
  65593. */
  65594. export class InternalTexture {
  65595. /** hidden */
  65596. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  65597. /**
  65598. * The source of the texture data is unknown
  65599. */
  65600. static DATASOURCE_UNKNOWN: number;
  65601. /**
  65602. * Texture data comes from an URL
  65603. */
  65604. static DATASOURCE_URL: number;
  65605. /**
  65606. * Texture data is only used for temporary storage
  65607. */
  65608. static DATASOURCE_TEMP: number;
  65609. /**
  65610. * Texture data comes from raw data (ArrayBuffer)
  65611. */
  65612. static DATASOURCE_RAW: number;
  65613. /**
  65614. * Texture content is dynamic (video or dynamic texture)
  65615. */
  65616. static DATASOURCE_DYNAMIC: number;
  65617. /**
  65618. * Texture content is generated by rendering to it
  65619. */
  65620. static DATASOURCE_RENDERTARGET: number;
  65621. /**
  65622. * Texture content is part of a multi render target process
  65623. */
  65624. static DATASOURCE_MULTIRENDERTARGET: number;
  65625. /**
  65626. * Texture data comes from a cube data file
  65627. */
  65628. static DATASOURCE_CUBE: number;
  65629. /**
  65630. * Texture data comes from a raw cube data
  65631. */
  65632. static DATASOURCE_CUBERAW: number;
  65633. /**
  65634. * Texture data come from a prefiltered cube data file
  65635. */
  65636. static DATASOURCE_CUBEPREFILTERED: number;
  65637. /**
  65638. * Texture content is raw 3D data
  65639. */
  65640. static DATASOURCE_RAW3D: number;
  65641. /**
  65642. * Texture content is a depth texture
  65643. */
  65644. static DATASOURCE_DEPTHTEXTURE: number;
  65645. /**
  65646. * Texture data comes from a raw cube data encoded with RGBD
  65647. */
  65648. static DATASOURCE_CUBERAW_RGBD: number;
  65649. /**
  65650. * Defines if the texture is ready
  65651. */
  65652. isReady: boolean;
  65653. /**
  65654. * Defines if the texture is a cube texture
  65655. */
  65656. isCube: boolean;
  65657. /**
  65658. * Defines if the texture contains 3D data
  65659. */
  65660. is3D: boolean;
  65661. /**
  65662. * Defines if the texture contains multiview data
  65663. */
  65664. isMultiview: boolean;
  65665. /**
  65666. * Gets the URL used to load this texture
  65667. */
  65668. url: string;
  65669. /**
  65670. * Gets the sampling mode of the texture
  65671. */
  65672. samplingMode: number;
  65673. /**
  65674. * Gets a boolean indicating if the texture needs mipmaps generation
  65675. */
  65676. generateMipMaps: boolean;
  65677. /**
  65678. * Gets the number of samples used by the texture (WebGL2+ only)
  65679. */
  65680. samples: number;
  65681. /**
  65682. * Gets the type of the texture (int, float...)
  65683. */
  65684. type: number;
  65685. /**
  65686. * Gets the format of the texture (RGB, RGBA...)
  65687. */
  65688. format: number;
  65689. /**
  65690. * Observable called when the texture is loaded
  65691. */
  65692. onLoadedObservable: Observable<InternalTexture>;
  65693. /**
  65694. * Gets the width of the texture
  65695. */
  65696. width: number;
  65697. /**
  65698. * Gets the height of the texture
  65699. */
  65700. height: number;
  65701. /**
  65702. * Gets the depth of the texture
  65703. */
  65704. depth: number;
  65705. /**
  65706. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  65707. */
  65708. baseWidth: number;
  65709. /**
  65710. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  65711. */
  65712. baseHeight: number;
  65713. /**
  65714. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  65715. */
  65716. baseDepth: number;
  65717. /**
  65718. * Gets a boolean indicating if the texture is inverted on Y axis
  65719. */
  65720. invertY: boolean;
  65721. /** @hidden */
  65722. _invertVScale: boolean;
  65723. /** @hidden */
  65724. _associatedChannel: number;
  65725. /** @hidden */
  65726. _dataSource: number;
  65727. /** @hidden */
  65728. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  65729. /** @hidden */
  65730. _bufferView: Nullable<ArrayBufferView>;
  65731. /** @hidden */
  65732. _bufferViewArray: Nullable<ArrayBufferView[]>;
  65733. /** @hidden */
  65734. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  65735. /** @hidden */
  65736. _size: number;
  65737. /** @hidden */
  65738. _extension: string;
  65739. /** @hidden */
  65740. _files: Nullable<string[]>;
  65741. /** @hidden */
  65742. _workingCanvas: HTMLCanvasElement;
  65743. /** @hidden */
  65744. _workingContext: CanvasRenderingContext2D;
  65745. /** @hidden */
  65746. _framebuffer: Nullable<WebGLFramebuffer>;
  65747. /** @hidden */
  65748. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  65749. /** @hidden */
  65750. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  65751. /** @hidden */
  65752. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  65753. /** @hidden */
  65754. _attachments: Nullable<number[]>;
  65755. /** @hidden */
  65756. _cachedCoordinatesMode: Nullable<number>;
  65757. /** @hidden */
  65758. _cachedWrapU: Nullable<number>;
  65759. /** @hidden */
  65760. _cachedWrapV: Nullable<number>;
  65761. /** @hidden */
  65762. _cachedWrapR: Nullable<number>;
  65763. /** @hidden */
  65764. _cachedAnisotropicFilteringLevel: Nullable<number>;
  65765. /** @hidden */
  65766. _isDisabled: boolean;
  65767. /** @hidden */
  65768. _compression: Nullable<string>;
  65769. /** @hidden */
  65770. _generateStencilBuffer: boolean;
  65771. /** @hidden */
  65772. _generateDepthBuffer: boolean;
  65773. /** @hidden */
  65774. _comparisonFunction: number;
  65775. /** @hidden */
  65776. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  65777. /** @hidden */
  65778. _lodGenerationScale: number;
  65779. /** @hidden */
  65780. _lodGenerationOffset: number;
  65781. /** @hidden */
  65782. _colorTextureArray: Nullable<WebGLTexture>;
  65783. /** @hidden */
  65784. _depthStencilTextureArray: Nullable<WebGLTexture>;
  65785. /** @hidden */
  65786. _lodTextureHigh: BaseTexture;
  65787. /** @hidden */
  65788. _lodTextureMid: BaseTexture;
  65789. /** @hidden */
  65790. _lodTextureLow: BaseTexture;
  65791. /** @hidden */
  65792. _isRGBD: boolean;
  65793. /** @hidden */
  65794. _webGLTexture: Nullable<WebGLTexture>;
  65795. /** @hidden */
  65796. _references: number;
  65797. private _engine;
  65798. /**
  65799. * Gets the Engine the texture belongs to.
  65800. * @returns The babylon engine
  65801. */
  65802. getEngine(): Engine;
  65803. /**
  65804. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  65805. */
  65806. readonly dataSource: number;
  65807. /**
  65808. * Creates a new InternalTexture
  65809. * @param engine defines the engine to use
  65810. * @param dataSource defines the type of data that will be used
  65811. * @param delayAllocation if the texture allocation should be delayed (default: false)
  65812. */
  65813. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  65814. /**
  65815. * Increments the number of references (ie. the number of Texture that point to it)
  65816. */
  65817. incrementReferences(): void;
  65818. /**
  65819. * Change the size of the texture (not the size of the content)
  65820. * @param width defines the new width
  65821. * @param height defines the new height
  65822. * @param depth defines the new depth (1 by default)
  65823. */
  65824. updateSize(width: int, height: int, depth?: int): void;
  65825. /** @hidden */
  65826. _rebuild(): void;
  65827. /** @hidden */
  65828. _swapAndDie(target: InternalTexture): void;
  65829. /**
  65830. * Dispose the current allocated resources
  65831. */
  65832. dispose(): void;
  65833. }
  65834. }
  65835. declare module BABYLON {
  65836. /**
  65837. * This represents the main contract an easing function should follow.
  65838. * Easing functions are used throughout the animation system.
  65839. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65840. */
  65841. export interface IEasingFunction {
  65842. /**
  65843. * Given an input gradient between 0 and 1, this returns the corrseponding value
  65844. * of the easing function.
  65845. * The link below provides some of the most common examples of easing functions.
  65846. * @see https://easings.net/
  65847. * @param gradient Defines the value between 0 and 1 we want the easing value for
  65848. * @returns the corresponding value on the curve defined by the easing function
  65849. */
  65850. ease(gradient: number): number;
  65851. }
  65852. /**
  65853. * Base class used for every default easing function.
  65854. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65855. */
  65856. export class EasingFunction implements IEasingFunction {
  65857. /**
  65858. * Interpolation follows the mathematical formula associated with the easing function.
  65859. */
  65860. static readonly EASINGMODE_EASEIN: number;
  65861. /**
  65862. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  65863. */
  65864. static readonly EASINGMODE_EASEOUT: number;
  65865. /**
  65866. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  65867. */
  65868. static readonly EASINGMODE_EASEINOUT: number;
  65869. private _easingMode;
  65870. /**
  65871. * Sets the easing mode of the current function.
  65872. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  65873. */
  65874. setEasingMode(easingMode: number): void;
  65875. /**
  65876. * Gets the current easing mode.
  65877. * @returns the easing mode
  65878. */
  65879. getEasingMode(): number;
  65880. /**
  65881. * @hidden
  65882. */
  65883. easeInCore(gradient: number): number;
  65884. /**
  65885. * Given an input gradient between 0 and 1, this returns the corrseponding value
  65886. * of the easing function.
  65887. * @param gradient Defines the value between 0 and 1 we want the easing value for
  65888. * @returns the corresponding value on the curve defined by the easing function
  65889. */
  65890. ease(gradient: number): number;
  65891. }
  65892. /**
  65893. * Easing function with a circle shape (see link below).
  65894. * @see https://easings.net/#easeInCirc
  65895. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65896. */
  65897. export class CircleEase extends EasingFunction implements IEasingFunction {
  65898. /** @hidden */
  65899. easeInCore(gradient: number): number;
  65900. }
  65901. /**
  65902. * Easing function with a ease back shape (see link below).
  65903. * @see https://easings.net/#easeInBack
  65904. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65905. */
  65906. export class BackEase extends EasingFunction implements IEasingFunction {
  65907. /** Defines the amplitude of the function */
  65908. amplitude: number;
  65909. /**
  65910. * Instantiates a back ease easing
  65911. * @see https://easings.net/#easeInBack
  65912. * @param amplitude Defines the amplitude of the function
  65913. */
  65914. constructor(
  65915. /** Defines the amplitude of the function */
  65916. amplitude?: number);
  65917. /** @hidden */
  65918. easeInCore(gradient: number): number;
  65919. }
  65920. /**
  65921. * Easing function with a bouncing shape (see link below).
  65922. * @see https://easings.net/#easeInBounce
  65923. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65924. */
  65925. export class BounceEase extends EasingFunction implements IEasingFunction {
  65926. /** Defines the number of bounces */
  65927. bounces: number;
  65928. /** Defines the amplitude of the bounce */
  65929. bounciness: number;
  65930. /**
  65931. * Instantiates a bounce easing
  65932. * @see https://easings.net/#easeInBounce
  65933. * @param bounces Defines the number of bounces
  65934. * @param bounciness Defines the amplitude of the bounce
  65935. */
  65936. constructor(
  65937. /** Defines the number of bounces */
  65938. bounces?: number,
  65939. /** Defines the amplitude of the bounce */
  65940. bounciness?: number);
  65941. /** @hidden */
  65942. easeInCore(gradient: number): number;
  65943. }
  65944. /**
  65945. * Easing function with a power of 3 shape (see link below).
  65946. * @see https://easings.net/#easeInCubic
  65947. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65948. */
  65949. export class CubicEase extends EasingFunction implements IEasingFunction {
  65950. /** @hidden */
  65951. easeInCore(gradient: number): number;
  65952. }
  65953. /**
  65954. * Easing function with an elastic shape (see link below).
  65955. * @see https://easings.net/#easeInElastic
  65956. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65957. */
  65958. export class ElasticEase extends EasingFunction implements IEasingFunction {
  65959. /** Defines the number of oscillations*/
  65960. oscillations: number;
  65961. /** Defines the amplitude of the oscillations*/
  65962. springiness: number;
  65963. /**
  65964. * Instantiates an elastic easing function
  65965. * @see https://easings.net/#easeInElastic
  65966. * @param oscillations Defines the number of oscillations
  65967. * @param springiness Defines the amplitude of the oscillations
  65968. */
  65969. constructor(
  65970. /** Defines the number of oscillations*/
  65971. oscillations?: number,
  65972. /** Defines the amplitude of the oscillations*/
  65973. springiness?: number);
  65974. /** @hidden */
  65975. easeInCore(gradient: number): number;
  65976. }
  65977. /**
  65978. * Easing function with an exponential shape (see link below).
  65979. * @see https://easings.net/#easeInExpo
  65980. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65981. */
  65982. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  65983. /** Defines the exponent of the function */
  65984. exponent: number;
  65985. /**
  65986. * Instantiates an exponential easing function
  65987. * @see https://easings.net/#easeInExpo
  65988. * @param exponent Defines the exponent of the function
  65989. */
  65990. constructor(
  65991. /** Defines the exponent of the function */
  65992. exponent?: number);
  65993. /** @hidden */
  65994. easeInCore(gradient: number): number;
  65995. }
  65996. /**
  65997. * Easing function with a power shape (see link below).
  65998. * @see https://easings.net/#easeInQuad
  65999. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66000. */
  66001. export class PowerEase extends EasingFunction implements IEasingFunction {
  66002. /** Defines the power of the function */
  66003. power: number;
  66004. /**
  66005. * Instantiates an power base easing function
  66006. * @see https://easings.net/#easeInQuad
  66007. * @param power Defines the power of the function
  66008. */
  66009. constructor(
  66010. /** Defines the power of the function */
  66011. power?: number);
  66012. /** @hidden */
  66013. easeInCore(gradient: number): number;
  66014. }
  66015. /**
  66016. * Easing function with a power of 2 shape (see link below).
  66017. * @see https://easings.net/#easeInQuad
  66018. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66019. */
  66020. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  66021. /** @hidden */
  66022. easeInCore(gradient: number): number;
  66023. }
  66024. /**
  66025. * Easing function with a power of 4 shape (see link below).
  66026. * @see https://easings.net/#easeInQuart
  66027. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66028. */
  66029. export class QuarticEase extends EasingFunction implements IEasingFunction {
  66030. /** @hidden */
  66031. easeInCore(gradient: number): number;
  66032. }
  66033. /**
  66034. * Easing function with a power of 5 shape (see link below).
  66035. * @see https://easings.net/#easeInQuint
  66036. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66037. */
  66038. export class QuinticEase extends EasingFunction implements IEasingFunction {
  66039. /** @hidden */
  66040. easeInCore(gradient: number): number;
  66041. }
  66042. /**
  66043. * Easing function with a sin shape (see link below).
  66044. * @see https://easings.net/#easeInSine
  66045. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66046. */
  66047. export class SineEase extends EasingFunction implements IEasingFunction {
  66048. /** @hidden */
  66049. easeInCore(gradient: number): number;
  66050. }
  66051. /**
  66052. * Easing function with a bezier shape (see link below).
  66053. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  66054. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66055. */
  66056. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  66057. /** Defines the x component of the start tangent in the bezier curve */
  66058. x1: number;
  66059. /** Defines the y component of the start tangent in the bezier curve */
  66060. y1: number;
  66061. /** Defines the x component of the end tangent in the bezier curve */
  66062. x2: number;
  66063. /** Defines the y component of the end tangent in the bezier curve */
  66064. y2: number;
  66065. /**
  66066. * Instantiates a bezier function
  66067. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  66068. * @param x1 Defines the x component of the start tangent in the bezier curve
  66069. * @param y1 Defines the y component of the start tangent in the bezier curve
  66070. * @param x2 Defines the x component of the end tangent in the bezier curve
  66071. * @param y2 Defines the y component of the end tangent in the bezier curve
  66072. */
  66073. constructor(
  66074. /** Defines the x component of the start tangent in the bezier curve */
  66075. x1?: number,
  66076. /** Defines the y component of the start tangent in the bezier curve */
  66077. y1?: number,
  66078. /** Defines the x component of the end tangent in the bezier curve */
  66079. x2?: number,
  66080. /** Defines the y component of the end tangent in the bezier curve */
  66081. y2?: number);
  66082. /** @hidden */
  66083. easeInCore(gradient: number): number;
  66084. }
  66085. }
  66086. declare module BABYLON {
  66087. /**
  66088. * Defines an interface which represents an animation key frame
  66089. */
  66090. export interface IAnimationKey {
  66091. /**
  66092. * Frame of the key frame
  66093. */
  66094. frame: number;
  66095. /**
  66096. * Value at the specifies key frame
  66097. */
  66098. value: any;
  66099. /**
  66100. * The input tangent for the cubic hermite spline
  66101. */
  66102. inTangent?: any;
  66103. /**
  66104. * The output tangent for the cubic hermite spline
  66105. */
  66106. outTangent?: any;
  66107. /**
  66108. * The animation interpolation type
  66109. */
  66110. interpolation?: AnimationKeyInterpolation;
  66111. }
  66112. /**
  66113. * Enum for the animation key frame interpolation type
  66114. */
  66115. export enum AnimationKeyInterpolation {
  66116. /**
  66117. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  66118. */
  66119. STEP = 1
  66120. }
  66121. }
  66122. declare module BABYLON {
  66123. /**
  66124. * Represents the range of an animation
  66125. */
  66126. export class AnimationRange {
  66127. /**The name of the animation range**/
  66128. name: string;
  66129. /**The starting frame of the animation */
  66130. from: number;
  66131. /**The ending frame of the animation*/
  66132. to: number;
  66133. /**
  66134. * Initializes the range of an animation
  66135. * @param name The name of the animation range
  66136. * @param from The starting frame of the animation
  66137. * @param to The ending frame of the animation
  66138. */
  66139. constructor(
  66140. /**The name of the animation range**/
  66141. name: string,
  66142. /**The starting frame of the animation */
  66143. from: number,
  66144. /**The ending frame of the animation*/
  66145. to: number);
  66146. /**
  66147. * Makes a copy of the animation range
  66148. * @returns A copy of the animation range
  66149. */
  66150. clone(): AnimationRange;
  66151. }
  66152. }
  66153. declare module BABYLON {
  66154. /**
  66155. * Composed of a frame, and an action function
  66156. */
  66157. export class AnimationEvent {
  66158. /** The frame for which the event is triggered **/
  66159. frame: number;
  66160. /** The event to perform when triggered **/
  66161. action: (currentFrame: number) => void;
  66162. /** Specifies if the event should be triggered only once**/
  66163. onlyOnce?: boolean | undefined;
  66164. /**
  66165. * Specifies if the animation event is done
  66166. */
  66167. isDone: boolean;
  66168. /**
  66169. * Initializes the animation event
  66170. * @param frame The frame for which the event is triggered
  66171. * @param action The event to perform when triggered
  66172. * @param onlyOnce Specifies if the event should be triggered only once
  66173. */
  66174. constructor(
  66175. /** The frame for which the event is triggered **/
  66176. frame: number,
  66177. /** The event to perform when triggered **/
  66178. action: (currentFrame: number) => void,
  66179. /** Specifies if the event should be triggered only once**/
  66180. onlyOnce?: boolean | undefined);
  66181. /** @hidden */
  66182. _clone(): AnimationEvent;
  66183. }
  66184. }
  66185. declare module BABYLON {
  66186. /**
  66187. * Interface used to define a behavior
  66188. */
  66189. export interface Behavior<T> {
  66190. /** gets or sets behavior's name */
  66191. name: string;
  66192. /**
  66193. * Function called when the behavior needs to be initialized (after attaching it to a target)
  66194. */
  66195. init(): void;
  66196. /**
  66197. * Called when the behavior is attached to a target
  66198. * @param target defines the target where the behavior is attached to
  66199. */
  66200. attach(target: T): void;
  66201. /**
  66202. * Called when the behavior is detached from its target
  66203. */
  66204. detach(): void;
  66205. }
  66206. /**
  66207. * Interface implemented by classes supporting behaviors
  66208. */
  66209. export interface IBehaviorAware<T> {
  66210. /**
  66211. * Attach a behavior
  66212. * @param behavior defines the behavior to attach
  66213. * @returns the current host
  66214. */
  66215. addBehavior(behavior: Behavior<T>): T;
  66216. /**
  66217. * Remove a behavior from the current object
  66218. * @param behavior defines the behavior to detach
  66219. * @returns the current host
  66220. */
  66221. removeBehavior(behavior: Behavior<T>): T;
  66222. /**
  66223. * Gets a behavior using its name to search
  66224. * @param name defines the name to search
  66225. * @returns the behavior or null if not found
  66226. */
  66227. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  66228. }
  66229. }
  66230. declare module BABYLON {
  66231. /**
  66232. * @hidden
  66233. */
  66234. export class IntersectionInfo {
  66235. bu: Nullable<number>;
  66236. bv: Nullable<number>;
  66237. distance: number;
  66238. faceId: number;
  66239. subMeshId: number;
  66240. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  66241. }
  66242. }
  66243. declare module BABYLON {
  66244. /**
  66245. * Class used to store bounding sphere information
  66246. */
  66247. export class BoundingSphere {
  66248. /**
  66249. * Gets the center of the bounding sphere in local space
  66250. */
  66251. readonly center: Vector3;
  66252. /**
  66253. * Radius of the bounding sphere in local space
  66254. */
  66255. radius: number;
  66256. /**
  66257. * Gets the center of the bounding sphere in world space
  66258. */
  66259. readonly centerWorld: Vector3;
  66260. /**
  66261. * Radius of the bounding sphere in world space
  66262. */
  66263. radiusWorld: number;
  66264. /**
  66265. * Gets the minimum vector in local space
  66266. */
  66267. readonly minimum: Vector3;
  66268. /**
  66269. * Gets the maximum vector in local space
  66270. */
  66271. readonly maximum: Vector3;
  66272. private _worldMatrix;
  66273. private static readonly TmpVector3;
  66274. /**
  66275. * Creates a new bounding sphere
  66276. * @param min defines the minimum vector (in local space)
  66277. * @param max defines the maximum vector (in local space)
  66278. * @param worldMatrix defines the new world matrix
  66279. */
  66280. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66281. /**
  66282. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  66283. * @param min defines the new minimum vector (in local space)
  66284. * @param max defines the new maximum vector (in local space)
  66285. * @param worldMatrix defines the new world matrix
  66286. */
  66287. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66288. /**
  66289. * Scale the current bounding sphere by applying a scale factor
  66290. * @param factor defines the scale factor to apply
  66291. * @returns the current bounding box
  66292. */
  66293. scale(factor: number): BoundingSphere;
  66294. /**
  66295. * Gets the world matrix of the bounding box
  66296. * @returns a matrix
  66297. */
  66298. getWorldMatrix(): DeepImmutable<Matrix>;
  66299. /** @hidden */
  66300. _update(worldMatrix: DeepImmutable<Matrix>): void;
  66301. /**
  66302. * Tests if the bounding sphere is intersecting the frustum planes
  66303. * @param frustumPlanes defines the frustum planes to test
  66304. * @returns true if there is an intersection
  66305. */
  66306. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66307. /**
  66308. * Tests if the bounding sphere center is in between the frustum planes.
  66309. * Used for optimistic fast inclusion.
  66310. * @param frustumPlanes defines the frustum planes to test
  66311. * @returns true if the sphere center is in between the frustum planes
  66312. */
  66313. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66314. /**
  66315. * Tests if a point is inside the bounding sphere
  66316. * @param point defines the point to test
  66317. * @returns true if the point is inside the bounding sphere
  66318. */
  66319. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66320. /**
  66321. * Checks if two sphere intersct
  66322. * @param sphere0 sphere 0
  66323. * @param sphere1 sphere 1
  66324. * @returns true if the speres intersect
  66325. */
  66326. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  66327. }
  66328. }
  66329. declare module BABYLON {
  66330. /**
  66331. * Class used to store bounding box information
  66332. */
  66333. export class BoundingBox implements ICullable {
  66334. /**
  66335. * Gets the 8 vectors representing the bounding box in local space
  66336. */
  66337. readonly vectors: Vector3[];
  66338. /**
  66339. * Gets the center of the bounding box in local space
  66340. */
  66341. readonly center: Vector3;
  66342. /**
  66343. * Gets the center of the bounding box in world space
  66344. */
  66345. readonly centerWorld: Vector3;
  66346. /**
  66347. * Gets the extend size in local space
  66348. */
  66349. readonly extendSize: Vector3;
  66350. /**
  66351. * Gets the extend size in world space
  66352. */
  66353. readonly extendSizeWorld: Vector3;
  66354. /**
  66355. * Gets the OBB (object bounding box) directions
  66356. */
  66357. readonly directions: Vector3[];
  66358. /**
  66359. * Gets the 8 vectors representing the bounding box in world space
  66360. */
  66361. readonly vectorsWorld: Vector3[];
  66362. /**
  66363. * Gets the minimum vector in world space
  66364. */
  66365. readonly minimumWorld: Vector3;
  66366. /**
  66367. * Gets the maximum vector in world space
  66368. */
  66369. readonly maximumWorld: Vector3;
  66370. /**
  66371. * Gets the minimum vector in local space
  66372. */
  66373. readonly minimum: Vector3;
  66374. /**
  66375. * Gets the maximum vector in local space
  66376. */
  66377. readonly maximum: Vector3;
  66378. private _worldMatrix;
  66379. private static readonly TmpVector3;
  66380. /**
  66381. * @hidden
  66382. */
  66383. _tag: number;
  66384. /**
  66385. * Creates a new bounding box
  66386. * @param min defines the minimum vector (in local space)
  66387. * @param max defines the maximum vector (in local space)
  66388. * @param worldMatrix defines the new world matrix
  66389. */
  66390. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66391. /**
  66392. * Recreates the entire bounding box from scratch as if we call the constructor in place
  66393. * @param min defines the new minimum vector (in local space)
  66394. * @param max defines the new maximum vector (in local space)
  66395. * @param worldMatrix defines the new world matrix
  66396. */
  66397. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66398. /**
  66399. * Scale the current bounding box by applying a scale factor
  66400. * @param factor defines the scale factor to apply
  66401. * @returns the current bounding box
  66402. */
  66403. scale(factor: number): BoundingBox;
  66404. /**
  66405. * Gets the world matrix of the bounding box
  66406. * @returns a matrix
  66407. */
  66408. getWorldMatrix(): DeepImmutable<Matrix>;
  66409. /** @hidden */
  66410. _update(world: DeepImmutable<Matrix>): void;
  66411. /**
  66412. * Tests if the bounding box is intersecting the frustum planes
  66413. * @param frustumPlanes defines the frustum planes to test
  66414. * @returns true if there is an intersection
  66415. */
  66416. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66417. /**
  66418. * Tests if the bounding box is entirely inside the frustum planes
  66419. * @param frustumPlanes defines the frustum planes to test
  66420. * @returns true if there is an inclusion
  66421. */
  66422. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66423. /**
  66424. * Tests if a point is inside the bounding box
  66425. * @param point defines the point to test
  66426. * @returns true if the point is inside the bounding box
  66427. */
  66428. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66429. /**
  66430. * Tests if the bounding box intersects with a bounding sphere
  66431. * @param sphere defines the sphere to test
  66432. * @returns true if there is an intersection
  66433. */
  66434. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  66435. /**
  66436. * Tests if the bounding box intersects with a box defined by a min and max vectors
  66437. * @param min defines the min vector to use
  66438. * @param max defines the max vector to use
  66439. * @returns true if there is an intersection
  66440. */
  66441. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  66442. /**
  66443. * Tests if two bounding boxes are intersections
  66444. * @param box0 defines the first box to test
  66445. * @param box1 defines the second box to test
  66446. * @returns true if there is an intersection
  66447. */
  66448. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  66449. /**
  66450. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  66451. * @param minPoint defines the minimum vector of the bounding box
  66452. * @param maxPoint defines the maximum vector of the bounding box
  66453. * @param sphereCenter defines the sphere center
  66454. * @param sphereRadius defines the sphere radius
  66455. * @returns true if there is an intersection
  66456. */
  66457. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  66458. /**
  66459. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  66460. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  66461. * @param frustumPlanes defines the frustum planes to test
  66462. * @return true if there is an inclusion
  66463. */
  66464. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66465. /**
  66466. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  66467. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  66468. * @param frustumPlanes defines the frustum planes to test
  66469. * @return true if there is an intersection
  66470. */
  66471. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66472. }
  66473. }
  66474. declare module BABYLON {
  66475. /** @hidden */
  66476. export class Collider {
  66477. /** Define if a collision was found */
  66478. collisionFound: boolean;
  66479. /**
  66480. * Define last intersection point in local space
  66481. */
  66482. intersectionPoint: Vector3;
  66483. /**
  66484. * Define last collided mesh
  66485. */
  66486. collidedMesh: Nullable<AbstractMesh>;
  66487. private _collisionPoint;
  66488. private _planeIntersectionPoint;
  66489. private _tempVector;
  66490. private _tempVector2;
  66491. private _tempVector3;
  66492. private _tempVector4;
  66493. private _edge;
  66494. private _baseToVertex;
  66495. private _destinationPoint;
  66496. private _slidePlaneNormal;
  66497. private _displacementVector;
  66498. /** @hidden */
  66499. _radius: Vector3;
  66500. /** @hidden */
  66501. _retry: number;
  66502. private _velocity;
  66503. private _basePoint;
  66504. private _epsilon;
  66505. /** @hidden */
  66506. _velocityWorldLength: number;
  66507. /** @hidden */
  66508. _basePointWorld: Vector3;
  66509. private _velocityWorld;
  66510. private _normalizedVelocity;
  66511. /** @hidden */
  66512. _initialVelocity: Vector3;
  66513. /** @hidden */
  66514. _initialPosition: Vector3;
  66515. private _nearestDistance;
  66516. private _collisionMask;
  66517. collisionMask: number;
  66518. /**
  66519. * Gets the plane normal used to compute the sliding response (in local space)
  66520. */
  66521. readonly slidePlaneNormal: Vector3;
  66522. /** @hidden */
  66523. _initialize(source: Vector3, dir: Vector3, e: number): void;
  66524. /** @hidden */
  66525. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  66526. /** @hidden */
  66527. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  66528. /** @hidden */
  66529. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  66530. /** @hidden */
  66531. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  66532. /** @hidden */
  66533. _getResponse(pos: Vector3, vel: Vector3): void;
  66534. }
  66535. }
  66536. declare module BABYLON {
  66537. /**
  66538. * Interface for cullable objects
  66539. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  66540. */
  66541. export interface ICullable {
  66542. /**
  66543. * Checks if the object or part of the object is in the frustum
  66544. * @param frustumPlanes Camera near/planes
  66545. * @returns true if the object is in frustum otherwise false
  66546. */
  66547. isInFrustum(frustumPlanes: Plane[]): boolean;
  66548. /**
  66549. * Checks if a cullable object (mesh...) is in the camera frustum
  66550. * Unlike isInFrustum this cheks the full bounding box
  66551. * @param frustumPlanes Camera near/planes
  66552. * @returns true if the object is in frustum otherwise false
  66553. */
  66554. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  66555. }
  66556. /**
  66557. * Info for a bounding data of a mesh
  66558. */
  66559. export class BoundingInfo implements ICullable {
  66560. /**
  66561. * Bounding box for the mesh
  66562. */
  66563. readonly boundingBox: BoundingBox;
  66564. /**
  66565. * Bounding sphere for the mesh
  66566. */
  66567. readonly boundingSphere: BoundingSphere;
  66568. private _isLocked;
  66569. private static readonly TmpVector3;
  66570. /**
  66571. * Constructs bounding info
  66572. * @param minimum min vector of the bounding box/sphere
  66573. * @param maximum max vector of the bounding box/sphere
  66574. * @param worldMatrix defines the new world matrix
  66575. */
  66576. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66577. /**
  66578. * Recreates the entire bounding info from scratch as if we call the constructor in place
  66579. * @param min defines the new minimum vector (in local space)
  66580. * @param max defines the new maximum vector (in local space)
  66581. * @param worldMatrix defines the new world matrix
  66582. */
  66583. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66584. /**
  66585. * min vector of the bounding box/sphere
  66586. */
  66587. readonly minimum: Vector3;
  66588. /**
  66589. * max vector of the bounding box/sphere
  66590. */
  66591. readonly maximum: Vector3;
  66592. /**
  66593. * If the info is locked and won't be updated to avoid perf overhead
  66594. */
  66595. isLocked: boolean;
  66596. /**
  66597. * Updates the bounding sphere and box
  66598. * @param world world matrix to be used to update
  66599. */
  66600. update(world: DeepImmutable<Matrix>): void;
  66601. /**
  66602. * Recreate the bounding info to be centered around a specific point given a specific extend.
  66603. * @param center New center of the bounding info
  66604. * @param extend New extend of the bounding info
  66605. * @returns the current bounding info
  66606. */
  66607. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  66608. /**
  66609. * Scale the current bounding info by applying a scale factor
  66610. * @param factor defines the scale factor to apply
  66611. * @returns the current bounding info
  66612. */
  66613. scale(factor: number): BoundingInfo;
  66614. /**
  66615. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  66616. * @param frustumPlanes defines the frustum to test
  66617. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  66618. * @returns true if the bounding info is in the frustum planes
  66619. */
  66620. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  66621. /**
  66622. * Gets the world distance between the min and max points of the bounding box
  66623. */
  66624. readonly diagonalLength: number;
  66625. /**
  66626. * Checks if a cullable object (mesh...) is in the camera frustum
  66627. * Unlike isInFrustum this cheks the full bounding box
  66628. * @param frustumPlanes Camera near/planes
  66629. * @returns true if the object is in frustum otherwise false
  66630. */
  66631. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66632. /** @hidden */
  66633. _checkCollision(collider: Collider): boolean;
  66634. /**
  66635. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  66636. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  66637. * @param point the point to check intersection with
  66638. * @returns if the point intersects
  66639. */
  66640. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66641. /**
  66642. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  66643. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  66644. * @param boundingInfo the bounding info to check intersection with
  66645. * @param precise if the intersection should be done using OBB
  66646. * @returns if the bounding info intersects
  66647. */
  66648. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  66649. }
  66650. }
  66651. declare module BABYLON {
  66652. /**
  66653. * Defines an array and its length.
  66654. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  66655. */
  66656. export interface ISmartArrayLike<T> {
  66657. /**
  66658. * The data of the array.
  66659. */
  66660. data: Array<T>;
  66661. /**
  66662. * The active length of the array.
  66663. */
  66664. length: number;
  66665. }
  66666. /**
  66667. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  66668. */
  66669. export class SmartArray<T> implements ISmartArrayLike<T> {
  66670. /**
  66671. * The full set of data from the array.
  66672. */
  66673. data: Array<T>;
  66674. /**
  66675. * The active length of the array.
  66676. */
  66677. length: number;
  66678. protected _id: number;
  66679. /**
  66680. * Instantiates a Smart Array.
  66681. * @param capacity defines the default capacity of the array.
  66682. */
  66683. constructor(capacity: number);
  66684. /**
  66685. * Pushes a value at the end of the active data.
  66686. * @param value defines the object to push in the array.
  66687. */
  66688. push(value: T): void;
  66689. /**
  66690. * Iterates over the active data and apply the lambda to them.
  66691. * @param func defines the action to apply on each value.
  66692. */
  66693. forEach(func: (content: T) => void): void;
  66694. /**
  66695. * Sorts the full sets of data.
  66696. * @param compareFn defines the comparison function to apply.
  66697. */
  66698. sort(compareFn: (a: T, b: T) => number): void;
  66699. /**
  66700. * Resets the active data to an empty array.
  66701. */
  66702. reset(): void;
  66703. /**
  66704. * Releases all the data from the array as well as the array.
  66705. */
  66706. dispose(): void;
  66707. /**
  66708. * Concats the active data with a given array.
  66709. * @param array defines the data to concatenate with.
  66710. */
  66711. concat(array: any): void;
  66712. /**
  66713. * Returns the position of a value in the active data.
  66714. * @param value defines the value to find the index for
  66715. * @returns the index if found in the active data otherwise -1
  66716. */
  66717. indexOf(value: T): number;
  66718. /**
  66719. * Returns whether an element is part of the active data.
  66720. * @param value defines the value to look for
  66721. * @returns true if found in the active data otherwise false
  66722. */
  66723. contains(value: T): boolean;
  66724. private static _GlobalId;
  66725. }
  66726. /**
  66727. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  66728. * The data in this array can only be present once
  66729. */
  66730. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  66731. private _duplicateId;
  66732. /**
  66733. * Pushes a value at the end of the active data.
  66734. * THIS DOES NOT PREVENT DUPPLICATE DATA
  66735. * @param value defines the object to push in the array.
  66736. */
  66737. push(value: T): void;
  66738. /**
  66739. * Pushes a value at the end of the active data.
  66740. * If the data is already present, it won t be added again
  66741. * @param value defines the object to push in the array.
  66742. * @returns true if added false if it was already present
  66743. */
  66744. pushNoDuplicate(value: T): boolean;
  66745. /**
  66746. * Resets the active data to an empty array.
  66747. */
  66748. reset(): void;
  66749. /**
  66750. * Concats the active data with a given array.
  66751. * This ensures no dupplicate will be present in the result.
  66752. * @param array defines the data to concatenate with.
  66753. */
  66754. concatWithNoDuplicate(array: any): void;
  66755. }
  66756. }
  66757. declare module BABYLON {
  66758. /**
  66759. * A multi-material is used to apply different materials to different parts of the same object without the need of
  66760. * separate meshes. This can be use to improve performances.
  66761. * @see http://doc.babylonjs.com/how_to/multi_materials
  66762. */
  66763. export class MultiMaterial extends Material {
  66764. private _subMaterials;
  66765. /**
  66766. * Gets or Sets the list of Materials used within the multi material.
  66767. * They need to be ordered according to the submeshes order in the associated mesh
  66768. */
  66769. subMaterials: Nullable<Material>[];
  66770. /**
  66771. * Function used to align with Node.getChildren()
  66772. * @returns the list of Materials used within the multi material
  66773. */
  66774. getChildren(): Nullable<Material>[];
  66775. /**
  66776. * Instantiates a new Multi Material
  66777. * A multi-material is used to apply different materials to different parts of the same object without the need of
  66778. * separate meshes. This can be use to improve performances.
  66779. * @see http://doc.babylonjs.com/how_to/multi_materials
  66780. * @param name Define the name in the scene
  66781. * @param scene Define the scene the material belongs to
  66782. */
  66783. constructor(name: string, scene: Scene);
  66784. private _hookArray;
  66785. /**
  66786. * Get one of the submaterial by its index in the submaterials array
  66787. * @param index The index to look the sub material at
  66788. * @returns The Material if the index has been defined
  66789. */
  66790. getSubMaterial(index: number): Nullable<Material>;
  66791. /**
  66792. * Get the list of active textures for the whole sub materials list.
  66793. * @returns All the textures that will be used during the rendering
  66794. */
  66795. getActiveTextures(): BaseTexture[];
  66796. /**
  66797. * Gets the current class name of the material e.g. "MultiMaterial"
  66798. * Mainly use in serialization.
  66799. * @returns the class name
  66800. */
  66801. getClassName(): string;
  66802. /**
  66803. * Checks if the material is ready to render the requested sub mesh
  66804. * @param mesh Define the mesh the submesh belongs to
  66805. * @param subMesh Define the sub mesh to look readyness for
  66806. * @param useInstances Define whether or not the material is used with instances
  66807. * @returns true if ready, otherwise false
  66808. */
  66809. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  66810. /**
  66811. * Clones the current material and its related sub materials
  66812. * @param name Define the name of the newly cloned material
  66813. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  66814. * @returns the cloned material
  66815. */
  66816. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  66817. /**
  66818. * Serializes the materials into a JSON representation.
  66819. * @returns the JSON representation
  66820. */
  66821. serialize(): any;
  66822. /**
  66823. * Dispose the material and release its associated resources
  66824. * @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)
  66825. * @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)
  66826. * @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)
  66827. */
  66828. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  66829. /**
  66830. * Creates a MultiMaterial from parsed MultiMaterial data.
  66831. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  66832. * @param scene defines the hosting scene
  66833. * @returns a new MultiMaterial
  66834. */
  66835. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  66836. }
  66837. }
  66838. declare module BABYLON {
  66839. /**
  66840. * Class used to represent data loading progression
  66841. */
  66842. export class SceneLoaderFlags {
  66843. private static _ForceFullSceneLoadingForIncremental;
  66844. private static _ShowLoadingScreen;
  66845. private static _CleanBoneMatrixWeights;
  66846. private static _loggingLevel;
  66847. /**
  66848. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  66849. */
  66850. static ForceFullSceneLoadingForIncremental: boolean;
  66851. /**
  66852. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  66853. */
  66854. static ShowLoadingScreen: boolean;
  66855. /**
  66856. * Defines the current logging level (while loading the scene)
  66857. * @ignorenaming
  66858. */
  66859. static loggingLevel: number;
  66860. /**
  66861. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  66862. */
  66863. static CleanBoneMatrixWeights: boolean;
  66864. }
  66865. }
  66866. declare module BABYLON {
  66867. /**
  66868. * 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.
  66869. * @see https://doc.babylonjs.com/how_to/transformnode
  66870. */
  66871. export class TransformNode extends Node {
  66872. /**
  66873. * Object will not rotate to face the camera
  66874. */
  66875. static BILLBOARDMODE_NONE: number;
  66876. /**
  66877. * Object will rotate to face the camera but only on the x axis
  66878. */
  66879. static BILLBOARDMODE_X: number;
  66880. /**
  66881. * Object will rotate to face the camera but only on the y axis
  66882. */
  66883. static BILLBOARDMODE_Y: number;
  66884. /**
  66885. * Object will rotate to face the camera but only on the z axis
  66886. */
  66887. static BILLBOARDMODE_Z: number;
  66888. /**
  66889. * Object will rotate to face the camera
  66890. */
  66891. static BILLBOARDMODE_ALL: number;
  66892. private _forward;
  66893. private _forwardInverted;
  66894. private _up;
  66895. private _right;
  66896. private _rightInverted;
  66897. private _position;
  66898. private _rotation;
  66899. private _rotationQuaternion;
  66900. protected _scaling: Vector3;
  66901. protected _isDirty: boolean;
  66902. private _transformToBoneReferal;
  66903. private _billboardMode;
  66904. /**
  66905. * Gets or sets the billboard mode. Default is 0.
  66906. *
  66907. * | Value | Type | Description |
  66908. * | --- | --- | --- |
  66909. * | 0 | BILLBOARDMODE_NONE | |
  66910. * | 1 | BILLBOARDMODE_X | |
  66911. * | 2 | BILLBOARDMODE_Y | |
  66912. * | 4 | BILLBOARDMODE_Z | |
  66913. * | 7 | BILLBOARDMODE_ALL | |
  66914. *
  66915. */
  66916. billboardMode: number;
  66917. private _preserveParentRotationForBillboard;
  66918. /**
  66919. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  66920. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  66921. */
  66922. preserveParentRotationForBillboard: boolean;
  66923. /**
  66924. * 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
  66925. */
  66926. scalingDeterminant: number;
  66927. private _infiniteDistance;
  66928. /**
  66929. * Gets or sets the distance of the object to max, often used by skybox
  66930. */
  66931. infiniteDistance: boolean;
  66932. /**
  66933. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  66934. * By default the system will update normals to compensate
  66935. */
  66936. ignoreNonUniformScaling: boolean;
  66937. /**
  66938. * 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
  66939. */
  66940. reIntegrateRotationIntoRotationQuaternion: boolean;
  66941. /** @hidden */
  66942. _poseMatrix: Matrix;
  66943. /** @hidden */
  66944. _localMatrix: Matrix;
  66945. private _absolutePosition;
  66946. private _pivotMatrix;
  66947. private _pivotMatrixInverse;
  66948. protected _postMultiplyPivotMatrix: boolean;
  66949. protected _isWorldMatrixFrozen: boolean;
  66950. /** @hidden */
  66951. _indexInSceneTransformNodesArray: number;
  66952. private _connectBillboardProcessors;
  66953. /**
  66954. * An event triggered after the world matrix is updated
  66955. */
  66956. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  66957. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  66958. /**
  66959. * Gets a string identifying the name of the class
  66960. * @returns "TransformNode" string
  66961. */
  66962. getClassName(): string;
  66963. /**
  66964. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  66965. */
  66966. position: Vector3;
  66967. /**
  66968. * 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)).
  66969. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  66970. */
  66971. rotation: Vector3;
  66972. /**
  66973. * 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)).
  66974. */
  66975. scaling: Vector3;
  66976. /**
  66977. * 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).
  66978. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  66979. */
  66980. rotationQuaternion: Nullable<Quaternion>;
  66981. /**
  66982. * The forward direction of that transform in world space.
  66983. */
  66984. readonly forward: Vector3;
  66985. /**
  66986. * The up direction of that transform in world space.
  66987. */
  66988. readonly up: Vector3;
  66989. /**
  66990. * The right direction of that transform in world space.
  66991. */
  66992. readonly right: Vector3;
  66993. /**
  66994. * Copies the parameter passed Matrix into the mesh Pose matrix.
  66995. * @param matrix the matrix to copy the pose from
  66996. * @returns this TransformNode.
  66997. */
  66998. updatePoseMatrix(matrix: Matrix): TransformNode;
  66999. /**
  67000. * Returns the mesh Pose matrix.
  67001. * @returns the pose matrix
  67002. */
  67003. getPoseMatrix(): Matrix;
  67004. /** @hidden */
  67005. _isSynchronized(): boolean;
  67006. /** @hidden */
  67007. _initCache(): void;
  67008. /**
  67009. * Flag the transform node as dirty (Forcing it to update everything)
  67010. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  67011. * @returns this transform node
  67012. */
  67013. markAsDirty(property: string): TransformNode;
  67014. /**
  67015. * Returns the current mesh absolute position.
  67016. * Returns a Vector3.
  67017. */
  67018. readonly absolutePosition: Vector3;
  67019. /**
  67020. * Sets a new matrix to apply before all other transformation
  67021. * @param matrix defines the transform matrix
  67022. * @returns the current TransformNode
  67023. */
  67024. setPreTransformMatrix(matrix: Matrix): TransformNode;
  67025. /**
  67026. * Sets a new pivot matrix to the current node
  67027. * @param matrix defines the new pivot matrix to use
  67028. * @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
  67029. * @returns the current TransformNode
  67030. */
  67031. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  67032. /**
  67033. * Returns the mesh pivot matrix.
  67034. * Default : Identity.
  67035. * @returns the matrix
  67036. */
  67037. getPivotMatrix(): Matrix;
  67038. /**
  67039. * Prevents the World matrix to be computed any longer.
  67040. * @returns the TransformNode.
  67041. */
  67042. freezeWorldMatrix(): TransformNode;
  67043. /**
  67044. * Allows back the World matrix computation.
  67045. * @returns the TransformNode.
  67046. */
  67047. unfreezeWorldMatrix(): this;
  67048. /**
  67049. * True if the World matrix has been frozen.
  67050. */
  67051. readonly isWorldMatrixFrozen: boolean;
  67052. /**
  67053. * Retuns the mesh absolute position in the World.
  67054. * @returns a Vector3.
  67055. */
  67056. getAbsolutePosition(): Vector3;
  67057. /**
  67058. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  67059. * @param absolutePosition the absolute position to set
  67060. * @returns the TransformNode.
  67061. */
  67062. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  67063. /**
  67064. * Sets the mesh position in its local space.
  67065. * @param vector3 the position to set in localspace
  67066. * @returns the TransformNode.
  67067. */
  67068. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  67069. /**
  67070. * Returns the mesh position in the local space from the current World matrix values.
  67071. * @returns a new Vector3.
  67072. */
  67073. getPositionExpressedInLocalSpace(): Vector3;
  67074. /**
  67075. * Translates the mesh along the passed Vector3 in its local space.
  67076. * @param vector3 the distance to translate in localspace
  67077. * @returns the TransformNode.
  67078. */
  67079. locallyTranslate(vector3: Vector3): TransformNode;
  67080. private static _lookAtVectorCache;
  67081. /**
  67082. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  67083. * @param targetPoint the position (must be in same space as current mesh) to look at
  67084. * @param yawCor optional yaw (y-axis) correction in radians
  67085. * @param pitchCor optional pitch (x-axis) correction in radians
  67086. * @param rollCor optional roll (z-axis) correction in radians
  67087. * @param space the choosen space of the target
  67088. * @returns the TransformNode.
  67089. */
  67090. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  67091. /**
  67092. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  67093. * This Vector3 is expressed in the World space.
  67094. * @param localAxis axis to rotate
  67095. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  67096. */
  67097. getDirection(localAxis: Vector3): Vector3;
  67098. /**
  67099. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  67100. * localAxis is expressed in the mesh local space.
  67101. * result is computed in the Wordl space from the mesh World matrix.
  67102. * @param localAxis axis to rotate
  67103. * @param result the resulting transformnode
  67104. * @returns this TransformNode.
  67105. */
  67106. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  67107. /**
  67108. * Sets this transform node rotation to the given local axis.
  67109. * @param localAxis the axis in local space
  67110. * @param yawCor optional yaw (y-axis) correction in radians
  67111. * @param pitchCor optional pitch (x-axis) correction in radians
  67112. * @param rollCor optional roll (z-axis) correction in radians
  67113. * @returns this TransformNode
  67114. */
  67115. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  67116. /**
  67117. * Sets a new pivot point to the current node
  67118. * @param point defines the new pivot point to use
  67119. * @param space defines if the point is in world or local space (local by default)
  67120. * @returns the current TransformNode
  67121. */
  67122. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  67123. /**
  67124. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  67125. * @returns the pivot point
  67126. */
  67127. getPivotPoint(): Vector3;
  67128. /**
  67129. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  67130. * @param result the vector3 to store the result
  67131. * @returns this TransformNode.
  67132. */
  67133. getPivotPointToRef(result: Vector3): TransformNode;
  67134. /**
  67135. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  67136. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  67137. */
  67138. getAbsolutePivotPoint(): Vector3;
  67139. /**
  67140. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  67141. * @param result vector3 to store the result
  67142. * @returns this TransformNode.
  67143. */
  67144. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  67145. /**
  67146. * Defines the passed node as the parent of the current node.
  67147. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  67148. * @see https://doc.babylonjs.com/how_to/parenting
  67149. * @param node the node ot set as the parent
  67150. * @returns this TransformNode.
  67151. */
  67152. setParent(node: Nullable<Node>): TransformNode;
  67153. private _nonUniformScaling;
  67154. /**
  67155. * True if the scaling property of this object is non uniform eg. (1,2,1)
  67156. */
  67157. readonly nonUniformScaling: boolean;
  67158. /** @hidden */
  67159. _updateNonUniformScalingState(value: boolean): boolean;
  67160. /**
  67161. * Attach the current TransformNode to another TransformNode associated with a bone
  67162. * @param bone Bone affecting the TransformNode
  67163. * @param affectedTransformNode TransformNode associated with the bone
  67164. * @returns this object
  67165. */
  67166. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  67167. /**
  67168. * Detach the transform node if its associated with a bone
  67169. * @returns this object
  67170. */
  67171. detachFromBone(): TransformNode;
  67172. private static _rotationAxisCache;
  67173. /**
  67174. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  67175. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  67176. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  67177. * The passed axis is also normalized.
  67178. * @param axis the axis to rotate around
  67179. * @param amount the amount to rotate in radians
  67180. * @param space Space to rotate in (Default: local)
  67181. * @returns the TransformNode.
  67182. */
  67183. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  67184. /**
  67185. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  67186. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  67187. * The passed axis is also normalized. .
  67188. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  67189. * @param point the point to rotate around
  67190. * @param axis the axis to rotate around
  67191. * @param amount the amount to rotate in radians
  67192. * @returns the TransformNode
  67193. */
  67194. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  67195. /**
  67196. * Translates the mesh along the axis vector for the passed distance in the given space.
  67197. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  67198. * @param axis the axis to translate in
  67199. * @param distance the distance to translate
  67200. * @param space Space to rotate in (Default: local)
  67201. * @returns the TransformNode.
  67202. */
  67203. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  67204. /**
  67205. * Adds a rotation step to the mesh current rotation.
  67206. * x, y, z are Euler angles expressed in radians.
  67207. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  67208. * This means this rotation is made in the mesh local space only.
  67209. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  67210. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  67211. * ```javascript
  67212. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  67213. * ```
  67214. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  67215. * 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.
  67216. * @param x Rotation to add
  67217. * @param y Rotation to add
  67218. * @param z Rotation to add
  67219. * @returns the TransformNode.
  67220. */
  67221. addRotation(x: number, y: number, z: number): TransformNode;
  67222. /**
  67223. * @hidden
  67224. */
  67225. protected _getEffectiveParent(): Nullable<Node>;
  67226. private _activeCompositionProcessor;
  67227. private _defaultCompositionProcessor;
  67228. private _pivotCompositionProcessor;
  67229. private _translationProcessor;
  67230. private _defaultTranslationProcessor;
  67231. private _infiniteDistanceTranslationProcessor;
  67232. private _activeParentProcessor;
  67233. private _activeBillboardPostProcessor;
  67234. private _defaultParentProcessor;
  67235. private _billboardParentProcessor;
  67236. private _billboardPostProcessor;
  67237. /**
  67238. * Computes the world matrix of the node
  67239. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  67240. * @returns the world matrix
  67241. */
  67242. computeWorldMatrix(force?: boolean): Matrix;
  67243. protected _afterComputeWorldMatrix(): void;
  67244. /**
  67245. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  67246. * @param func callback function to add
  67247. *
  67248. * @returns the TransformNode.
  67249. */
  67250. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  67251. /**
  67252. * Removes a registered callback function.
  67253. * @param func callback function to remove
  67254. * @returns the TransformNode.
  67255. */
  67256. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  67257. /**
  67258. * Gets the position of the current mesh in camera space
  67259. * @param camera defines the camera to use
  67260. * @returns a position
  67261. */
  67262. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  67263. /**
  67264. * Returns the distance from the mesh to the active camera
  67265. * @param camera defines the camera to use
  67266. * @returns the distance
  67267. */
  67268. getDistanceToCamera(camera?: Nullable<Camera>): number;
  67269. /**
  67270. * Clone the current transform node
  67271. * @param name Name of the new clone
  67272. * @param newParent New parent for the clone
  67273. * @param doNotCloneChildren Do not clone children hierarchy
  67274. * @returns the new transform node
  67275. */
  67276. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  67277. /**
  67278. * Serializes the objects information.
  67279. * @param currentSerializationObject defines the object to serialize in
  67280. * @returns the serialized object
  67281. */
  67282. serialize(currentSerializationObject?: any): any;
  67283. /**
  67284. * Returns a new TransformNode object parsed from the source provided.
  67285. * @param parsedTransformNode is the source.
  67286. * @param scene the scne the object belongs to
  67287. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  67288. * @returns a new TransformNode object parsed from the source provided.
  67289. */
  67290. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  67291. /**
  67292. * Get all child-transformNodes of this node
  67293. * @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
  67294. * @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
  67295. * @returns an array of TransformNode
  67296. */
  67297. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  67298. /**
  67299. * Releases resources associated with this transform node.
  67300. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  67301. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  67302. */
  67303. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  67304. }
  67305. }
  67306. declare module BABYLON {
  67307. /**
  67308. * Class used to override all child animations of a given target
  67309. */
  67310. export class AnimationPropertiesOverride {
  67311. /**
  67312. * Gets or sets a value indicating if animation blending must be used
  67313. */
  67314. enableBlending: boolean;
  67315. /**
  67316. * Gets or sets the blending speed to use when enableBlending is true
  67317. */
  67318. blendingSpeed: number;
  67319. /**
  67320. * Gets or sets the default loop mode to use
  67321. */
  67322. loopMode: number;
  67323. }
  67324. }
  67325. declare module BABYLON {
  67326. /**
  67327. * Class used to store bone information
  67328. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  67329. */
  67330. export class Bone extends Node {
  67331. /**
  67332. * defines the bone name
  67333. */
  67334. name: string;
  67335. private static _tmpVecs;
  67336. private static _tmpQuat;
  67337. private static _tmpMats;
  67338. /**
  67339. * Gets the list of child bones
  67340. */
  67341. children: Bone[];
  67342. /** Gets the animations associated with this bone */
  67343. animations: Animation[];
  67344. /**
  67345. * Gets or sets bone length
  67346. */
  67347. length: number;
  67348. /**
  67349. * @hidden Internal only
  67350. * Set this value to map this bone to a different index in the transform matrices
  67351. * Set this value to -1 to exclude the bone from the transform matrices
  67352. */
  67353. _index: Nullable<number>;
  67354. private _skeleton;
  67355. private _localMatrix;
  67356. private _restPose;
  67357. private _baseMatrix;
  67358. private _absoluteTransform;
  67359. private _invertedAbsoluteTransform;
  67360. private _parent;
  67361. private _scalingDeterminant;
  67362. private _worldTransform;
  67363. private _localScaling;
  67364. private _localRotation;
  67365. private _localPosition;
  67366. private _needToDecompose;
  67367. private _needToCompose;
  67368. /** @hidden */
  67369. _linkedTransformNode: Nullable<TransformNode>;
  67370. /** @hidden */
  67371. /** @hidden */
  67372. _matrix: Matrix;
  67373. /**
  67374. * Create a new bone
  67375. * @param name defines the bone name
  67376. * @param skeleton defines the parent skeleton
  67377. * @param parentBone defines the parent (can be null if the bone is the root)
  67378. * @param localMatrix defines the local matrix
  67379. * @param restPose defines the rest pose matrix
  67380. * @param baseMatrix defines the base matrix
  67381. * @param index defines index of the bone in the hiearchy
  67382. */
  67383. constructor(
  67384. /**
  67385. * defines the bone name
  67386. */
  67387. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  67388. /**
  67389. * Gets the current object class name.
  67390. * @return the class name
  67391. */
  67392. getClassName(): string;
  67393. /**
  67394. * Gets the parent skeleton
  67395. * @returns a skeleton
  67396. */
  67397. getSkeleton(): Skeleton;
  67398. /**
  67399. * Gets parent bone
  67400. * @returns a bone or null if the bone is the root of the bone hierarchy
  67401. */
  67402. getParent(): Nullable<Bone>;
  67403. /**
  67404. * Returns an array containing the root bones
  67405. * @returns an array containing the root bones
  67406. */
  67407. getChildren(): Array<Bone>;
  67408. /**
  67409. * Sets the parent bone
  67410. * @param parent defines the parent (can be null if the bone is the root)
  67411. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  67412. */
  67413. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  67414. /**
  67415. * Gets the local matrix
  67416. * @returns a matrix
  67417. */
  67418. getLocalMatrix(): Matrix;
  67419. /**
  67420. * Gets the base matrix (initial matrix which remains unchanged)
  67421. * @returns a matrix
  67422. */
  67423. getBaseMatrix(): Matrix;
  67424. /**
  67425. * Gets the rest pose matrix
  67426. * @returns a matrix
  67427. */
  67428. getRestPose(): Matrix;
  67429. /**
  67430. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  67431. */
  67432. getWorldMatrix(): Matrix;
  67433. /**
  67434. * Sets the local matrix to rest pose matrix
  67435. */
  67436. returnToRest(): void;
  67437. /**
  67438. * Gets the inverse of the absolute transform matrix.
  67439. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  67440. * @returns a matrix
  67441. */
  67442. getInvertedAbsoluteTransform(): Matrix;
  67443. /**
  67444. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  67445. * @returns a matrix
  67446. */
  67447. getAbsoluteTransform(): Matrix;
  67448. /**
  67449. * Links with the given transform node.
  67450. * The local matrix of this bone is copied from the transform node every frame.
  67451. * @param transformNode defines the transform node to link to
  67452. */
  67453. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  67454. /** Gets or sets current position (in local space) */
  67455. position: Vector3;
  67456. /** Gets or sets current rotation (in local space) */
  67457. rotation: Vector3;
  67458. /** Gets or sets current rotation quaternion (in local space) */
  67459. rotationQuaternion: Quaternion;
  67460. /** Gets or sets current scaling (in local space) */
  67461. scaling: Vector3;
  67462. /**
  67463. * Gets the animation properties override
  67464. */
  67465. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  67466. private _decompose;
  67467. private _compose;
  67468. /**
  67469. * Update the base and local matrices
  67470. * @param matrix defines the new base or local matrix
  67471. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  67472. * @param updateLocalMatrix defines if the local matrix should be updated
  67473. */
  67474. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  67475. /** @hidden */
  67476. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  67477. /**
  67478. * Flag the bone as dirty (Forcing it to update everything)
  67479. */
  67480. markAsDirty(): void;
  67481. private _markAsDirtyAndCompose;
  67482. private _markAsDirtyAndDecompose;
  67483. /**
  67484. * Translate the bone in local or world space
  67485. * @param vec The amount to translate the bone
  67486. * @param space The space that the translation is in
  67487. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67488. */
  67489. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  67490. /**
  67491. * Set the postion of the bone in local or world space
  67492. * @param position The position to set the bone
  67493. * @param space The space that the position is in
  67494. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67495. */
  67496. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  67497. /**
  67498. * Set the absolute position of the bone (world space)
  67499. * @param position The position to set the bone
  67500. * @param mesh The mesh that this bone is attached to
  67501. */
  67502. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  67503. /**
  67504. * Scale the bone on the x, y and z axes (in local space)
  67505. * @param x The amount to scale the bone on the x axis
  67506. * @param y The amount to scale the bone on the y axis
  67507. * @param z The amount to scale the bone on the z axis
  67508. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  67509. */
  67510. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  67511. /**
  67512. * Set the bone scaling in local space
  67513. * @param scale defines the scaling vector
  67514. */
  67515. setScale(scale: Vector3): void;
  67516. /**
  67517. * Gets the current scaling in local space
  67518. * @returns the current scaling vector
  67519. */
  67520. getScale(): Vector3;
  67521. /**
  67522. * Gets the current scaling in local space and stores it in a target vector
  67523. * @param result defines the target vector
  67524. */
  67525. getScaleToRef(result: Vector3): void;
  67526. /**
  67527. * Set the yaw, pitch, and roll of the bone in local or world space
  67528. * @param yaw The rotation of the bone on the y axis
  67529. * @param pitch The rotation of the bone on the x axis
  67530. * @param roll The rotation of the bone on the z axis
  67531. * @param space The space that the axes of rotation are in
  67532. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67533. */
  67534. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  67535. /**
  67536. * Add a rotation to the bone on an axis in local or world space
  67537. * @param axis The axis to rotate the bone on
  67538. * @param amount The amount to rotate the bone
  67539. * @param space The space that the axis is in
  67540. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67541. */
  67542. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  67543. /**
  67544. * Set the rotation of the bone to a particular axis angle in local or world space
  67545. * @param axis The axis to rotate the bone on
  67546. * @param angle The angle that the bone should be rotated to
  67547. * @param space The space that the axis is in
  67548. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67549. */
  67550. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  67551. /**
  67552. * Set the euler rotation of the bone in local of world space
  67553. * @param rotation The euler rotation that the bone should be set to
  67554. * @param space The space that the rotation is in
  67555. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67556. */
  67557. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  67558. /**
  67559. * Set the quaternion rotation of the bone in local of world space
  67560. * @param quat The quaternion rotation that the bone should be set to
  67561. * @param space The space that the rotation is in
  67562. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67563. */
  67564. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  67565. /**
  67566. * Set the rotation matrix of the bone in local of world space
  67567. * @param rotMat The rotation matrix that the bone should be set to
  67568. * @param space The space that the rotation is in
  67569. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67570. */
  67571. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  67572. private _rotateWithMatrix;
  67573. private _getNegativeRotationToRef;
  67574. /**
  67575. * Get the position of the bone in local or world space
  67576. * @param space The space that the returned position is in
  67577. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67578. * @returns The position of the bone
  67579. */
  67580. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  67581. /**
  67582. * Copy the position of the bone to a vector3 in local or world space
  67583. * @param space The space that the returned position is in
  67584. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67585. * @param result The vector3 to copy the position to
  67586. */
  67587. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  67588. /**
  67589. * Get the absolute position of the bone (world space)
  67590. * @param mesh The mesh that this bone is attached to
  67591. * @returns The absolute position of the bone
  67592. */
  67593. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  67594. /**
  67595. * Copy the absolute position of the bone (world space) to the result param
  67596. * @param mesh The mesh that this bone is attached to
  67597. * @param result The vector3 to copy the absolute position to
  67598. */
  67599. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  67600. /**
  67601. * Compute the absolute transforms of this bone and its children
  67602. */
  67603. computeAbsoluteTransforms(): void;
  67604. /**
  67605. * Get the world direction from an axis that is in the local space of the bone
  67606. * @param localAxis The local direction that is used to compute the world direction
  67607. * @param mesh The mesh that this bone is attached to
  67608. * @returns The world direction
  67609. */
  67610. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  67611. /**
  67612. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  67613. * @param localAxis The local direction that is used to compute the world direction
  67614. * @param mesh The mesh that this bone is attached to
  67615. * @param result The vector3 that the world direction will be copied to
  67616. */
  67617. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  67618. /**
  67619. * Get the euler rotation of the bone in local or world space
  67620. * @param space The space that the rotation should be in
  67621. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67622. * @returns The euler rotation
  67623. */
  67624. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  67625. /**
  67626. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  67627. * @param space The space that the rotation should be in
  67628. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67629. * @param result The vector3 that the rotation should be copied to
  67630. */
  67631. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  67632. /**
  67633. * Get the quaternion rotation of the bone in either local or world space
  67634. * @param space The space that the rotation should be in
  67635. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67636. * @returns The quaternion rotation
  67637. */
  67638. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  67639. /**
  67640. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  67641. * @param space The space that the rotation should be in
  67642. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67643. * @param result The quaternion that the rotation should be copied to
  67644. */
  67645. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  67646. /**
  67647. * Get the rotation matrix of the bone in local or world space
  67648. * @param space The space that the rotation should be in
  67649. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67650. * @returns The rotation matrix
  67651. */
  67652. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  67653. /**
  67654. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  67655. * @param space The space that the rotation should be in
  67656. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67657. * @param result The quaternion that the rotation should be copied to
  67658. */
  67659. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  67660. /**
  67661. * Get the world position of a point that is in the local space of the bone
  67662. * @param position The local position
  67663. * @param mesh The mesh that this bone is attached to
  67664. * @returns The world position
  67665. */
  67666. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  67667. /**
  67668. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  67669. * @param position The local position
  67670. * @param mesh The mesh that this bone is attached to
  67671. * @param result The vector3 that the world position should be copied to
  67672. */
  67673. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  67674. /**
  67675. * Get the local position of a point that is in world space
  67676. * @param position The world position
  67677. * @param mesh The mesh that this bone is attached to
  67678. * @returns The local position
  67679. */
  67680. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  67681. /**
  67682. * Get the local position of a point that is in world space and copy it to the result param
  67683. * @param position The world position
  67684. * @param mesh The mesh that this bone is attached to
  67685. * @param result The vector3 that the local position should be copied to
  67686. */
  67687. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  67688. }
  67689. }
  67690. declare module BABYLON {
  67691. /**
  67692. * Enum that determines the text-wrapping mode to use.
  67693. */
  67694. export enum InspectableType {
  67695. /**
  67696. * Checkbox for booleans
  67697. */
  67698. Checkbox = 0,
  67699. /**
  67700. * Sliders for numbers
  67701. */
  67702. Slider = 1,
  67703. /**
  67704. * Vector3
  67705. */
  67706. Vector3 = 2,
  67707. /**
  67708. * Quaternions
  67709. */
  67710. Quaternion = 3,
  67711. /**
  67712. * Color3
  67713. */
  67714. Color3 = 4
  67715. }
  67716. /**
  67717. * Interface used to define custom inspectable properties.
  67718. * This interface is used by the inspector to display custom property grids
  67719. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  67720. */
  67721. export interface IInspectable {
  67722. /**
  67723. * Gets the label to display
  67724. */
  67725. label: string;
  67726. /**
  67727. * Gets the name of the property to edit
  67728. */
  67729. propertyName: string;
  67730. /**
  67731. * Gets the type of the editor to use
  67732. */
  67733. type: InspectableType;
  67734. /**
  67735. * Gets the minimum value of the property when using in "slider" mode
  67736. */
  67737. min?: number;
  67738. /**
  67739. * Gets the maximum value of the property when using in "slider" mode
  67740. */
  67741. max?: number;
  67742. /**
  67743. * Gets the setp to use when using in "slider" mode
  67744. */
  67745. step?: number;
  67746. }
  67747. }
  67748. declare module BABYLON {
  67749. /**
  67750. * Class for creating a cube texture
  67751. */
  67752. export class CubeTexture extends BaseTexture {
  67753. private _delayedOnLoad;
  67754. /**
  67755. * The url of the texture
  67756. */
  67757. url: string;
  67758. /**
  67759. * Gets or sets the center of the bounding box associated with the cube texture.
  67760. * It must define where the camera used to render the texture was set
  67761. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  67762. */
  67763. boundingBoxPosition: Vector3;
  67764. private _boundingBoxSize;
  67765. /**
  67766. * Gets or sets the size of the bounding box associated with the cube texture
  67767. * When defined, the cubemap will switch to local mode
  67768. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  67769. * @example https://www.babylonjs-playground.com/#RNASML
  67770. */
  67771. /**
  67772. * Returns the bounding box size
  67773. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  67774. */
  67775. boundingBoxSize: Vector3;
  67776. protected _rotationY: number;
  67777. /**
  67778. * Sets texture matrix rotation angle around Y axis in radians.
  67779. */
  67780. /**
  67781. * Gets texture matrix rotation angle around Y axis radians.
  67782. */
  67783. rotationY: number;
  67784. /**
  67785. * Are mip maps generated for this texture or not.
  67786. */
  67787. readonly noMipmap: boolean;
  67788. private _noMipmap;
  67789. private _files;
  67790. private _extensions;
  67791. private _textureMatrix;
  67792. private _format;
  67793. private _createPolynomials;
  67794. /** @hidden */
  67795. _prefiltered: boolean;
  67796. /**
  67797. * Creates a cube texture from an array of image urls
  67798. * @param files defines an array of image urls
  67799. * @param scene defines the hosting scene
  67800. * @param noMipmap specifies if mip maps are not used
  67801. * @returns a cube texture
  67802. */
  67803. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  67804. /**
  67805. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  67806. * @param url defines the url of the prefiltered texture
  67807. * @param scene defines the scene the texture is attached to
  67808. * @param forcedExtension defines the extension of the file if different from the url
  67809. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  67810. * @return the prefiltered texture
  67811. */
  67812. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  67813. /**
  67814. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  67815. * as prefiltered data.
  67816. * @param rootUrl defines the url of the texture or the root name of the six images
  67817. * @param scene defines the scene the texture is attached to
  67818. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  67819. * @param noMipmap defines if mipmaps should be created or not
  67820. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  67821. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  67822. * @param onError defines a callback triggered in case of error during load
  67823. * @param format defines the internal format to use for the texture once loaded
  67824. * @param prefiltered defines whether or not the texture is created from prefiltered data
  67825. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  67826. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  67827. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  67828. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  67829. * @return the cube texture
  67830. */
  67831. 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);
  67832. /**
  67833. * Get the current class name of the texture useful for serialization or dynamic coding.
  67834. * @returns "CubeTexture"
  67835. */
  67836. getClassName(): string;
  67837. /**
  67838. * Update the url (and optional buffer) of this texture if url was null during construction.
  67839. * @param url the url of the texture
  67840. * @param forcedExtension defines the extension to use
  67841. * @param onLoad callback called when the texture is loaded (defaults to null)
  67842. */
  67843. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  67844. /**
  67845. * Delays loading of the cube texture
  67846. * @param forcedExtension defines the extension to use
  67847. */
  67848. delayLoad(forcedExtension?: string): void;
  67849. /**
  67850. * Returns the reflection texture matrix
  67851. * @returns the reflection texture matrix
  67852. */
  67853. getReflectionTextureMatrix(): Matrix;
  67854. /**
  67855. * Sets the reflection texture matrix
  67856. * @param value Reflection texture matrix
  67857. */
  67858. setReflectionTextureMatrix(value: Matrix): void;
  67859. /**
  67860. * Parses text to create a cube texture
  67861. * @param parsedTexture define the serialized text to read from
  67862. * @param scene defines the hosting scene
  67863. * @param rootUrl defines the root url of the cube texture
  67864. * @returns a cube texture
  67865. */
  67866. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  67867. /**
  67868. * Makes a clone, or deep copy, of the cube texture
  67869. * @returns a new cube texture
  67870. */
  67871. clone(): CubeTexture;
  67872. }
  67873. }
  67874. declare module BABYLON {
  67875. /** @hidden */
  67876. export var postprocessVertexShader: {
  67877. name: string;
  67878. shader: string;
  67879. };
  67880. }
  67881. declare module BABYLON {
  67882. /**
  67883. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  67884. * This is the base of the follow, arc rotate cameras and Free camera
  67885. * @see http://doc.babylonjs.com/features/cameras
  67886. */
  67887. export class TargetCamera extends Camera {
  67888. private static _RigCamTransformMatrix;
  67889. private static _TargetTransformMatrix;
  67890. private static _TargetFocalPoint;
  67891. /**
  67892. * Define the current direction the camera is moving to
  67893. */
  67894. cameraDirection: Vector3;
  67895. /**
  67896. * Define the current rotation the camera is rotating to
  67897. */
  67898. cameraRotation: Vector2;
  67899. /**
  67900. * When set, the up vector of the camera will be updated by the rotation of the camera
  67901. */
  67902. updateUpVectorFromRotation: boolean;
  67903. private _tmpQuaternion;
  67904. /**
  67905. * Define the current rotation of the camera
  67906. */
  67907. rotation: Vector3;
  67908. /**
  67909. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  67910. */
  67911. rotationQuaternion: Quaternion;
  67912. /**
  67913. * Define the current speed of the camera
  67914. */
  67915. speed: number;
  67916. /**
  67917. * Add cconstraint to the camera to prevent it to move freely in all directions and
  67918. * around all axis.
  67919. */
  67920. noRotationConstraint: boolean;
  67921. /**
  67922. * Define the current target of the camera as an object or a position.
  67923. */
  67924. lockedTarget: any;
  67925. /** @hidden */
  67926. _currentTarget: Vector3;
  67927. /** @hidden */
  67928. _initialFocalDistance: number;
  67929. /** @hidden */
  67930. _viewMatrix: Matrix;
  67931. /** @hidden */
  67932. _camMatrix: Matrix;
  67933. /** @hidden */
  67934. _cameraTransformMatrix: Matrix;
  67935. /** @hidden */
  67936. _cameraRotationMatrix: Matrix;
  67937. /** @hidden */
  67938. _referencePoint: Vector3;
  67939. /** @hidden */
  67940. _transformedReferencePoint: Vector3;
  67941. protected _globalCurrentTarget: Vector3;
  67942. protected _globalCurrentUpVector: Vector3;
  67943. /** @hidden */
  67944. _reset: () => void;
  67945. private _defaultUp;
  67946. /**
  67947. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  67948. * This is the base of the follow, arc rotate cameras and Free camera
  67949. * @see http://doc.babylonjs.com/features/cameras
  67950. * @param name Defines the name of the camera in the scene
  67951. * @param position Defines the start position of the camera in the scene
  67952. * @param scene Defines the scene the camera belongs to
  67953. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  67954. */
  67955. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  67956. /**
  67957. * Gets the position in front of the camera at a given distance.
  67958. * @param distance The distance from the camera we want the position to be
  67959. * @returns the position
  67960. */
  67961. getFrontPosition(distance: number): Vector3;
  67962. /** @hidden */
  67963. _getLockedTargetPosition(): Nullable<Vector3>;
  67964. private _storedPosition;
  67965. private _storedRotation;
  67966. private _storedRotationQuaternion;
  67967. /**
  67968. * Store current camera state of the camera (fov, position, rotation, etc..)
  67969. * @returns the camera
  67970. */
  67971. storeState(): Camera;
  67972. /**
  67973. * Restored camera state. You must call storeState() first
  67974. * @returns whether it was successful or not
  67975. * @hidden
  67976. */
  67977. _restoreStateValues(): boolean;
  67978. /** @hidden */
  67979. _initCache(): void;
  67980. /** @hidden */
  67981. _updateCache(ignoreParentClass?: boolean): void;
  67982. /** @hidden */
  67983. _isSynchronizedViewMatrix(): boolean;
  67984. /** @hidden */
  67985. _computeLocalCameraSpeed(): number;
  67986. /**
  67987. * Defines the target the camera should look at.
  67988. * This will automatically adapt alpha beta and radius to fit within the new target.
  67989. * @param target Defines the new target as a Vector or a mesh
  67990. */
  67991. setTarget(target: Vector3): void;
  67992. /**
  67993. * Return the current target position of the camera. This value is expressed in local space.
  67994. * @returns the target position
  67995. */
  67996. getTarget(): Vector3;
  67997. /** @hidden */
  67998. _decideIfNeedsToMove(): boolean;
  67999. /** @hidden */
  68000. _updatePosition(): void;
  68001. /** @hidden */
  68002. _checkInputs(): void;
  68003. protected _updateCameraRotationMatrix(): void;
  68004. /**
  68005. * 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)
  68006. * @returns the current camera
  68007. */
  68008. private _rotateUpVectorWithCameraRotationMatrix;
  68009. private _cachedRotationZ;
  68010. private _cachedQuaternionRotationZ;
  68011. /** @hidden */
  68012. _getViewMatrix(): Matrix;
  68013. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  68014. /**
  68015. * @hidden
  68016. */
  68017. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  68018. /**
  68019. * @hidden
  68020. */
  68021. _updateRigCameras(): void;
  68022. private _getRigCamPositionAndTarget;
  68023. /**
  68024. * Gets the current object class name.
  68025. * @return the class name
  68026. */
  68027. getClassName(): string;
  68028. }
  68029. }
  68030. declare module BABYLON {
  68031. /**
  68032. * @ignore
  68033. * This is a list of all the different input types that are available in the application.
  68034. * Fo instance: ArcRotateCameraGamepadInput...
  68035. */
  68036. export var CameraInputTypes: {};
  68037. /**
  68038. * This is the contract to implement in order to create a new input class.
  68039. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  68040. */
  68041. export interface ICameraInput<TCamera extends Camera> {
  68042. /**
  68043. * Defines the camera the input is attached to.
  68044. */
  68045. camera: Nullable<TCamera>;
  68046. /**
  68047. * Gets the class name of the current intput.
  68048. * @returns the class name
  68049. */
  68050. getClassName(): string;
  68051. /**
  68052. * Get the friendly name associated with the input class.
  68053. * @returns the input friendly name
  68054. */
  68055. getSimpleName(): string;
  68056. /**
  68057. * Attach the input controls to a specific dom element to get the input from.
  68058. * @param element Defines the element the controls should be listened from
  68059. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68060. */
  68061. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68062. /**
  68063. * Detach the current controls from the specified dom element.
  68064. * @param element Defines the element to stop listening the inputs from
  68065. */
  68066. detachControl(element: Nullable<HTMLElement>): void;
  68067. /**
  68068. * Update the current camera state depending on the inputs that have been used this frame.
  68069. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68070. */
  68071. checkInputs?: () => void;
  68072. }
  68073. /**
  68074. * Represents a map of input types to input instance or input index to input instance.
  68075. */
  68076. export interface CameraInputsMap<TCamera extends Camera> {
  68077. /**
  68078. * Accessor to the input by input type.
  68079. */
  68080. [name: string]: ICameraInput<TCamera>;
  68081. /**
  68082. * Accessor to the input by input index.
  68083. */
  68084. [idx: number]: ICameraInput<TCamera>;
  68085. }
  68086. /**
  68087. * This represents the input manager used within a camera.
  68088. * It helps dealing with all the different kind of input attached to a camera.
  68089. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68090. */
  68091. export class CameraInputsManager<TCamera extends Camera> {
  68092. /**
  68093. * Defines the list of inputs attahed to the camera.
  68094. */
  68095. attached: CameraInputsMap<TCamera>;
  68096. /**
  68097. * Defines the dom element the camera is collecting inputs from.
  68098. * This is null if the controls have not been attached.
  68099. */
  68100. attachedElement: Nullable<HTMLElement>;
  68101. /**
  68102. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68103. */
  68104. noPreventDefault: boolean;
  68105. /**
  68106. * Defined the camera the input manager belongs to.
  68107. */
  68108. camera: TCamera;
  68109. /**
  68110. * Update the current camera state depending on the inputs that have been used this frame.
  68111. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68112. */
  68113. checkInputs: () => void;
  68114. /**
  68115. * Instantiate a new Camera Input Manager.
  68116. * @param camera Defines the camera the input manager blongs to
  68117. */
  68118. constructor(camera: TCamera);
  68119. /**
  68120. * Add an input method to a camera
  68121. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68122. * @param input camera input method
  68123. */
  68124. add(input: ICameraInput<TCamera>): void;
  68125. /**
  68126. * Remove a specific input method from a camera
  68127. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  68128. * @param inputToRemove camera input method
  68129. */
  68130. remove(inputToRemove: ICameraInput<TCamera>): void;
  68131. /**
  68132. * Remove a specific input type from a camera
  68133. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  68134. * @param inputType the type of the input to remove
  68135. */
  68136. removeByType(inputType: string): void;
  68137. private _addCheckInputs;
  68138. /**
  68139. * Attach the input controls to the currently attached dom element to listen the events from.
  68140. * @param input Defines the input to attach
  68141. */
  68142. attachInput(input: ICameraInput<TCamera>): void;
  68143. /**
  68144. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  68145. * @param element Defines the dom element to collect the events from
  68146. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68147. */
  68148. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  68149. /**
  68150. * Detach the current manager inputs controls from a specific dom element.
  68151. * @param element Defines the dom element to collect the events from
  68152. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  68153. */
  68154. detachElement(element: HTMLElement, disconnect?: boolean): void;
  68155. /**
  68156. * Rebuild the dynamic inputCheck function from the current list of
  68157. * defined inputs in the manager.
  68158. */
  68159. rebuildInputCheck(): void;
  68160. /**
  68161. * Remove all attached input methods from a camera
  68162. */
  68163. clear(): void;
  68164. /**
  68165. * Serialize the current input manager attached to a camera.
  68166. * This ensures than once parsed,
  68167. * the input associated to the camera will be identical to the current ones
  68168. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  68169. */
  68170. serialize(serializedCamera: any): void;
  68171. /**
  68172. * Parses an input manager serialized JSON to restore the previous list of inputs
  68173. * and states associated to a camera.
  68174. * @param parsedCamera Defines the JSON to parse
  68175. */
  68176. parse(parsedCamera: any): void;
  68177. }
  68178. }
  68179. declare module BABYLON {
  68180. /**
  68181. * Gather the list of keyboard event types as constants.
  68182. */
  68183. export class KeyboardEventTypes {
  68184. /**
  68185. * The keydown event is fired when a key becomes active (pressed).
  68186. */
  68187. static readonly KEYDOWN: number;
  68188. /**
  68189. * The keyup event is fired when a key has been released.
  68190. */
  68191. static readonly KEYUP: number;
  68192. }
  68193. /**
  68194. * This class is used to store keyboard related info for the onKeyboardObservable event.
  68195. */
  68196. export class KeyboardInfo {
  68197. /**
  68198. * Defines the type of event (KeyboardEventTypes)
  68199. */
  68200. type: number;
  68201. /**
  68202. * Defines the related dom event
  68203. */
  68204. event: KeyboardEvent;
  68205. /**
  68206. * Instantiates a new keyboard info.
  68207. * This class is used to store keyboard related info for the onKeyboardObservable event.
  68208. * @param type Defines the type of event (KeyboardEventTypes)
  68209. * @param event Defines the related dom event
  68210. */
  68211. constructor(
  68212. /**
  68213. * Defines the type of event (KeyboardEventTypes)
  68214. */
  68215. type: number,
  68216. /**
  68217. * Defines the related dom event
  68218. */
  68219. event: KeyboardEvent);
  68220. }
  68221. /**
  68222. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  68223. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  68224. */
  68225. export class KeyboardInfoPre extends KeyboardInfo {
  68226. /**
  68227. * Defines the type of event (KeyboardEventTypes)
  68228. */
  68229. type: number;
  68230. /**
  68231. * Defines the related dom event
  68232. */
  68233. event: KeyboardEvent;
  68234. /**
  68235. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  68236. */
  68237. skipOnPointerObservable: boolean;
  68238. /**
  68239. * Instantiates a new keyboard pre info.
  68240. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  68241. * @param type Defines the type of event (KeyboardEventTypes)
  68242. * @param event Defines the related dom event
  68243. */
  68244. constructor(
  68245. /**
  68246. * Defines the type of event (KeyboardEventTypes)
  68247. */
  68248. type: number,
  68249. /**
  68250. * Defines the related dom event
  68251. */
  68252. event: KeyboardEvent);
  68253. }
  68254. }
  68255. declare module BABYLON {
  68256. /**
  68257. * Manage the keyboard inputs to control the movement of a free camera.
  68258. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68259. */
  68260. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  68261. /**
  68262. * Defines the camera the input is attached to.
  68263. */
  68264. camera: FreeCamera;
  68265. /**
  68266. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  68267. */
  68268. keysUp: number[];
  68269. /**
  68270. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  68271. */
  68272. keysDown: number[];
  68273. /**
  68274. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  68275. */
  68276. keysLeft: number[];
  68277. /**
  68278. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  68279. */
  68280. keysRight: number[];
  68281. private _keys;
  68282. private _onCanvasBlurObserver;
  68283. private _onKeyboardObserver;
  68284. private _engine;
  68285. private _scene;
  68286. /**
  68287. * Attach the input controls to a specific dom element to get the input from.
  68288. * @param element Defines the element the controls should be listened from
  68289. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68290. */
  68291. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68292. /**
  68293. * Detach the current controls from the specified dom element.
  68294. * @param element Defines the element to stop listening the inputs from
  68295. */
  68296. detachControl(element: Nullable<HTMLElement>): void;
  68297. /**
  68298. * Update the current camera state depending on the inputs that have been used this frame.
  68299. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68300. */
  68301. checkInputs(): void;
  68302. /**
  68303. * Gets the class name of the current intput.
  68304. * @returns the class name
  68305. */
  68306. getClassName(): string;
  68307. /** @hidden */
  68308. _onLostFocus(): void;
  68309. /**
  68310. * Get the friendly name associated with the input class.
  68311. * @returns the input friendly name
  68312. */
  68313. getSimpleName(): string;
  68314. }
  68315. }
  68316. declare module BABYLON {
  68317. /**
  68318. * Interface describing all the common properties and methods a shadow light needs to implement.
  68319. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  68320. * as well as binding the different shadow properties to the effects.
  68321. */
  68322. export interface IShadowLight extends Light {
  68323. /**
  68324. * The light id in the scene (used in scene.findLighById for instance)
  68325. */
  68326. id: string;
  68327. /**
  68328. * The position the shdow will be casted from.
  68329. */
  68330. position: Vector3;
  68331. /**
  68332. * In 2d mode (needCube being false), the direction used to cast the shadow.
  68333. */
  68334. direction: Vector3;
  68335. /**
  68336. * The transformed position. Position of the light in world space taking parenting in account.
  68337. */
  68338. transformedPosition: Vector3;
  68339. /**
  68340. * The transformed direction. Direction of the light in world space taking parenting in account.
  68341. */
  68342. transformedDirection: Vector3;
  68343. /**
  68344. * The friendly name of the light in the scene.
  68345. */
  68346. name: string;
  68347. /**
  68348. * Defines the shadow projection clipping minimum z value.
  68349. */
  68350. shadowMinZ: number;
  68351. /**
  68352. * Defines the shadow projection clipping maximum z value.
  68353. */
  68354. shadowMaxZ: number;
  68355. /**
  68356. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  68357. * @returns true if the information has been computed, false if it does not need to (no parenting)
  68358. */
  68359. computeTransformedInformation(): boolean;
  68360. /**
  68361. * Gets the scene the light belongs to.
  68362. * @returns The scene
  68363. */
  68364. getScene(): Scene;
  68365. /**
  68366. * Callback defining a custom Projection Matrix Builder.
  68367. * This can be used to override the default projection matrix computation.
  68368. */
  68369. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  68370. /**
  68371. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  68372. * @param matrix The materix to updated with the projection information
  68373. * @param viewMatrix The transform matrix of the light
  68374. * @param renderList The list of mesh to render in the map
  68375. * @returns The current light
  68376. */
  68377. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  68378. /**
  68379. * Gets the current depth scale used in ESM.
  68380. * @returns The scale
  68381. */
  68382. getDepthScale(): number;
  68383. /**
  68384. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  68385. * @returns true if a cube texture needs to be use
  68386. */
  68387. needCube(): boolean;
  68388. /**
  68389. * Detects if the projection matrix requires to be recomputed this frame.
  68390. * @returns true if it requires to be recomputed otherwise, false.
  68391. */
  68392. needProjectionMatrixCompute(): boolean;
  68393. /**
  68394. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  68395. */
  68396. forceProjectionMatrixCompute(): void;
  68397. /**
  68398. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  68399. * @param faceIndex The index of the face we are computed the direction to generate shadow
  68400. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  68401. */
  68402. getShadowDirection(faceIndex?: number): Vector3;
  68403. /**
  68404. * Gets the minZ used for shadow according to both the scene and the light.
  68405. * @param activeCamera The camera we are returning the min for
  68406. * @returns the depth min z
  68407. */
  68408. getDepthMinZ(activeCamera: Camera): number;
  68409. /**
  68410. * Gets the maxZ used for shadow according to both the scene and the light.
  68411. * @param activeCamera The camera we are returning the max for
  68412. * @returns the depth max z
  68413. */
  68414. getDepthMaxZ(activeCamera: Camera): number;
  68415. }
  68416. /**
  68417. * Base implementation IShadowLight
  68418. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  68419. */
  68420. export abstract class ShadowLight extends Light implements IShadowLight {
  68421. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  68422. protected _position: Vector3;
  68423. protected _setPosition(value: Vector3): void;
  68424. /**
  68425. * Sets the position the shadow will be casted from. Also use as the light position for both
  68426. * point and spot lights.
  68427. */
  68428. /**
  68429. * Sets the position the shadow will be casted from. Also use as the light position for both
  68430. * point and spot lights.
  68431. */
  68432. position: Vector3;
  68433. protected _direction: Vector3;
  68434. protected _setDirection(value: Vector3): void;
  68435. /**
  68436. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  68437. * Also use as the light direction on spot and directional lights.
  68438. */
  68439. /**
  68440. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  68441. * Also use as the light direction on spot and directional lights.
  68442. */
  68443. direction: Vector3;
  68444. private _shadowMinZ;
  68445. /**
  68446. * Gets the shadow projection clipping minimum z value.
  68447. */
  68448. /**
  68449. * Sets the shadow projection clipping minimum z value.
  68450. */
  68451. shadowMinZ: number;
  68452. private _shadowMaxZ;
  68453. /**
  68454. * Sets the shadow projection clipping maximum z value.
  68455. */
  68456. /**
  68457. * Gets the shadow projection clipping maximum z value.
  68458. */
  68459. shadowMaxZ: number;
  68460. /**
  68461. * Callback defining a custom Projection Matrix Builder.
  68462. * This can be used to override the default projection matrix computation.
  68463. */
  68464. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  68465. /**
  68466. * The transformed position. Position of the light in world space taking parenting in account.
  68467. */
  68468. transformedPosition: Vector3;
  68469. /**
  68470. * The transformed direction. Direction of the light in world space taking parenting in account.
  68471. */
  68472. transformedDirection: Vector3;
  68473. private _needProjectionMatrixCompute;
  68474. /**
  68475. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  68476. * @returns true if the information has been computed, false if it does not need to (no parenting)
  68477. */
  68478. computeTransformedInformation(): boolean;
  68479. /**
  68480. * Return the depth scale used for the shadow map.
  68481. * @returns the depth scale.
  68482. */
  68483. getDepthScale(): number;
  68484. /**
  68485. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  68486. * @param faceIndex The index of the face we are computed the direction to generate shadow
  68487. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  68488. */
  68489. getShadowDirection(faceIndex?: number): Vector3;
  68490. /**
  68491. * Returns the ShadowLight absolute position in the World.
  68492. * @returns the position vector in world space
  68493. */
  68494. getAbsolutePosition(): Vector3;
  68495. /**
  68496. * Sets the ShadowLight direction toward the passed target.
  68497. * @param target The point to target in local space
  68498. * @returns the updated ShadowLight direction
  68499. */
  68500. setDirectionToTarget(target: Vector3): Vector3;
  68501. /**
  68502. * Returns the light rotation in euler definition.
  68503. * @returns the x y z rotation in local space.
  68504. */
  68505. getRotation(): Vector3;
  68506. /**
  68507. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  68508. * @returns true if a cube texture needs to be use
  68509. */
  68510. needCube(): boolean;
  68511. /**
  68512. * Detects if the projection matrix requires to be recomputed this frame.
  68513. * @returns true if it requires to be recomputed otherwise, false.
  68514. */
  68515. needProjectionMatrixCompute(): boolean;
  68516. /**
  68517. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  68518. */
  68519. forceProjectionMatrixCompute(): void;
  68520. /** @hidden */
  68521. _initCache(): void;
  68522. /** @hidden */
  68523. _isSynchronized(): boolean;
  68524. /**
  68525. * Computes the world matrix of the node
  68526. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  68527. * @returns the world matrix
  68528. */
  68529. computeWorldMatrix(force?: boolean): Matrix;
  68530. /**
  68531. * Gets the minZ used for shadow according to both the scene and the light.
  68532. * @param activeCamera The camera we are returning the min for
  68533. * @returns the depth min z
  68534. */
  68535. getDepthMinZ(activeCamera: Camera): number;
  68536. /**
  68537. * Gets the maxZ used for shadow according to both the scene and the light.
  68538. * @param activeCamera The camera we are returning the max for
  68539. * @returns the depth max z
  68540. */
  68541. getDepthMaxZ(activeCamera: Camera): number;
  68542. /**
  68543. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  68544. * @param matrix The materix to updated with the projection information
  68545. * @param viewMatrix The transform matrix of the light
  68546. * @param renderList The list of mesh to render in the map
  68547. * @returns The current light
  68548. */
  68549. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  68550. }
  68551. }
  68552. declare module BABYLON {
  68553. /**
  68554. * "Static Class" containing the most commonly used helper while dealing with material for
  68555. * rendering purpose.
  68556. *
  68557. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  68558. *
  68559. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  68560. */
  68561. export class MaterialHelper {
  68562. /**
  68563. * Bind the current view position to an effect.
  68564. * @param effect The effect to be bound
  68565. * @param scene The scene the eyes position is used from
  68566. */
  68567. static BindEyePosition(effect: Effect, scene: Scene): void;
  68568. /**
  68569. * Helps preparing the defines values about the UVs in used in the effect.
  68570. * UVs are shared as much as we can accross channels in the shaders.
  68571. * @param texture The texture we are preparing the UVs for
  68572. * @param defines The defines to update
  68573. * @param key The channel key "diffuse", "specular"... used in the shader
  68574. */
  68575. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  68576. /**
  68577. * Binds a texture matrix value to its corrsponding uniform
  68578. * @param texture The texture to bind the matrix for
  68579. * @param uniformBuffer The uniform buffer receivin the data
  68580. * @param key The channel key "diffuse", "specular"... used in the shader
  68581. */
  68582. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  68583. /**
  68584. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  68585. * @param mesh defines the current mesh
  68586. * @param scene defines the current scene
  68587. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  68588. * @param pointsCloud defines if point cloud rendering has to be turned on
  68589. * @param fogEnabled defines if fog has to be turned on
  68590. * @param alphaTest defines if alpha testing has to be turned on
  68591. * @param defines defines the current list of defines
  68592. */
  68593. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  68594. /**
  68595. * Helper used to prepare the list of defines associated with frame values for shader compilation
  68596. * @param scene defines the current scene
  68597. * @param engine defines the current engine
  68598. * @param defines specifies the list of active defines
  68599. * @param useInstances defines if instances have to be turned on
  68600. * @param useClipPlane defines if clip plane have to be turned on
  68601. */
  68602. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  68603. /**
  68604. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  68605. * @param mesh The mesh containing the geometry data we will draw
  68606. * @param defines The defines to update
  68607. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  68608. * @param useBones Precise whether bones should be used or not (override mesh info)
  68609. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  68610. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  68611. * @returns false if defines are considered not dirty and have not been checked
  68612. */
  68613. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  68614. /**
  68615. * Prepares the defines related to multiview
  68616. * @param scene The scene we are intending to draw
  68617. * @param defines The defines to update
  68618. */
  68619. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  68620. /**
  68621. * Prepares the defines related to the light information passed in parameter
  68622. * @param scene The scene we are intending to draw
  68623. * @param mesh The mesh the effect is compiling for
  68624. * @param defines The defines to update
  68625. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  68626. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  68627. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  68628. * @returns true if normals will be required for the rest of the effect
  68629. */
  68630. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  68631. /**
  68632. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  68633. * that won t be acctive due to defines being turned off.
  68634. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  68635. * @param samplersList The samplers list
  68636. * @param defines The defines helping in the list generation
  68637. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  68638. */
  68639. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  68640. /**
  68641. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  68642. * @param defines The defines to update while falling back
  68643. * @param fallbacks The authorized effect fallbacks
  68644. * @param maxSimultaneousLights The maximum number of lights allowed
  68645. * @param rank the current rank of the Effect
  68646. * @returns The newly affected rank
  68647. */
  68648. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  68649. /**
  68650. * Prepares the list of attributes required for morph targets according to the effect defines.
  68651. * @param attribs The current list of supported attribs
  68652. * @param mesh The mesh to prepare the morph targets attributes for
  68653. * @param defines The current Defines of the effect
  68654. */
  68655. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  68656. /**
  68657. * Prepares the list of attributes required for bones according to the effect defines.
  68658. * @param attribs The current list of supported attribs
  68659. * @param mesh The mesh to prepare the bones attributes for
  68660. * @param defines The current Defines of the effect
  68661. * @param fallbacks The current efffect fallback strategy
  68662. */
  68663. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  68664. /**
  68665. * Prepares the list of attributes required for instances according to the effect defines.
  68666. * @param attribs The current list of supported attribs
  68667. * @param defines The current Defines of the effect
  68668. */
  68669. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  68670. /**
  68671. * Binds the light shadow information to the effect for the given mesh.
  68672. * @param light The light containing the generator
  68673. * @param scene The scene the lights belongs to
  68674. * @param mesh The mesh we are binding the information to render
  68675. * @param lightIndex The light index in the effect used to render the mesh
  68676. * @param effect The effect we are binding the data to
  68677. */
  68678. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  68679. /**
  68680. * Binds the light information to the effect.
  68681. * @param light The light containing the generator
  68682. * @param effect The effect we are binding the data to
  68683. * @param lightIndex The light index in the effect used to render
  68684. */
  68685. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  68686. /**
  68687. * Binds the lights information from the scene to the effect for the given mesh.
  68688. * @param scene The scene the lights belongs to
  68689. * @param mesh The mesh we are binding the information to render
  68690. * @param effect The effect we are binding the data to
  68691. * @param defines The generated defines for the effect
  68692. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  68693. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  68694. */
  68695. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  68696. private static _tempFogColor;
  68697. /**
  68698. * Binds the fog information from the scene to the effect for the given mesh.
  68699. * @param scene The scene the lights belongs to
  68700. * @param mesh The mesh we are binding the information to render
  68701. * @param effect The effect we are binding the data to
  68702. * @param linearSpace Defines if the fog effect is applied in linear space
  68703. */
  68704. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  68705. /**
  68706. * Binds the bones information from the mesh to the effect.
  68707. * @param mesh The mesh we are binding the information to render
  68708. * @param effect The effect we are binding the data to
  68709. */
  68710. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  68711. /**
  68712. * Binds the morph targets information from the mesh to the effect.
  68713. * @param abstractMesh The mesh we are binding the information to render
  68714. * @param effect The effect we are binding the data to
  68715. */
  68716. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  68717. /**
  68718. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  68719. * @param defines The generated defines used in the effect
  68720. * @param effect The effect we are binding the data to
  68721. * @param scene The scene we are willing to render with logarithmic scale for
  68722. */
  68723. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  68724. /**
  68725. * Binds the clip plane information from the scene to the effect.
  68726. * @param scene The scene the clip plane information are extracted from
  68727. * @param effect The effect we are binding the data to
  68728. */
  68729. static BindClipPlane(effect: Effect, scene: Scene): void;
  68730. }
  68731. }
  68732. declare module BABYLON {
  68733. /** @hidden */
  68734. export var kernelBlurVaryingDeclaration: {
  68735. name: string;
  68736. shader: string;
  68737. };
  68738. }
  68739. declare module BABYLON {
  68740. /** @hidden */
  68741. export var kernelBlurFragment: {
  68742. name: string;
  68743. shader: string;
  68744. };
  68745. }
  68746. declare module BABYLON {
  68747. /** @hidden */
  68748. export var kernelBlurFragment2: {
  68749. name: string;
  68750. shader: string;
  68751. };
  68752. }
  68753. declare module BABYLON {
  68754. /** @hidden */
  68755. export var kernelBlurPixelShader: {
  68756. name: string;
  68757. shader: string;
  68758. };
  68759. }
  68760. declare module BABYLON {
  68761. /** @hidden */
  68762. export var kernelBlurVertex: {
  68763. name: string;
  68764. shader: string;
  68765. };
  68766. }
  68767. declare module BABYLON {
  68768. /** @hidden */
  68769. export var kernelBlurVertexShader: {
  68770. name: string;
  68771. shader: string;
  68772. };
  68773. }
  68774. declare module BABYLON {
  68775. /**
  68776. * The Blur Post Process which blurs an image based on a kernel and direction.
  68777. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  68778. */
  68779. export class BlurPostProcess extends PostProcess {
  68780. /** The direction in which to blur the image. */
  68781. direction: Vector2;
  68782. private blockCompilation;
  68783. protected _kernel: number;
  68784. protected _idealKernel: number;
  68785. protected _packedFloat: boolean;
  68786. private _staticDefines;
  68787. /**
  68788. * Sets the length in pixels of the blur sample region
  68789. */
  68790. /**
  68791. * Gets the length in pixels of the blur sample region
  68792. */
  68793. kernel: number;
  68794. /**
  68795. * Sets wether or not the blur needs to unpack/repack floats
  68796. */
  68797. /**
  68798. * Gets wether or not the blur is unpacking/repacking floats
  68799. */
  68800. packedFloat: boolean;
  68801. /**
  68802. * Creates a new instance BlurPostProcess
  68803. * @param name The name of the effect.
  68804. * @param direction The direction in which to blur the image.
  68805. * @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.
  68806. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  68807. * @param camera The camera to apply the render pass to.
  68808. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68809. * @param engine The engine which the post process will be applied. (default: current engine)
  68810. * @param reusable If the post process can be reused on the same frame. (default: false)
  68811. * @param textureType Type of textures used when performing the post process. (default: 0)
  68812. * @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)
  68813. */
  68814. constructor(name: string,
  68815. /** The direction in which to blur the image. */
  68816. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  68817. /**
  68818. * Updates the effect with the current post process compile time values and recompiles the shader.
  68819. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  68820. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  68821. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  68822. * @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
  68823. * @param onCompiled Called when the shader has been compiled.
  68824. * @param onError Called if there is an error when compiling a shader.
  68825. */
  68826. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68827. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68828. /**
  68829. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  68830. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  68831. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  68832. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  68833. * The gaps between physical kernels are compensated for in the weighting of the samples
  68834. * @param idealKernel Ideal blur kernel.
  68835. * @return Nearest best kernel.
  68836. */
  68837. protected _nearestBestKernel(idealKernel: number): number;
  68838. /**
  68839. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  68840. * @param x The point on the Gaussian distribution to sample.
  68841. * @return the value of the Gaussian function at x.
  68842. */
  68843. protected _gaussianWeight(x: number): number;
  68844. /**
  68845. * Generates a string that can be used as a floating point number in GLSL.
  68846. * @param x Value to print.
  68847. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  68848. * @return GLSL float string.
  68849. */
  68850. protected _glslFloat(x: number, decimalFigures?: number): string;
  68851. }
  68852. }
  68853. declare module BABYLON {
  68854. /** @hidden */
  68855. export var shadowMapPixelShader: {
  68856. name: string;
  68857. shader: string;
  68858. };
  68859. }
  68860. declare module BABYLON {
  68861. /** @hidden */
  68862. export var bonesDeclaration: {
  68863. name: string;
  68864. shader: string;
  68865. };
  68866. }
  68867. declare module BABYLON {
  68868. /** @hidden */
  68869. export var morphTargetsVertexGlobalDeclaration: {
  68870. name: string;
  68871. shader: string;
  68872. };
  68873. }
  68874. declare module BABYLON {
  68875. /** @hidden */
  68876. export var morphTargetsVertexDeclaration: {
  68877. name: string;
  68878. shader: string;
  68879. };
  68880. }
  68881. declare module BABYLON {
  68882. /** @hidden */
  68883. export var instancesDeclaration: {
  68884. name: string;
  68885. shader: string;
  68886. };
  68887. }
  68888. declare module BABYLON {
  68889. /** @hidden */
  68890. export var helperFunctions: {
  68891. name: string;
  68892. shader: string;
  68893. };
  68894. }
  68895. declare module BABYLON {
  68896. /** @hidden */
  68897. export var morphTargetsVertex: {
  68898. name: string;
  68899. shader: string;
  68900. };
  68901. }
  68902. declare module BABYLON {
  68903. /** @hidden */
  68904. export var instancesVertex: {
  68905. name: string;
  68906. shader: string;
  68907. };
  68908. }
  68909. declare module BABYLON {
  68910. /** @hidden */
  68911. export var bonesVertex: {
  68912. name: string;
  68913. shader: string;
  68914. };
  68915. }
  68916. declare module BABYLON {
  68917. /** @hidden */
  68918. export var shadowMapVertexShader: {
  68919. name: string;
  68920. shader: string;
  68921. };
  68922. }
  68923. declare module BABYLON {
  68924. /** @hidden */
  68925. export var depthBoxBlurPixelShader: {
  68926. name: string;
  68927. shader: string;
  68928. };
  68929. }
  68930. declare module BABYLON {
  68931. /**
  68932. * Defines the options associated with the creation of a custom shader for a shadow generator.
  68933. */
  68934. export interface ICustomShaderOptions {
  68935. /**
  68936. * Gets or sets the custom shader name to use
  68937. */
  68938. shaderName: string;
  68939. /**
  68940. * The list of attribute names used in the shader
  68941. */
  68942. attributes?: string[];
  68943. /**
  68944. * The list of unifrom names used in the shader
  68945. */
  68946. uniforms?: string[];
  68947. /**
  68948. * The list of sampler names used in the shader
  68949. */
  68950. samplers?: string[];
  68951. /**
  68952. * The list of defines used in the shader
  68953. */
  68954. defines?: string[];
  68955. }
  68956. /**
  68957. * Interface to implement to create a shadow generator compatible with BJS.
  68958. */
  68959. export interface IShadowGenerator {
  68960. /**
  68961. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  68962. * @returns The render target texture if present otherwise, null
  68963. */
  68964. getShadowMap(): Nullable<RenderTargetTexture>;
  68965. /**
  68966. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  68967. * @returns The render target texture if the shadow map is present otherwise, null
  68968. */
  68969. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  68970. /**
  68971. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  68972. * @param subMesh The submesh we want to render in the shadow map
  68973. * @param useInstances Defines wether will draw in the map using instances
  68974. * @returns true if ready otherwise, false
  68975. */
  68976. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68977. /**
  68978. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  68979. * @param defines Defines of the material we want to update
  68980. * @param lightIndex Index of the light in the enabled light list of the material
  68981. */
  68982. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  68983. /**
  68984. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  68985. * defined in the generator but impacting the effect).
  68986. * It implies the unifroms available on the materials are the standard BJS ones.
  68987. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  68988. * @param effect The effect we are binfing the information for
  68989. */
  68990. bindShadowLight(lightIndex: string, effect: Effect): void;
  68991. /**
  68992. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  68993. * (eq to shadow prjection matrix * light transform matrix)
  68994. * @returns The transform matrix used to create the shadow map
  68995. */
  68996. getTransformMatrix(): Matrix;
  68997. /**
  68998. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  68999. * Cube and 2D textures for instance.
  69000. */
  69001. recreateShadowMap(): void;
  69002. /**
  69003. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69004. * @param onCompiled Callback triggered at the and of the effects compilation
  69005. * @param options Sets of optional options forcing the compilation with different modes
  69006. */
  69007. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  69008. useInstances: boolean;
  69009. }>): void;
  69010. /**
  69011. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69012. * @param options Sets of optional options forcing the compilation with different modes
  69013. * @returns A promise that resolves when the compilation completes
  69014. */
  69015. forceCompilationAsync(options?: Partial<{
  69016. useInstances: boolean;
  69017. }>): Promise<void>;
  69018. /**
  69019. * Serializes the shadow generator setup to a json object.
  69020. * @returns The serialized JSON object
  69021. */
  69022. serialize(): any;
  69023. /**
  69024. * Disposes the Shadow map and related Textures and effects.
  69025. */
  69026. dispose(): void;
  69027. }
  69028. /**
  69029. * Default implementation IShadowGenerator.
  69030. * This is the main object responsible of generating shadows in the framework.
  69031. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  69032. */
  69033. export class ShadowGenerator implements IShadowGenerator {
  69034. /**
  69035. * Shadow generator mode None: no filtering applied.
  69036. */
  69037. static readonly FILTER_NONE: number;
  69038. /**
  69039. * Shadow generator mode ESM: Exponential Shadow Mapping.
  69040. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69041. */
  69042. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  69043. /**
  69044. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  69045. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  69046. */
  69047. static readonly FILTER_POISSONSAMPLING: number;
  69048. /**
  69049. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  69050. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69051. */
  69052. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  69053. /**
  69054. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  69055. * edge artifacts on steep falloff.
  69056. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69057. */
  69058. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  69059. /**
  69060. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  69061. * edge artifacts on steep falloff.
  69062. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69063. */
  69064. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  69065. /**
  69066. * Shadow generator mode PCF: Percentage Closer Filtering
  69067. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  69068. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  69069. */
  69070. static readonly FILTER_PCF: number;
  69071. /**
  69072. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  69073. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  69074. * Contact Hardening
  69075. */
  69076. static readonly FILTER_PCSS: number;
  69077. /**
  69078. * Reserved for PCF and PCSS
  69079. * Highest Quality.
  69080. *
  69081. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  69082. *
  69083. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  69084. */
  69085. static readonly QUALITY_HIGH: number;
  69086. /**
  69087. * Reserved for PCF and PCSS
  69088. * Good tradeoff for quality/perf cross devices
  69089. *
  69090. * Execute PCF on a 3*3 kernel.
  69091. *
  69092. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  69093. */
  69094. static readonly QUALITY_MEDIUM: number;
  69095. /**
  69096. * Reserved for PCF and PCSS
  69097. * The lowest quality but the fastest.
  69098. *
  69099. * Execute PCF on a 1*1 kernel.
  69100. *
  69101. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  69102. */
  69103. static readonly QUALITY_LOW: number;
  69104. /** Gets or sets the custom shader name to use */
  69105. customShaderOptions: ICustomShaderOptions;
  69106. /**
  69107. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  69108. */
  69109. onBeforeShadowMapRenderObservable: Observable<Effect>;
  69110. /**
  69111. * Observable triggered before a mesh is rendered in the shadow map.
  69112. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  69113. */
  69114. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  69115. private _bias;
  69116. /**
  69117. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  69118. */
  69119. /**
  69120. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  69121. */
  69122. bias: number;
  69123. private _normalBias;
  69124. /**
  69125. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  69126. */
  69127. /**
  69128. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  69129. */
  69130. normalBias: number;
  69131. private _blurBoxOffset;
  69132. /**
  69133. * Gets the blur box offset: offset applied during the blur pass.
  69134. * Only useful if useKernelBlur = false
  69135. */
  69136. /**
  69137. * Sets the blur box offset: offset applied during the blur pass.
  69138. * Only useful if useKernelBlur = false
  69139. */
  69140. blurBoxOffset: number;
  69141. private _blurScale;
  69142. /**
  69143. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  69144. * 2 means half of the size.
  69145. */
  69146. /**
  69147. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  69148. * 2 means half of the size.
  69149. */
  69150. blurScale: number;
  69151. private _blurKernel;
  69152. /**
  69153. * Gets the blur kernel: kernel size of the blur pass.
  69154. * Only useful if useKernelBlur = true
  69155. */
  69156. /**
  69157. * Sets the blur kernel: kernel size of the blur pass.
  69158. * Only useful if useKernelBlur = true
  69159. */
  69160. blurKernel: number;
  69161. private _useKernelBlur;
  69162. /**
  69163. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  69164. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  69165. */
  69166. /**
  69167. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  69168. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  69169. */
  69170. useKernelBlur: boolean;
  69171. private _depthScale;
  69172. /**
  69173. * Gets the depth scale used in ESM mode.
  69174. */
  69175. /**
  69176. * Sets the depth scale used in ESM mode.
  69177. * This can override the scale stored on the light.
  69178. */
  69179. depthScale: number;
  69180. private _filter;
  69181. /**
  69182. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  69183. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  69184. */
  69185. /**
  69186. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  69187. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  69188. */
  69189. filter: number;
  69190. /**
  69191. * Gets if the current filter is set to Poisson Sampling.
  69192. */
  69193. /**
  69194. * Sets the current filter to Poisson Sampling.
  69195. */
  69196. usePoissonSampling: boolean;
  69197. /**
  69198. * Gets if the current filter is set to ESM.
  69199. */
  69200. /**
  69201. * Sets the current filter is to ESM.
  69202. */
  69203. useExponentialShadowMap: boolean;
  69204. /**
  69205. * Gets if the current filter is set to filtered ESM.
  69206. */
  69207. /**
  69208. * Gets if the current filter is set to filtered ESM.
  69209. */
  69210. useBlurExponentialShadowMap: boolean;
  69211. /**
  69212. * Gets if the current filter is set to "close ESM" (using the inverse of the
  69213. * exponential to prevent steep falloff artifacts).
  69214. */
  69215. /**
  69216. * Sets the current filter to "close ESM" (using the inverse of the
  69217. * exponential to prevent steep falloff artifacts).
  69218. */
  69219. useCloseExponentialShadowMap: boolean;
  69220. /**
  69221. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  69222. * exponential to prevent steep falloff artifacts).
  69223. */
  69224. /**
  69225. * Sets the current filter to filtered "close ESM" (using the inverse of the
  69226. * exponential to prevent steep falloff artifacts).
  69227. */
  69228. useBlurCloseExponentialShadowMap: boolean;
  69229. /**
  69230. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  69231. */
  69232. /**
  69233. * Sets the current filter to "PCF" (percentage closer filtering).
  69234. */
  69235. usePercentageCloserFiltering: boolean;
  69236. private _filteringQuality;
  69237. /**
  69238. * Gets the PCF or PCSS Quality.
  69239. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  69240. */
  69241. /**
  69242. * Sets the PCF or PCSS Quality.
  69243. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  69244. */
  69245. filteringQuality: number;
  69246. /**
  69247. * Gets if the current filter is set to "PCSS" (contact hardening).
  69248. */
  69249. /**
  69250. * Sets the current filter to "PCSS" (contact hardening).
  69251. */
  69252. useContactHardeningShadow: boolean;
  69253. private _contactHardeningLightSizeUVRatio;
  69254. /**
  69255. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  69256. * Using a ratio helps keeping shape stability independently of the map size.
  69257. *
  69258. * It does not account for the light projection as it was having too much
  69259. * instability during the light setup or during light position changes.
  69260. *
  69261. * Only valid if useContactHardeningShadow is true.
  69262. */
  69263. /**
  69264. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  69265. * Using a ratio helps keeping shape stability independently of the map size.
  69266. *
  69267. * It does not account for the light projection as it was having too much
  69268. * instability during the light setup or during light position changes.
  69269. *
  69270. * Only valid if useContactHardeningShadow is true.
  69271. */
  69272. contactHardeningLightSizeUVRatio: number;
  69273. private _darkness;
  69274. /**
  69275. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  69276. * 0 means strongest and 1 would means no shadow.
  69277. * @returns the darkness.
  69278. */
  69279. getDarkness(): number;
  69280. /**
  69281. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  69282. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  69283. * @returns the shadow generator allowing fluent coding.
  69284. */
  69285. setDarkness(darkness: number): ShadowGenerator;
  69286. private _transparencyShadow;
  69287. /**
  69288. * Sets the ability to have transparent shadow (boolean).
  69289. * @param transparent True if transparent else False
  69290. * @returns the shadow generator allowing fluent coding
  69291. */
  69292. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  69293. private _shadowMap;
  69294. private _shadowMap2;
  69295. /**
  69296. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  69297. * @returns The render target texture if present otherwise, null
  69298. */
  69299. getShadowMap(): Nullable<RenderTargetTexture>;
  69300. /**
  69301. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  69302. * @returns The render target texture if the shadow map is present otherwise, null
  69303. */
  69304. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  69305. /**
  69306. * Helper function to add a mesh and its descendants to the list of shadow casters.
  69307. * @param mesh Mesh to add
  69308. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  69309. * @returns the Shadow Generator itself
  69310. */
  69311. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  69312. /**
  69313. * Helper function to remove a mesh and its descendants from the list of shadow casters
  69314. * @param mesh Mesh to remove
  69315. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  69316. * @returns the Shadow Generator itself
  69317. */
  69318. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  69319. /**
  69320. * Controls the extent to which the shadows fade out at the edge of the frustum
  69321. * Used only by directionals and spots
  69322. */
  69323. frustumEdgeFalloff: number;
  69324. private _light;
  69325. /**
  69326. * Returns the associated light object.
  69327. * @returns the light generating the shadow
  69328. */
  69329. getLight(): IShadowLight;
  69330. /**
  69331. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  69332. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  69333. * It might on the other hand introduce peter panning.
  69334. */
  69335. forceBackFacesOnly: boolean;
  69336. private _scene;
  69337. private _lightDirection;
  69338. private _effect;
  69339. private _viewMatrix;
  69340. private _projectionMatrix;
  69341. private _transformMatrix;
  69342. private _cachedPosition;
  69343. private _cachedDirection;
  69344. private _cachedDefines;
  69345. private _currentRenderID;
  69346. private _boxBlurPostprocess;
  69347. private _kernelBlurXPostprocess;
  69348. private _kernelBlurYPostprocess;
  69349. private _blurPostProcesses;
  69350. private _mapSize;
  69351. private _currentFaceIndex;
  69352. private _currentFaceIndexCache;
  69353. private _textureType;
  69354. private _defaultTextureMatrix;
  69355. /** @hidden */
  69356. static _SceneComponentInitialization: (scene: Scene) => void;
  69357. /**
  69358. * Creates a ShadowGenerator object.
  69359. * A ShadowGenerator is the required tool to use the shadows.
  69360. * Each light casting shadows needs to use its own ShadowGenerator.
  69361. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  69362. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  69363. * @param light The light object generating the shadows.
  69364. * @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.
  69365. */
  69366. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  69367. private _initializeGenerator;
  69368. private _initializeShadowMap;
  69369. private _initializeBlurRTTAndPostProcesses;
  69370. private _renderForShadowMap;
  69371. private _renderSubMeshForShadowMap;
  69372. private _applyFilterValues;
  69373. /**
  69374. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69375. * @param onCompiled Callback triggered at the and of the effects compilation
  69376. * @param options Sets of optional options forcing the compilation with different modes
  69377. */
  69378. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  69379. useInstances: boolean;
  69380. }>): void;
  69381. /**
  69382. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69383. * @param options Sets of optional options forcing the compilation with different modes
  69384. * @returns A promise that resolves when the compilation completes
  69385. */
  69386. forceCompilationAsync(options?: Partial<{
  69387. useInstances: boolean;
  69388. }>): Promise<void>;
  69389. /**
  69390. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  69391. * @param subMesh The submesh we want to render in the shadow map
  69392. * @param useInstances Defines wether will draw in the map using instances
  69393. * @returns true if ready otherwise, false
  69394. */
  69395. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69396. /**
  69397. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  69398. * @param defines Defines of the material we want to update
  69399. * @param lightIndex Index of the light in the enabled light list of the material
  69400. */
  69401. prepareDefines(defines: any, lightIndex: number): void;
  69402. /**
  69403. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  69404. * defined in the generator but impacting the effect).
  69405. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  69406. * @param effect The effect we are binfing the information for
  69407. */
  69408. bindShadowLight(lightIndex: string, effect: Effect): void;
  69409. /**
  69410. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  69411. * (eq to shadow prjection matrix * light transform matrix)
  69412. * @returns The transform matrix used to create the shadow map
  69413. */
  69414. getTransformMatrix(): Matrix;
  69415. /**
  69416. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  69417. * Cube and 2D textures for instance.
  69418. */
  69419. recreateShadowMap(): void;
  69420. private _disposeBlurPostProcesses;
  69421. private _disposeRTTandPostProcesses;
  69422. /**
  69423. * Disposes the ShadowGenerator.
  69424. * Returns nothing.
  69425. */
  69426. dispose(): void;
  69427. /**
  69428. * Serializes the shadow generator setup to a json object.
  69429. * @returns The serialized JSON object
  69430. */
  69431. serialize(): any;
  69432. /**
  69433. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  69434. * @param parsedShadowGenerator The JSON object to parse
  69435. * @param scene The scene to create the shadow map for
  69436. * @returns The parsed shadow generator
  69437. */
  69438. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  69439. }
  69440. }
  69441. declare module BABYLON {
  69442. /**
  69443. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  69444. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  69445. * 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.
  69446. */
  69447. export abstract class Light extends Node {
  69448. /**
  69449. * Falloff Default: light is falling off following the material specification:
  69450. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  69451. */
  69452. static readonly FALLOFF_DEFAULT: number;
  69453. /**
  69454. * Falloff Physical: light is falling off following the inverse squared distance law.
  69455. */
  69456. static readonly FALLOFF_PHYSICAL: number;
  69457. /**
  69458. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  69459. * to enhance interoperability with other engines.
  69460. */
  69461. static readonly FALLOFF_GLTF: number;
  69462. /**
  69463. * Falloff Standard: light is falling off like in the standard material
  69464. * to enhance interoperability with other materials.
  69465. */
  69466. static readonly FALLOFF_STANDARD: number;
  69467. /**
  69468. * If every light affecting the material is in this lightmapMode,
  69469. * material.lightmapTexture adds or multiplies
  69470. * (depends on material.useLightmapAsShadowmap)
  69471. * after every other light calculations.
  69472. */
  69473. static readonly LIGHTMAP_DEFAULT: number;
  69474. /**
  69475. * material.lightmapTexture as only diffuse lighting from this light
  69476. * adds only specular lighting from this light
  69477. * adds dynamic shadows
  69478. */
  69479. static readonly LIGHTMAP_SPECULAR: number;
  69480. /**
  69481. * material.lightmapTexture as only lighting
  69482. * no light calculation from this light
  69483. * only adds dynamic shadows from this light
  69484. */
  69485. static readonly LIGHTMAP_SHADOWSONLY: number;
  69486. /**
  69487. * Each light type uses the default quantity according to its type:
  69488. * point/spot lights use luminous intensity
  69489. * directional lights use illuminance
  69490. */
  69491. static readonly INTENSITYMODE_AUTOMATIC: number;
  69492. /**
  69493. * lumen (lm)
  69494. */
  69495. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  69496. /**
  69497. * candela (lm/sr)
  69498. */
  69499. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  69500. /**
  69501. * lux (lm/m^2)
  69502. */
  69503. static readonly INTENSITYMODE_ILLUMINANCE: number;
  69504. /**
  69505. * nit (cd/m^2)
  69506. */
  69507. static readonly INTENSITYMODE_LUMINANCE: number;
  69508. /**
  69509. * Light type const id of the point light.
  69510. */
  69511. static readonly LIGHTTYPEID_POINTLIGHT: number;
  69512. /**
  69513. * Light type const id of the directional light.
  69514. */
  69515. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  69516. /**
  69517. * Light type const id of the spot light.
  69518. */
  69519. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  69520. /**
  69521. * Light type const id of the hemispheric light.
  69522. */
  69523. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  69524. /**
  69525. * Diffuse gives the basic color to an object.
  69526. */
  69527. diffuse: Color3;
  69528. /**
  69529. * Specular produces a highlight color on an object.
  69530. * Note: This is note affecting PBR materials.
  69531. */
  69532. specular: Color3;
  69533. /**
  69534. * Defines the falloff type for this light. This lets overrriding how punctual light are
  69535. * falling off base on range or angle.
  69536. * This can be set to any values in Light.FALLOFF_x.
  69537. *
  69538. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  69539. * other types of materials.
  69540. */
  69541. falloffType: number;
  69542. /**
  69543. * Strength of the light.
  69544. * Note: By default it is define in the framework own unit.
  69545. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  69546. */
  69547. intensity: number;
  69548. private _range;
  69549. protected _inverseSquaredRange: number;
  69550. /**
  69551. * Defines how far from the source the light is impacting in scene units.
  69552. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  69553. */
  69554. /**
  69555. * Defines how far from the source the light is impacting in scene units.
  69556. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  69557. */
  69558. range: number;
  69559. /**
  69560. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  69561. * of light.
  69562. */
  69563. private _photometricScale;
  69564. private _intensityMode;
  69565. /**
  69566. * Gets the photometric scale used to interpret the intensity.
  69567. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  69568. */
  69569. /**
  69570. * Sets the photometric scale used to interpret the intensity.
  69571. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  69572. */
  69573. intensityMode: number;
  69574. private _radius;
  69575. /**
  69576. * Gets the light radius used by PBR Materials to simulate soft area lights.
  69577. */
  69578. /**
  69579. * sets the light radius used by PBR Materials to simulate soft area lights.
  69580. */
  69581. radius: number;
  69582. private _renderPriority;
  69583. /**
  69584. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  69585. * exceeding the number allowed of the materials.
  69586. */
  69587. renderPriority: number;
  69588. private _shadowEnabled;
  69589. /**
  69590. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  69591. * the current shadow generator.
  69592. */
  69593. /**
  69594. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  69595. * the current shadow generator.
  69596. */
  69597. shadowEnabled: boolean;
  69598. private _includedOnlyMeshes;
  69599. /**
  69600. * Gets the only meshes impacted by this light.
  69601. */
  69602. /**
  69603. * Sets the only meshes impacted by this light.
  69604. */
  69605. includedOnlyMeshes: AbstractMesh[];
  69606. private _excludedMeshes;
  69607. /**
  69608. * Gets the meshes not impacted by this light.
  69609. */
  69610. /**
  69611. * Sets the meshes not impacted by this light.
  69612. */
  69613. excludedMeshes: AbstractMesh[];
  69614. private _excludeWithLayerMask;
  69615. /**
  69616. * Gets the layer id use to find what meshes are not impacted by the light.
  69617. * Inactive if 0
  69618. */
  69619. /**
  69620. * Sets the layer id use to find what meshes are not impacted by the light.
  69621. * Inactive if 0
  69622. */
  69623. excludeWithLayerMask: number;
  69624. private _includeOnlyWithLayerMask;
  69625. /**
  69626. * Gets the layer id use to find what meshes are impacted by the light.
  69627. * Inactive if 0
  69628. */
  69629. /**
  69630. * Sets the layer id use to find what meshes are impacted by the light.
  69631. * Inactive if 0
  69632. */
  69633. includeOnlyWithLayerMask: number;
  69634. private _lightmapMode;
  69635. /**
  69636. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  69637. */
  69638. /**
  69639. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  69640. */
  69641. lightmapMode: number;
  69642. /**
  69643. * Shadow generator associted to the light.
  69644. * @hidden Internal use only.
  69645. */
  69646. _shadowGenerator: Nullable<IShadowGenerator>;
  69647. /**
  69648. * @hidden Internal use only.
  69649. */
  69650. _excludedMeshesIds: string[];
  69651. /**
  69652. * @hidden Internal use only.
  69653. */
  69654. _includedOnlyMeshesIds: string[];
  69655. /**
  69656. * The current light unifom buffer.
  69657. * @hidden Internal use only.
  69658. */
  69659. _uniformBuffer: UniformBuffer;
  69660. /**
  69661. * Creates a Light object in the scene.
  69662. * Documentation : https://doc.babylonjs.com/babylon101/lights
  69663. * @param name The firendly name of the light
  69664. * @param scene The scene the light belongs too
  69665. */
  69666. constructor(name: string, scene: Scene);
  69667. protected abstract _buildUniformLayout(): void;
  69668. /**
  69669. * Sets the passed Effect "effect" with the Light information.
  69670. * @param effect The effect to update
  69671. * @param lightIndex The index of the light in the effect to update
  69672. * @returns The light
  69673. */
  69674. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  69675. /**
  69676. * Returns the string "Light".
  69677. * @returns the class name
  69678. */
  69679. getClassName(): string;
  69680. /** @hidden */
  69681. readonly _isLight: boolean;
  69682. /**
  69683. * Converts the light information to a readable string for debug purpose.
  69684. * @param fullDetails Supports for multiple levels of logging within scene loading
  69685. * @returns the human readable light info
  69686. */
  69687. toString(fullDetails?: boolean): string;
  69688. /** @hidden */
  69689. protected _syncParentEnabledState(): void;
  69690. /**
  69691. * Set the enabled state of this node.
  69692. * @param value - the new enabled state
  69693. */
  69694. setEnabled(value: boolean): void;
  69695. /**
  69696. * Returns the Light associated shadow generator if any.
  69697. * @return the associated shadow generator.
  69698. */
  69699. getShadowGenerator(): Nullable<IShadowGenerator>;
  69700. /**
  69701. * Returns a Vector3, the absolute light position in the World.
  69702. * @returns the world space position of the light
  69703. */
  69704. getAbsolutePosition(): Vector3;
  69705. /**
  69706. * Specifies if the light will affect the passed mesh.
  69707. * @param mesh The mesh to test against the light
  69708. * @return true the mesh is affected otherwise, false.
  69709. */
  69710. canAffectMesh(mesh: AbstractMesh): boolean;
  69711. /**
  69712. * Sort function to order lights for rendering.
  69713. * @param a First Light object to compare to second.
  69714. * @param b Second Light object to compare first.
  69715. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  69716. */
  69717. static CompareLightsPriority(a: Light, b: Light): number;
  69718. /**
  69719. * Releases resources associated with this node.
  69720. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  69721. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  69722. */
  69723. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  69724. /**
  69725. * Returns the light type ID (integer).
  69726. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  69727. */
  69728. getTypeID(): number;
  69729. /**
  69730. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  69731. * @returns the scaled intensity in intensity mode unit
  69732. */
  69733. getScaledIntensity(): number;
  69734. /**
  69735. * Returns a new Light object, named "name", from the current one.
  69736. * @param name The name of the cloned light
  69737. * @returns the new created light
  69738. */
  69739. clone(name: string): Nullable<Light>;
  69740. /**
  69741. * Serializes the current light into a Serialization object.
  69742. * @returns the serialized object.
  69743. */
  69744. serialize(): any;
  69745. /**
  69746. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  69747. * This new light is named "name" and added to the passed scene.
  69748. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  69749. * @param name The friendly name of the light
  69750. * @param scene The scene the new light will belong to
  69751. * @returns the constructor function
  69752. */
  69753. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  69754. /**
  69755. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  69756. * @param parsedLight The JSON representation of the light
  69757. * @param scene The scene to create the parsed light in
  69758. * @returns the created light after parsing
  69759. */
  69760. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  69761. private _hookArrayForExcluded;
  69762. private _hookArrayForIncludedOnly;
  69763. private _resyncMeshes;
  69764. /**
  69765. * Forces the meshes to update their light related information in their rendering used effects
  69766. * @hidden Internal Use Only
  69767. */
  69768. _markMeshesAsLightDirty(): void;
  69769. /**
  69770. * Recomputes the cached photometric scale if needed.
  69771. */
  69772. private _computePhotometricScale;
  69773. /**
  69774. * Returns the Photometric Scale according to the light type and intensity mode.
  69775. */
  69776. private _getPhotometricScale;
  69777. /**
  69778. * Reorder the light in the scene according to their defined priority.
  69779. * @hidden Internal Use Only
  69780. */
  69781. _reorderLightsInScene(): void;
  69782. /**
  69783. * Prepares the list of defines specific to the light type.
  69784. * @param defines the list of defines
  69785. * @param lightIndex defines the index of the light for the effect
  69786. */
  69787. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  69788. }
  69789. }
  69790. declare module BABYLON {
  69791. /**
  69792. * Interface used to define Action
  69793. */
  69794. export interface IAction {
  69795. /**
  69796. * Trigger for the action
  69797. */
  69798. trigger: number;
  69799. /** Options of the trigger */
  69800. triggerOptions: any;
  69801. /**
  69802. * Gets the trigger parameters
  69803. * @returns the trigger parameters
  69804. */
  69805. getTriggerParameter(): any;
  69806. /**
  69807. * Internal only - executes current action event
  69808. * @hidden
  69809. */
  69810. _executeCurrent(evt?: ActionEvent): void;
  69811. /**
  69812. * Serialize placeholder for child classes
  69813. * @param parent of child
  69814. * @returns the serialized object
  69815. */
  69816. serialize(parent: any): any;
  69817. /**
  69818. * Internal only
  69819. * @hidden
  69820. */
  69821. _prepare(): void;
  69822. /**
  69823. * Internal only - manager for action
  69824. * @hidden
  69825. */
  69826. _actionManager: AbstractActionManager;
  69827. }
  69828. /**
  69829. * The action to be carried out following a trigger
  69830. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  69831. */
  69832. export class Action implements IAction {
  69833. /** the trigger, with or without parameters, for the action */
  69834. triggerOptions: any;
  69835. /**
  69836. * Trigger for the action
  69837. */
  69838. trigger: number;
  69839. /**
  69840. * Internal only - manager for action
  69841. * @hidden
  69842. */
  69843. _actionManager: ActionManager;
  69844. private _nextActiveAction;
  69845. private _child;
  69846. private _condition?;
  69847. private _triggerParameter;
  69848. /**
  69849. * An event triggered prior to action being executed.
  69850. */
  69851. onBeforeExecuteObservable: Observable<Action>;
  69852. /**
  69853. * Creates a new Action
  69854. * @param triggerOptions the trigger, with or without parameters, for the action
  69855. * @param condition an optional determinant of action
  69856. */
  69857. constructor(
  69858. /** the trigger, with or without parameters, for the action */
  69859. triggerOptions: any, condition?: Condition);
  69860. /**
  69861. * Internal only
  69862. * @hidden
  69863. */
  69864. _prepare(): void;
  69865. /**
  69866. * Gets the trigger parameters
  69867. * @returns the trigger parameters
  69868. */
  69869. getTriggerParameter(): any;
  69870. /**
  69871. * Internal only - executes current action event
  69872. * @hidden
  69873. */
  69874. _executeCurrent(evt?: ActionEvent): void;
  69875. /**
  69876. * Execute placeholder for child classes
  69877. * @param evt optional action event
  69878. */
  69879. execute(evt?: ActionEvent): void;
  69880. /**
  69881. * Skips to next active action
  69882. */
  69883. skipToNextActiveAction(): void;
  69884. /**
  69885. * Adds action to chain of actions, may be a DoNothingAction
  69886. * @param action defines the next action to execute
  69887. * @returns The action passed in
  69888. * @see https://www.babylonjs-playground.com/#1T30HR#0
  69889. */
  69890. then(action: Action): Action;
  69891. /**
  69892. * Internal only
  69893. * @hidden
  69894. */
  69895. _getProperty(propertyPath: string): string;
  69896. /**
  69897. * Internal only
  69898. * @hidden
  69899. */
  69900. _getEffectiveTarget(target: any, propertyPath: string): any;
  69901. /**
  69902. * Serialize placeholder for child classes
  69903. * @param parent of child
  69904. * @returns the serialized object
  69905. */
  69906. serialize(parent: any): any;
  69907. /**
  69908. * Internal only called by serialize
  69909. * @hidden
  69910. */
  69911. protected _serialize(serializedAction: any, parent?: any): any;
  69912. /**
  69913. * Internal only
  69914. * @hidden
  69915. */
  69916. static _SerializeValueAsString: (value: any) => string;
  69917. /**
  69918. * Internal only
  69919. * @hidden
  69920. */
  69921. static _GetTargetProperty: (target: Scene | Node) => {
  69922. name: string;
  69923. targetType: string;
  69924. value: string;
  69925. };
  69926. }
  69927. }
  69928. declare module BABYLON {
  69929. /**
  69930. * A Condition applied to an Action
  69931. */
  69932. export class Condition {
  69933. /**
  69934. * Internal only - manager for action
  69935. * @hidden
  69936. */
  69937. _actionManager: ActionManager;
  69938. /**
  69939. * Internal only
  69940. * @hidden
  69941. */
  69942. _evaluationId: number;
  69943. /**
  69944. * Internal only
  69945. * @hidden
  69946. */
  69947. _currentResult: boolean;
  69948. /**
  69949. * Creates a new Condition
  69950. * @param actionManager the manager of the action the condition is applied to
  69951. */
  69952. constructor(actionManager: ActionManager);
  69953. /**
  69954. * Check if the current condition is valid
  69955. * @returns a boolean
  69956. */
  69957. isValid(): boolean;
  69958. /**
  69959. * Internal only
  69960. * @hidden
  69961. */
  69962. _getProperty(propertyPath: string): string;
  69963. /**
  69964. * Internal only
  69965. * @hidden
  69966. */
  69967. _getEffectiveTarget(target: any, propertyPath: string): any;
  69968. /**
  69969. * Serialize placeholder for child classes
  69970. * @returns the serialized object
  69971. */
  69972. serialize(): any;
  69973. /**
  69974. * Internal only
  69975. * @hidden
  69976. */
  69977. protected _serialize(serializedCondition: any): any;
  69978. }
  69979. /**
  69980. * Defines specific conditional operators as extensions of Condition
  69981. */
  69982. export class ValueCondition extends Condition {
  69983. /** path to specify the property of the target the conditional operator uses */
  69984. propertyPath: string;
  69985. /** the value compared by the conditional operator against the current value of the property */
  69986. value: any;
  69987. /** the conditional operator, default ValueCondition.IsEqual */
  69988. operator: number;
  69989. /**
  69990. * Internal only
  69991. * @hidden
  69992. */
  69993. private static _IsEqual;
  69994. /**
  69995. * Internal only
  69996. * @hidden
  69997. */
  69998. private static _IsDifferent;
  69999. /**
  70000. * Internal only
  70001. * @hidden
  70002. */
  70003. private static _IsGreater;
  70004. /**
  70005. * Internal only
  70006. * @hidden
  70007. */
  70008. private static _IsLesser;
  70009. /**
  70010. * returns the number for IsEqual
  70011. */
  70012. static readonly IsEqual: number;
  70013. /**
  70014. * Returns the number for IsDifferent
  70015. */
  70016. static readonly IsDifferent: number;
  70017. /**
  70018. * Returns the number for IsGreater
  70019. */
  70020. static readonly IsGreater: number;
  70021. /**
  70022. * Returns the number for IsLesser
  70023. */
  70024. static readonly IsLesser: number;
  70025. /**
  70026. * Internal only The action manager for the condition
  70027. * @hidden
  70028. */
  70029. _actionManager: ActionManager;
  70030. /**
  70031. * Internal only
  70032. * @hidden
  70033. */
  70034. private _target;
  70035. /**
  70036. * Internal only
  70037. * @hidden
  70038. */
  70039. private _effectiveTarget;
  70040. /**
  70041. * Internal only
  70042. * @hidden
  70043. */
  70044. private _property;
  70045. /**
  70046. * Creates a new ValueCondition
  70047. * @param actionManager manager for the action the condition applies to
  70048. * @param target for the action
  70049. * @param propertyPath path to specify the property of the target the conditional operator uses
  70050. * @param value the value compared by the conditional operator against the current value of the property
  70051. * @param operator the conditional operator, default ValueCondition.IsEqual
  70052. */
  70053. constructor(actionManager: ActionManager, target: any,
  70054. /** path to specify the property of the target the conditional operator uses */
  70055. propertyPath: string,
  70056. /** the value compared by the conditional operator against the current value of the property */
  70057. value: any,
  70058. /** the conditional operator, default ValueCondition.IsEqual */
  70059. operator?: number);
  70060. /**
  70061. * Compares the given value with the property value for the specified conditional operator
  70062. * @returns the result of the comparison
  70063. */
  70064. isValid(): boolean;
  70065. /**
  70066. * Serialize the ValueCondition into a JSON compatible object
  70067. * @returns serialization object
  70068. */
  70069. serialize(): any;
  70070. /**
  70071. * Gets the name of the conditional operator for the ValueCondition
  70072. * @param operator the conditional operator
  70073. * @returns the name
  70074. */
  70075. static GetOperatorName(operator: number): string;
  70076. }
  70077. /**
  70078. * Defines a predicate condition as an extension of Condition
  70079. */
  70080. export class PredicateCondition extends Condition {
  70081. /** defines the predicate function used to validate the condition */
  70082. predicate: () => boolean;
  70083. /**
  70084. * Internal only - manager for action
  70085. * @hidden
  70086. */
  70087. _actionManager: ActionManager;
  70088. /**
  70089. * Creates a new PredicateCondition
  70090. * @param actionManager manager for the action the condition applies to
  70091. * @param predicate defines the predicate function used to validate the condition
  70092. */
  70093. constructor(actionManager: ActionManager,
  70094. /** defines the predicate function used to validate the condition */
  70095. predicate: () => boolean);
  70096. /**
  70097. * @returns the validity of the predicate condition
  70098. */
  70099. isValid(): boolean;
  70100. }
  70101. /**
  70102. * Defines a state condition as an extension of Condition
  70103. */
  70104. export class StateCondition extends Condition {
  70105. /** Value to compare with target state */
  70106. value: string;
  70107. /**
  70108. * Internal only - manager for action
  70109. * @hidden
  70110. */
  70111. _actionManager: ActionManager;
  70112. /**
  70113. * Internal only
  70114. * @hidden
  70115. */
  70116. private _target;
  70117. /**
  70118. * Creates a new StateCondition
  70119. * @param actionManager manager for the action the condition applies to
  70120. * @param target of the condition
  70121. * @param value to compare with target state
  70122. */
  70123. constructor(actionManager: ActionManager, target: any,
  70124. /** Value to compare with target state */
  70125. value: string);
  70126. /**
  70127. * Gets a boolean indicating if the current condition is met
  70128. * @returns the validity of the state
  70129. */
  70130. isValid(): boolean;
  70131. /**
  70132. * Serialize the StateCondition into a JSON compatible object
  70133. * @returns serialization object
  70134. */
  70135. serialize(): any;
  70136. }
  70137. }
  70138. declare module BABYLON {
  70139. /**
  70140. * This defines an action responsible to toggle a boolean once triggered.
  70141. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70142. */
  70143. export class SwitchBooleanAction extends Action {
  70144. /**
  70145. * The path to the boolean property in the target object
  70146. */
  70147. propertyPath: string;
  70148. private _target;
  70149. private _effectiveTarget;
  70150. private _property;
  70151. /**
  70152. * Instantiate the action
  70153. * @param triggerOptions defines the trigger options
  70154. * @param target defines the object containing the boolean
  70155. * @param propertyPath defines the path to the boolean property in the target object
  70156. * @param condition defines the trigger related conditions
  70157. */
  70158. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  70159. /** @hidden */
  70160. _prepare(): void;
  70161. /**
  70162. * Execute the action toggle the boolean value.
  70163. */
  70164. execute(): void;
  70165. /**
  70166. * Serializes the actions and its related information.
  70167. * @param parent defines the object to serialize in
  70168. * @returns the serialized object
  70169. */
  70170. serialize(parent: any): any;
  70171. }
  70172. /**
  70173. * This defines an action responsible to set a the state field of the target
  70174. * to a desired value once triggered.
  70175. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70176. */
  70177. export class SetStateAction extends Action {
  70178. /**
  70179. * The value to store in the state field.
  70180. */
  70181. value: string;
  70182. private _target;
  70183. /**
  70184. * Instantiate the action
  70185. * @param triggerOptions defines the trigger options
  70186. * @param target defines the object containing the state property
  70187. * @param value defines the value to store in the state field
  70188. * @param condition defines the trigger related conditions
  70189. */
  70190. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  70191. /**
  70192. * Execute the action and store the value on the target state property.
  70193. */
  70194. execute(): void;
  70195. /**
  70196. * Serializes the actions and its related information.
  70197. * @param parent defines the object to serialize in
  70198. * @returns the serialized object
  70199. */
  70200. serialize(parent: any): any;
  70201. }
  70202. /**
  70203. * This defines an action responsible to set a property of the target
  70204. * to a desired value once triggered.
  70205. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70206. */
  70207. export class SetValueAction extends Action {
  70208. /**
  70209. * The path of the property to set in the target.
  70210. */
  70211. propertyPath: string;
  70212. /**
  70213. * The value to set in the property
  70214. */
  70215. value: any;
  70216. private _target;
  70217. private _effectiveTarget;
  70218. private _property;
  70219. /**
  70220. * Instantiate the action
  70221. * @param triggerOptions defines the trigger options
  70222. * @param target defines the object containing the property
  70223. * @param propertyPath defines the path of the property to set in the target
  70224. * @param value defines the value to set in the property
  70225. * @param condition defines the trigger related conditions
  70226. */
  70227. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  70228. /** @hidden */
  70229. _prepare(): void;
  70230. /**
  70231. * Execute the action and set the targetted property to the desired value.
  70232. */
  70233. execute(): void;
  70234. /**
  70235. * Serializes the actions and its related information.
  70236. * @param parent defines the object to serialize in
  70237. * @returns the serialized object
  70238. */
  70239. serialize(parent: any): any;
  70240. }
  70241. /**
  70242. * This defines an action responsible to increment the target value
  70243. * to a desired value once triggered.
  70244. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70245. */
  70246. export class IncrementValueAction extends Action {
  70247. /**
  70248. * The path of the property to increment in the target.
  70249. */
  70250. propertyPath: string;
  70251. /**
  70252. * The value we should increment the property by.
  70253. */
  70254. value: any;
  70255. private _target;
  70256. private _effectiveTarget;
  70257. private _property;
  70258. /**
  70259. * Instantiate the action
  70260. * @param triggerOptions defines the trigger options
  70261. * @param target defines the object containing the property
  70262. * @param propertyPath defines the path of the property to increment in the target
  70263. * @param value defines the value value we should increment the property by
  70264. * @param condition defines the trigger related conditions
  70265. */
  70266. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  70267. /** @hidden */
  70268. _prepare(): void;
  70269. /**
  70270. * Execute the action and increment the target of the value amount.
  70271. */
  70272. execute(): void;
  70273. /**
  70274. * Serializes the actions and its related information.
  70275. * @param parent defines the object to serialize in
  70276. * @returns the serialized object
  70277. */
  70278. serialize(parent: any): any;
  70279. }
  70280. /**
  70281. * This defines an action responsible to start an animation once triggered.
  70282. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70283. */
  70284. export class PlayAnimationAction extends Action {
  70285. /**
  70286. * Where the animation should start (animation frame)
  70287. */
  70288. from: number;
  70289. /**
  70290. * Where the animation should stop (animation frame)
  70291. */
  70292. to: number;
  70293. /**
  70294. * Define if the animation should loop or stop after the first play.
  70295. */
  70296. loop?: boolean;
  70297. private _target;
  70298. /**
  70299. * Instantiate the action
  70300. * @param triggerOptions defines the trigger options
  70301. * @param target defines the target animation or animation name
  70302. * @param from defines from where the animation should start (animation frame)
  70303. * @param end defines where the animation should stop (animation frame)
  70304. * @param loop defines if the animation should loop or stop after the first play
  70305. * @param condition defines the trigger related conditions
  70306. */
  70307. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  70308. /** @hidden */
  70309. _prepare(): void;
  70310. /**
  70311. * Execute the action and play the animation.
  70312. */
  70313. execute(): void;
  70314. /**
  70315. * Serializes the actions and its related information.
  70316. * @param parent defines the object to serialize in
  70317. * @returns the serialized object
  70318. */
  70319. serialize(parent: any): any;
  70320. }
  70321. /**
  70322. * This defines an action responsible to stop an animation once triggered.
  70323. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70324. */
  70325. export class StopAnimationAction extends Action {
  70326. private _target;
  70327. /**
  70328. * Instantiate the action
  70329. * @param triggerOptions defines the trigger options
  70330. * @param target defines the target animation or animation name
  70331. * @param condition defines the trigger related conditions
  70332. */
  70333. constructor(triggerOptions: any, target: any, condition?: Condition);
  70334. /** @hidden */
  70335. _prepare(): void;
  70336. /**
  70337. * Execute the action and stop the animation.
  70338. */
  70339. execute(): void;
  70340. /**
  70341. * Serializes the actions and its related information.
  70342. * @param parent defines the object to serialize in
  70343. * @returns the serialized object
  70344. */
  70345. serialize(parent: any): any;
  70346. }
  70347. /**
  70348. * This defines an action responsible that does nothing once triggered.
  70349. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70350. */
  70351. export class DoNothingAction extends Action {
  70352. /**
  70353. * Instantiate the action
  70354. * @param triggerOptions defines the trigger options
  70355. * @param condition defines the trigger related conditions
  70356. */
  70357. constructor(triggerOptions?: any, condition?: Condition);
  70358. /**
  70359. * Execute the action and do nothing.
  70360. */
  70361. execute(): void;
  70362. /**
  70363. * Serializes the actions and its related information.
  70364. * @param parent defines the object to serialize in
  70365. * @returns the serialized object
  70366. */
  70367. serialize(parent: any): any;
  70368. }
  70369. /**
  70370. * This defines an action responsible to trigger several actions once triggered.
  70371. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70372. */
  70373. export class CombineAction extends Action {
  70374. /**
  70375. * The list of aggregated animations to run.
  70376. */
  70377. children: Action[];
  70378. /**
  70379. * Instantiate the action
  70380. * @param triggerOptions defines the trigger options
  70381. * @param children defines the list of aggregated animations to run
  70382. * @param condition defines the trigger related conditions
  70383. */
  70384. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  70385. /** @hidden */
  70386. _prepare(): void;
  70387. /**
  70388. * Execute the action and executes all the aggregated actions.
  70389. */
  70390. execute(evt: ActionEvent): void;
  70391. /**
  70392. * Serializes the actions and its related information.
  70393. * @param parent defines the object to serialize in
  70394. * @returns the serialized object
  70395. */
  70396. serialize(parent: any): any;
  70397. }
  70398. /**
  70399. * This defines an action responsible to run code (external event) once triggered.
  70400. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70401. */
  70402. export class ExecuteCodeAction extends Action {
  70403. /**
  70404. * The callback function to run.
  70405. */
  70406. func: (evt: ActionEvent) => void;
  70407. /**
  70408. * Instantiate the action
  70409. * @param triggerOptions defines the trigger options
  70410. * @param func defines the callback function to run
  70411. * @param condition defines the trigger related conditions
  70412. */
  70413. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  70414. /**
  70415. * Execute the action and run the attached code.
  70416. */
  70417. execute(evt: ActionEvent): void;
  70418. }
  70419. /**
  70420. * This defines an action responsible to set the parent property of the target once triggered.
  70421. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70422. */
  70423. export class SetParentAction extends Action {
  70424. private _parent;
  70425. private _target;
  70426. /**
  70427. * Instantiate the action
  70428. * @param triggerOptions defines the trigger options
  70429. * @param target defines the target containing the parent property
  70430. * @param parent defines from where the animation should start (animation frame)
  70431. * @param condition defines the trigger related conditions
  70432. */
  70433. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  70434. /** @hidden */
  70435. _prepare(): void;
  70436. /**
  70437. * Execute the action and set the parent property.
  70438. */
  70439. execute(): void;
  70440. /**
  70441. * Serializes the actions and its related information.
  70442. * @param parent defines the object to serialize in
  70443. * @returns the serialized object
  70444. */
  70445. serialize(parent: any): any;
  70446. }
  70447. }
  70448. declare module BABYLON {
  70449. /**
  70450. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  70451. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  70452. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70453. */
  70454. export class ActionManager extends AbstractActionManager {
  70455. /**
  70456. * Nothing
  70457. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70458. */
  70459. static readonly NothingTrigger: number;
  70460. /**
  70461. * On pick
  70462. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70463. */
  70464. static readonly OnPickTrigger: number;
  70465. /**
  70466. * On left pick
  70467. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70468. */
  70469. static readonly OnLeftPickTrigger: number;
  70470. /**
  70471. * On right pick
  70472. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70473. */
  70474. static readonly OnRightPickTrigger: number;
  70475. /**
  70476. * On center pick
  70477. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70478. */
  70479. static readonly OnCenterPickTrigger: number;
  70480. /**
  70481. * On pick down
  70482. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70483. */
  70484. static readonly OnPickDownTrigger: number;
  70485. /**
  70486. * On double pick
  70487. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70488. */
  70489. static readonly OnDoublePickTrigger: number;
  70490. /**
  70491. * On pick up
  70492. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70493. */
  70494. static readonly OnPickUpTrigger: number;
  70495. /**
  70496. * On pick out.
  70497. * This trigger will only be raised if you also declared a OnPickDown
  70498. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70499. */
  70500. static readonly OnPickOutTrigger: number;
  70501. /**
  70502. * On long press
  70503. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70504. */
  70505. static readonly OnLongPressTrigger: number;
  70506. /**
  70507. * On pointer over
  70508. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70509. */
  70510. static readonly OnPointerOverTrigger: number;
  70511. /**
  70512. * On pointer out
  70513. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70514. */
  70515. static readonly OnPointerOutTrigger: number;
  70516. /**
  70517. * On every frame
  70518. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70519. */
  70520. static readonly OnEveryFrameTrigger: number;
  70521. /**
  70522. * On intersection enter
  70523. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70524. */
  70525. static readonly OnIntersectionEnterTrigger: number;
  70526. /**
  70527. * On intersection exit
  70528. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70529. */
  70530. static readonly OnIntersectionExitTrigger: number;
  70531. /**
  70532. * On key down
  70533. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70534. */
  70535. static readonly OnKeyDownTrigger: number;
  70536. /**
  70537. * On key up
  70538. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70539. */
  70540. static readonly OnKeyUpTrigger: number;
  70541. private _scene;
  70542. /**
  70543. * Creates a new action manager
  70544. * @param scene defines the hosting scene
  70545. */
  70546. constructor(scene: Scene);
  70547. /**
  70548. * Releases all associated resources
  70549. */
  70550. dispose(): void;
  70551. /**
  70552. * Gets hosting scene
  70553. * @returns the hosting scene
  70554. */
  70555. getScene(): Scene;
  70556. /**
  70557. * Does this action manager handles actions of any of the given triggers
  70558. * @param triggers defines the triggers to be tested
  70559. * @return a boolean indicating whether one (or more) of the triggers is handled
  70560. */
  70561. hasSpecificTriggers(triggers: number[]): boolean;
  70562. /**
  70563. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  70564. * speed.
  70565. * @param triggerA defines the trigger to be tested
  70566. * @param triggerB defines the trigger to be tested
  70567. * @return a boolean indicating whether one (or more) of the triggers is handled
  70568. */
  70569. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  70570. /**
  70571. * Does this action manager handles actions of a given trigger
  70572. * @param trigger defines the trigger to be tested
  70573. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  70574. * @return whether the trigger is handled
  70575. */
  70576. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  70577. /**
  70578. * Does this action manager has pointer triggers
  70579. */
  70580. readonly hasPointerTriggers: boolean;
  70581. /**
  70582. * Does this action manager has pick triggers
  70583. */
  70584. readonly hasPickTriggers: boolean;
  70585. /**
  70586. * Registers an action to this action manager
  70587. * @param action defines the action to be registered
  70588. * @return the action amended (prepared) after registration
  70589. */
  70590. registerAction(action: IAction): Nullable<IAction>;
  70591. /**
  70592. * Unregisters an action to this action manager
  70593. * @param action defines the action to be unregistered
  70594. * @return a boolean indicating whether the action has been unregistered
  70595. */
  70596. unregisterAction(action: IAction): Boolean;
  70597. /**
  70598. * Process a specific trigger
  70599. * @param trigger defines the trigger to process
  70600. * @param evt defines the event details to be processed
  70601. */
  70602. processTrigger(trigger: number, evt?: IActionEvent): void;
  70603. /** @hidden */
  70604. _getEffectiveTarget(target: any, propertyPath: string): any;
  70605. /** @hidden */
  70606. _getProperty(propertyPath: string): string;
  70607. /**
  70608. * Serialize this manager to a JSON object
  70609. * @param name defines the property name to store this manager
  70610. * @returns a JSON representation of this manager
  70611. */
  70612. serialize(name: string): any;
  70613. /**
  70614. * Creates a new ActionManager from a JSON data
  70615. * @param parsedActions defines the JSON data to read from
  70616. * @param object defines the hosting mesh
  70617. * @param scene defines the hosting scene
  70618. */
  70619. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  70620. /**
  70621. * Get a trigger name by index
  70622. * @param trigger defines the trigger index
  70623. * @returns a trigger name
  70624. */
  70625. static GetTriggerName(trigger: number): string;
  70626. }
  70627. }
  70628. declare module BABYLON {
  70629. /**
  70630. * Class representing a ray with position and direction
  70631. */
  70632. export class Ray {
  70633. /** origin point */
  70634. origin: Vector3;
  70635. /** direction */
  70636. direction: Vector3;
  70637. /** length of the ray */
  70638. length: number;
  70639. private static readonly TmpVector3;
  70640. private _tmpRay;
  70641. /**
  70642. * Creates a new ray
  70643. * @param origin origin point
  70644. * @param direction direction
  70645. * @param length length of the ray
  70646. */
  70647. constructor(
  70648. /** origin point */
  70649. origin: Vector3,
  70650. /** direction */
  70651. direction: Vector3,
  70652. /** length of the ray */
  70653. length?: number);
  70654. /**
  70655. * Checks if the ray intersects a box
  70656. * @param minimum bound of the box
  70657. * @param maximum bound of the box
  70658. * @param intersectionTreshold extra extend to be added to the box in all direction
  70659. * @returns if the box was hit
  70660. */
  70661. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  70662. /**
  70663. * Checks if the ray intersects a box
  70664. * @param box the bounding box to check
  70665. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  70666. * @returns if the box was hit
  70667. */
  70668. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  70669. /**
  70670. * If the ray hits a sphere
  70671. * @param sphere the bounding sphere to check
  70672. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  70673. * @returns true if it hits the sphere
  70674. */
  70675. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  70676. /**
  70677. * If the ray hits a triange
  70678. * @param vertex0 triangle vertex
  70679. * @param vertex1 triangle vertex
  70680. * @param vertex2 triangle vertex
  70681. * @returns intersection information if hit
  70682. */
  70683. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  70684. /**
  70685. * Checks if ray intersects a plane
  70686. * @param plane the plane to check
  70687. * @returns the distance away it was hit
  70688. */
  70689. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  70690. /**
  70691. * Checks if ray intersects a mesh
  70692. * @param mesh the mesh to check
  70693. * @param fastCheck if only the bounding box should checked
  70694. * @returns picking info of the intersecton
  70695. */
  70696. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  70697. /**
  70698. * Checks if ray intersects a mesh
  70699. * @param meshes the meshes to check
  70700. * @param fastCheck if only the bounding box should checked
  70701. * @param results array to store result in
  70702. * @returns Array of picking infos
  70703. */
  70704. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  70705. private _comparePickingInfo;
  70706. private static smallnum;
  70707. private static rayl;
  70708. /**
  70709. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  70710. * @param sega the first point of the segment to test the intersection against
  70711. * @param segb the second point of the segment to test the intersection against
  70712. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  70713. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  70714. */
  70715. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  70716. /**
  70717. * Update the ray from viewport position
  70718. * @param x position
  70719. * @param y y position
  70720. * @param viewportWidth viewport width
  70721. * @param viewportHeight viewport height
  70722. * @param world world matrix
  70723. * @param view view matrix
  70724. * @param projection projection matrix
  70725. * @returns this ray updated
  70726. */
  70727. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  70728. /**
  70729. * Creates a ray with origin and direction of 0,0,0
  70730. * @returns the new ray
  70731. */
  70732. static Zero(): Ray;
  70733. /**
  70734. * Creates a new ray from screen space and viewport
  70735. * @param x position
  70736. * @param y y position
  70737. * @param viewportWidth viewport width
  70738. * @param viewportHeight viewport height
  70739. * @param world world matrix
  70740. * @param view view matrix
  70741. * @param projection projection matrix
  70742. * @returns new ray
  70743. */
  70744. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  70745. /**
  70746. * 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
  70747. * transformed to the given world matrix.
  70748. * @param origin The origin point
  70749. * @param end The end point
  70750. * @param world a matrix to transform the ray to. Default is the identity matrix.
  70751. * @returns the new ray
  70752. */
  70753. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  70754. /**
  70755. * Transforms a ray by a matrix
  70756. * @param ray ray to transform
  70757. * @param matrix matrix to apply
  70758. * @returns the resulting new ray
  70759. */
  70760. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  70761. /**
  70762. * Transforms a ray by a matrix
  70763. * @param ray ray to transform
  70764. * @param matrix matrix to apply
  70765. * @param result ray to store result in
  70766. */
  70767. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  70768. /**
  70769. * Unproject a ray from screen space to object space
  70770. * @param sourceX defines the screen space x coordinate to use
  70771. * @param sourceY defines the screen space y coordinate to use
  70772. * @param viewportWidth defines the current width of the viewport
  70773. * @param viewportHeight defines the current height of the viewport
  70774. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70775. * @param view defines the view matrix to use
  70776. * @param projection defines the projection matrix to use
  70777. */
  70778. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  70779. }
  70780. /**
  70781. * Type used to define predicate used to select faces when a mesh intersection is detected
  70782. */
  70783. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  70784. interface Scene {
  70785. /** @hidden */
  70786. _tempPickingRay: Nullable<Ray>;
  70787. /** @hidden */
  70788. _cachedRayForTransform: Ray;
  70789. /** @hidden */
  70790. _pickWithRayInverseMatrix: Matrix;
  70791. /** @hidden */
  70792. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  70793. /** @hidden */
  70794. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  70795. }
  70796. }
  70797. declare module BABYLON {
  70798. /**
  70799. * Groups all the scene component constants in one place to ease maintenance.
  70800. * @hidden
  70801. */
  70802. export class SceneComponentConstants {
  70803. static readonly NAME_EFFECTLAYER: string;
  70804. static readonly NAME_LAYER: string;
  70805. static readonly NAME_LENSFLARESYSTEM: string;
  70806. static readonly NAME_BOUNDINGBOXRENDERER: string;
  70807. static readonly NAME_PARTICLESYSTEM: string;
  70808. static readonly NAME_GAMEPAD: string;
  70809. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  70810. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  70811. static readonly NAME_DEPTHRENDERER: string;
  70812. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  70813. static readonly NAME_SPRITE: string;
  70814. static readonly NAME_OUTLINERENDERER: string;
  70815. static readonly NAME_PROCEDURALTEXTURE: string;
  70816. static readonly NAME_SHADOWGENERATOR: string;
  70817. static readonly NAME_OCTREE: string;
  70818. static readonly NAME_PHYSICSENGINE: string;
  70819. static readonly NAME_AUDIO: string;
  70820. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  70821. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  70822. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  70823. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  70824. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  70825. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  70826. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  70827. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  70828. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  70829. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  70830. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  70831. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  70832. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  70833. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  70834. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  70835. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  70836. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  70837. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  70838. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  70839. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  70840. static readonly STEP_AFTERRENDER_AUDIO: number;
  70841. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  70842. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  70843. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  70844. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  70845. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  70846. static readonly STEP_POINTERMOVE_SPRITE: number;
  70847. static readonly STEP_POINTERDOWN_SPRITE: number;
  70848. static readonly STEP_POINTERUP_SPRITE: number;
  70849. }
  70850. /**
  70851. * This represents a scene component.
  70852. *
  70853. * This is used to decouple the dependency the scene is having on the different workloads like
  70854. * layers, post processes...
  70855. */
  70856. export interface ISceneComponent {
  70857. /**
  70858. * The name of the component. Each component must have a unique name.
  70859. */
  70860. name: string;
  70861. /**
  70862. * The scene the component belongs to.
  70863. */
  70864. scene: Scene;
  70865. /**
  70866. * Register the component to one instance of a scene.
  70867. */
  70868. register(): void;
  70869. /**
  70870. * Rebuilds the elements related to this component in case of
  70871. * context lost for instance.
  70872. */
  70873. rebuild(): void;
  70874. /**
  70875. * Disposes the component and the associated ressources.
  70876. */
  70877. dispose(): void;
  70878. }
  70879. /**
  70880. * This represents a SERIALIZABLE scene component.
  70881. *
  70882. * This extends Scene Component to add Serialization methods on top.
  70883. */
  70884. export interface ISceneSerializableComponent extends ISceneComponent {
  70885. /**
  70886. * Adds all the element from the container to the scene
  70887. * @param container the container holding the elements
  70888. */
  70889. addFromContainer(container: AbstractScene): void;
  70890. /**
  70891. * Removes all the elements in the container from the scene
  70892. * @param container contains the elements to remove
  70893. * @param dispose if the removed element should be disposed (default: false)
  70894. */
  70895. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  70896. /**
  70897. * Serializes the component data to the specified json object
  70898. * @param serializationObject The object to serialize to
  70899. */
  70900. serialize(serializationObject: any): void;
  70901. }
  70902. /**
  70903. * Strong typing of a Mesh related stage step action
  70904. */
  70905. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  70906. /**
  70907. * Strong typing of a Evaluate Sub Mesh related stage step action
  70908. */
  70909. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  70910. /**
  70911. * Strong typing of a Active Mesh related stage step action
  70912. */
  70913. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  70914. /**
  70915. * Strong typing of a Camera related stage step action
  70916. */
  70917. export type CameraStageAction = (camera: Camera) => void;
  70918. /**
  70919. * Strong typing of a Render Target related stage step action
  70920. */
  70921. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  70922. /**
  70923. * Strong typing of a RenderingGroup related stage step action
  70924. */
  70925. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  70926. /**
  70927. * Strong typing of a Mesh Render related stage step action
  70928. */
  70929. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  70930. /**
  70931. * Strong typing of a simple stage step action
  70932. */
  70933. export type SimpleStageAction = () => void;
  70934. /**
  70935. * Strong typing of a render target action.
  70936. */
  70937. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  70938. /**
  70939. * Strong typing of a pointer move action.
  70940. */
  70941. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  70942. /**
  70943. * Strong typing of a pointer up/down action.
  70944. */
  70945. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  70946. /**
  70947. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  70948. * @hidden
  70949. */
  70950. export class Stage<T extends Function> extends Array<{
  70951. index: number;
  70952. component: ISceneComponent;
  70953. action: T;
  70954. }> {
  70955. /**
  70956. * Hide ctor from the rest of the world.
  70957. * @param items The items to add.
  70958. */
  70959. private constructor();
  70960. /**
  70961. * Creates a new Stage.
  70962. * @returns A new instance of a Stage
  70963. */
  70964. static Create<T extends Function>(): Stage<T>;
  70965. /**
  70966. * Registers a step in an ordered way in the targeted stage.
  70967. * @param index Defines the position to register the step in
  70968. * @param component Defines the component attached to the step
  70969. * @param action Defines the action to launch during the step
  70970. */
  70971. registerStep(index: number, component: ISceneComponent, action: T): void;
  70972. /**
  70973. * Clears all the steps from the stage.
  70974. */
  70975. clear(): void;
  70976. }
  70977. }
  70978. declare module BABYLON {
  70979. interface Scene {
  70980. /** @hidden */
  70981. _pointerOverSprite: Nullable<Sprite>;
  70982. /** @hidden */
  70983. _pickedDownSprite: Nullable<Sprite>;
  70984. /** @hidden */
  70985. _tempSpritePickingRay: Nullable<Ray>;
  70986. /**
  70987. * All of the sprite managers added to this scene
  70988. * @see http://doc.babylonjs.com/babylon101/sprites
  70989. */
  70990. spriteManagers: Array<ISpriteManager>;
  70991. /**
  70992. * An event triggered when sprites rendering is about to start
  70993. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  70994. */
  70995. onBeforeSpritesRenderingObservable: Observable<Scene>;
  70996. /**
  70997. * An event triggered when sprites rendering is done
  70998. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  70999. */
  71000. onAfterSpritesRenderingObservable: Observable<Scene>;
  71001. /** @hidden */
  71002. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  71003. /** Launch a ray to try to pick a sprite in the scene
  71004. * @param x position on screen
  71005. * @param y position on screen
  71006. * @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
  71007. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  71008. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  71009. * @returns a PickingInfo
  71010. */
  71011. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  71012. /** Use the given ray to pick a sprite in the scene
  71013. * @param ray The ray (in world space) to use to pick meshes
  71014. * @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
  71015. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  71016. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  71017. * @returns a PickingInfo
  71018. */
  71019. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  71020. /**
  71021. * Force the sprite under the pointer
  71022. * @param sprite defines the sprite to use
  71023. */
  71024. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  71025. /**
  71026. * Gets the sprite under the pointer
  71027. * @returns a Sprite or null if no sprite is under the pointer
  71028. */
  71029. getPointerOverSprite(): Nullable<Sprite>;
  71030. }
  71031. /**
  71032. * Defines the sprite scene component responsible to manage sprites
  71033. * in a given scene.
  71034. */
  71035. export class SpriteSceneComponent implements ISceneComponent {
  71036. /**
  71037. * The component name helpfull to identify the component in the list of scene components.
  71038. */
  71039. readonly name: string;
  71040. /**
  71041. * The scene the component belongs to.
  71042. */
  71043. scene: Scene;
  71044. /** @hidden */
  71045. private _spritePredicate;
  71046. /**
  71047. * Creates a new instance of the component for the given scene
  71048. * @param scene Defines the scene to register the component in
  71049. */
  71050. constructor(scene: Scene);
  71051. /**
  71052. * Registers the component in a given scene
  71053. */
  71054. register(): void;
  71055. /**
  71056. * Rebuilds the elements related to this component in case of
  71057. * context lost for instance.
  71058. */
  71059. rebuild(): void;
  71060. /**
  71061. * Disposes the component and the associated ressources.
  71062. */
  71063. dispose(): void;
  71064. private _pickSpriteButKeepRay;
  71065. private _pointerMove;
  71066. private _pointerDown;
  71067. private _pointerUp;
  71068. }
  71069. }
  71070. declare module BABYLON {
  71071. /** @hidden */
  71072. export var fogFragmentDeclaration: {
  71073. name: string;
  71074. shader: string;
  71075. };
  71076. }
  71077. declare module BABYLON {
  71078. /** @hidden */
  71079. export var fogFragment: {
  71080. name: string;
  71081. shader: string;
  71082. };
  71083. }
  71084. declare module BABYLON {
  71085. /** @hidden */
  71086. export var spritesPixelShader: {
  71087. name: string;
  71088. shader: string;
  71089. };
  71090. }
  71091. declare module BABYLON {
  71092. /** @hidden */
  71093. export var fogVertexDeclaration: {
  71094. name: string;
  71095. shader: string;
  71096. };
  71097. }
  71098. declare module BABYLON {
  71099. /** @hidden */
  71100. export var spritesVertexShader: {
  71101. name: string;
  71102. shader: string;
  71103. };
  71104. }
  71105. declare module BABYLON {
  71106. /**
  71107. * Defines the minimum interface to fullfil in order to be a sprite manager.
  71108. */
  71109. export interface ISpriteManager extends IDisposable {
  71110. /**
  71111. * Restricts the camera to viewing objects with the same layerMask.
  71112. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  71113. */
  71114. layerMask: number;
  71115. /**
  71116. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  71117. */
  71118. isPickable: boolean;
  71119. /**
  71120. * Specifies the rendering group id for this mesh (0 by default)
  71121. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  71122. */
  71123. renderingGroupId: number;
  71124. /**
  71125. * Defines the list of sprites managed by the manager.
  71126. */
  71127. sprites: Array<Sprite>;
  71128. /**
  71129. * Tests the intersection of a sprite with a specific ray.
  71130. * @param ray The ray we are sending to test the collision
  71131. * @param camera The camera space we are sending rays in
  71132. * @param predicate A predicate allowing excluding sprites from the list of object to test
  71133. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  71134. * @returns picking info or null.
  71135. */
  71136. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  71137. /**
  71138. * Renders the list of sprites on screen.
  71139. */
  71140. render(): void;
  71141. }
  71142. /**
  71143. * Class used to manage multiple sprites on the same spritesheet
  71144. * @see http://doc.babylonjs.com/babylon101/sprites
  71145. */
  71146. export class SpriteManager implements ISpriteManager {
  71147. /** defines the manager's name */
  71148. name: string;
  71149. /** Gets the list of sprites */
  71150. sprites: Sprite[];
  71151. /** Gets or sets the rendering group id (0 by default) */
  71152. renderingGroupId: number;
  71153. /** Gets or sets camera layer mask */
  71154. layerMask: number;
  71155. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  71156. fogEnabled: boolean;
  71157. /** Gets or sets a boolean indicating if the sprites are pickable */
  71158. isPickable: boolean;
  71159. /** Defines the default width of a cell in the spritesheet */
  71160. cellWidth: number;
  71161. /** Defines the default height of a cell in the spritesheet */
  71162. cellHeight: number;
  71163. /**
  71164. * An event triggered when the manager is disposed.
  71165. */
  71166. onDisposeObservable: Observable<SpriteManager>;
  71167. private _onDisposeObserver;
  71168. /**
  71169. * Callback called when the manager is disposed
  71170. */
  71171. onDispose: () => void;
  71172. private _capacity;
  71173. private _spriteTexture;
  71174. private _epsilon;
  71175. private _scene;
  71176. private _vertexData;
  71177. private _buffer;
  71178. private _vertexBuffers;
  71179. private _indexBuffer;
  71180. private _effectBase;
  71181. private _effectFog;
  71182. /**
  71183. * Gets or sets the spritesheet texture
  71184. */
  71185. texture: Texture;
  71186. /**
  71187. * Creates a new sprite manager
  71188. * @param name defines the manager's name
  71189. * @param imgUrl defines the sprite sheet url
  71190. * @param capacity defines the maximum allowed number of sprites
  71191. * @param cellSize defines the size of a sprite cell
  71192. * @param scene defines the hosting scene
  71193. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  71194. * @param samplingMode defines the smapling mode to use with spritesheet
  71195. */
  71196. constructor(
  71197. /** defines the manager's name */
  71198. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  71199. private _appendSpriteVertex;
  71200. /**
  71201. * Intersects the sprites with a ray
  71202. * @param ray defines the ray to intersect with
  71203. * @param camera defines the current active camera
  71204. * @param predicate defines a predicate used to select candidate sprites
  71205. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  71206. * @returns null if no hit or a PickingInfo
  71207. */
  71208. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  71209. /**
  71210. * Render all child sprites
  71211. */
  71212. render(): void;
  71213. /**
  71214. * Release associated resources
  71215. */
  71216. dispose(): void;
  71217. }
  71218. }
  71219. declare module BABYLON {
  71220. /**
  71221. * Class used to represent a sprite
  71222. * @see http://doc.babylonjs.com/babylon101/sprites
  71223. */
  71224. export class Sprite {
  71225. /** defines the name */
  71226. name: string;
  71227. /** Gets or sets the current world position */
  71228. position: Vector3;
  71229. /** Gets or sets the main color */
  71230. color: Color4;
  71231. /** Gets or sets the width */
  71232. width: number;
  71233. /** Gets or sets the height */
  71234. height: number;
  71235. /** Gets or sets rotation angle */
  71236. angle: number;
  71237. /** Gets or sets the cell index in the sprite sheet */
  71238. cellIndex: number;
  71239. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  71240. invertU: number;
  71241. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  71242. invertV: number;
  71243. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  71244. disposeWhenFinishedAnimating: boolean;
  71245. /** Gets the list of attached animations */
  71246. animations: Animation[];
  71247. /** Gets or sets a boolean indicating if the sprite can be picked */
  71248. isPickable: boolean;
  71249. /**
  71250. * Gets or sets the associated action manager
  71251. */
  71252. actionManager: Nullable<ActionManager>;
  71253. private _animationStarted;
  71254. private _loopAnimation;
  71255. private _fromIndex;
  71256. private _toIndex;
  71257. private _delay;
  71258. private _direction;
  71259. private _manager;
  71260. private _time;
  71261. private _onAnimationEnd;
  71262. /**
  71263. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  71264. */
  71265. isVisible: boolean;
  71266. /**
  71267. * Gets or sets the sprite size
  71268. */
  71269. size: number;
  71270. /**
  71271. * Creates a new Sprite
  71272. * @param name defines the name
  71273. * @param manager defines the manager
  71274. */
  71275. constructor(
  71276. /** defines the name */
  71277. name: string, manager: ISpriteManager);
  71278. /**
  71279. * Starts an animation
  71280. * @param from defines the initial key
  71281. * @param to defines the end key
  71282. * @param loop defines if the animation must loop
  71283. * @param delay defines the start delay (in ms)
  71284. * @param onAnimationEnd defines a callback to call when animation ends
  71285. */
  71286. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  71287. /** Stops current animation (if any) */
  71288. stopAnimation(): void;
  71289. /** @hidden */
  71290. _animate(deltaTime: number): void;
  71291. /** Release associated resources */
  71292. dispose(): void;
  71293. }
  71294. }
  71295. declare module BABYLON {
  71296. /**
  71297. * Information about the result of picking within a scene
  71298. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  71299. */
  71300. export class PickingInfo {
  71301. /** @hidden */
  71302. _pickingUnavailable: boolean;
  71303. /**
  71304. * If the pick collided with an object
  71305. */
  71306. hit: boolean;
  71307. /**
  71308. * Distance away where the pick collided
  71309. */
  71310. distance: number;
  71311. /**
  71312. * The location of pick collision
  71313. */
  71314. pickedPoint: Nullable<Vector3>;
  71315. /**
  71316. * The mesh corresponding the the pick collision
  71317. */
  71318. pickedMesh: Nullable<AbstractMesh>;
  71319. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  71320. bu: number;
  71321. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  71322. bv: number;
  71323. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  71324. faceId: number;
  71325. /** Id of the the submesh that was picked */
  71326. subMeshId: number;
  71327. /** If a sprite was picked, this will be the sprite the pick collided with */
  71328. pickedSprite: Nullable<Sprite>;
  71329. /**
  71330. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  71331. */
  71332. originMesh: Nullable<AbstractMesh>;
  71333. /**
  71334. * The ray that was used to perform the picking.
  71335. */
  71336. ray: Nullable<Ray>;
  71337. /**
  71338. * Gets the normal correspodning to the face the pick collided with
  71339. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  71340. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  71341. * @returns The normal correspodning to the face the pick collided with
  71342. */
  71343. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  71344. /**
  71345. * Gets the texture coordinates of where the pick occured
  71346. * @returns the vector containing the coordnates of the texture
  71347. */
  71348. getTextureCoordinates(): Nullable<Vector2>;
  71349. }
  71350. }
  71351. declare module BABYLON {
  71352. /**
  71353. * Gather the list of pointer event types as constants.
  71354. */
  71355. export class PointerEventTypes {
  71356. /**
  71357. * 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.
  71358. */
  71359. static readonly POINTERDOWN: number;
  71360. /**
  71361. * The pointerup event is fired when a pointer is no longer active.
  71362. */
  71363. static readonly POINTERUP: number;
  71364. /**
  71365. * The pointermove event is fired when a pointer changes coordinates.
  71366. */
  71367. static readonly POINTERMOVE: number;
  71368. /**
  71369. * The pointerwheel event is fired when a mouse wheel has been rotated.
  71370. */
  71371. static readonly POINTERWHEEL: number;
  71372. /**
  71373. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  71374. */
  71375. static readonly POINTERPICK: number;
  71376. /**
  71377. * The pointertap event is fired when a the object has been touched and released without drag.
  71378. */
  71379. static readonly POINTERTAP: number;
  71380. /**
  71381. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  71382. */
  71383. static readonly POINTERDOUBLETAP: number;
  71384. }
  71385. /**
  71386. * Base class of pointer info types.
  71387. */
  71388. export class PointerInfoBase {
  71389. /**
  71390. * Defines the type of event (PointerEventTypes)
  71391. */
  71392. type: number;
  71393. /**
  71394. * Defines the related dom event
  71395. */
  71396. event: PointerEvent | MouseWheelEvent;
  71397. /**
  71398. * Instantiates the base class of pointers info.
  71399. * @param type Defines the type of event (PointerEventTypes)
  71400. * @param event Defines the related dom event
  71401. */
  71402. constructor(
  71403. /**
  71404. * Defines the type of event (PointerEventTypes)
  71405. */
  71406. type: number,
  71407. /**
  71408. * Defines the related dom event
  71409. */
  71410. event: PointerEvent | MouseWheelEvent);
  71411. }
  71412. /**
  71413. * This class is used to store pointer related info for the onPrePointerObservable event.
  71414. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  71415. */
  71416. export class PointerInfoPre extends PointerInfoBase {
  71417. /**
  71418. * Ray from a pointer if availible (eg. 6dof controller)
  71419. */
  71420. ray: Nullable<Ray>;
  71421. /**
  71422. * Defines the local position of the pointer on the canvas.
  71423. */
  71424. localPosition: Vector2;
  71425. /**
  71426. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  71427. */
  71428. skipOnPointerObservable: boolean;
  71429. /**
  71430. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  71431. * @param type Defines the type of event (PointerEventTypes)
  71432. * @param event Defines the related dom event
  71433. * @param localX Defines the local x coordinates of the pointer when the event occured
  71434. * @param localY Defines the local y coordinates of the pointer when the event occured
  71435. */
  71436. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  71437. }
  71438. /**
  71439. * This type contains all the data related to a pointer event in Babylon.js.
  71440. * 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.
  71441. */
  71442. export class PointerInfo extends PointerInfoBase {
  71443. /**
  71444. * Defines the picking info associated to the info (if any)\
  71445. */
  71446. pickInfo: Nullable<PickingInfo>;
  71447. /**
  71448. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  71449. * @param type Defines the type of event (PointerEventTypes)
  71450. * @param event Defines the related dom event
  71451. * @param pickInfo Defines the picking info associated to the info (if any)\
  71452. */
  71453. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  71454. /**
  71455. * Defines the picking info associated to the info (if any)\
  71456. */
  71457. pickInfo: Nullable<PickingInfo>);
  71458. }
  71459. /**
  71460. * Data relating to a touch event on the screen.
  71461. */
  71462. export interface PointerTouch {
  71463. /**
  71464. * X coordinate of touch.
  71465. */
  71466. x: number;
  71467. /**
  71468. * Y coordinate of touch.
  71469. */
  71470. y: number;
  71471. /**
  71472. * Id of touch. Unique for each finger.
  71473. */
  71474. pointerId: number;
  71475. /**
  71476. * Event type passed from DOM.
  71477. */
  71478. type: any;
  71479. }
  71480. }
  71481. declare module BABYLON {
  71482. /**
  71483. * Manage the mouse inputs to control the movement of a free camera.
  71484. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71485. */
  71486. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  71487. /**
  71488. * Define if touch is enabled in the mouse input
  71489. */
  71490. touchEnabled: boolean;
  71491. /**
  71492. * Defines the camera the input is attached to.
  71493. */
  71494. camera: FreeCamera;
  71495. /**
  71496. * Defines the buttons associated with the input to handle camera move.
  71497. */
  71498. buttons: number[];
  71499. /**
  71500. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  71501. */
  71502. angularSensibility: number;
  71503. private _pointerInput;
  71504. private _onMouseMove;
  71505. private _observer;
  71506. private previousPosition;
  71507. /**
  71508. * Observable for when a pointer move event occurs containing the move offset
  71509. */
  71510. onPointerMovedObservable: Observable<{
  71511. offsetX: number;
  71512. offsetY: number;
  71513. }>;
  71514. /**
  71515. * @hidden
  71516. * If the camera should be rotated automatically based on pointer movement
  71517. */
  71518. _allowCameraRotation: boolean;
  71519. /**
  71520. * Manage the mouse inputs to control the movement of a free camera.
  71521. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71522. * @param touchEnabled Defines if touch is enabled or not
  71523. */
  71524. constructor(
  71525. /**
  71526. * Define if touch is enabled in the mouse input
  71527. */
  71528. touchEnabled?: boolean);
  71529. /**
  71530. * Attach the input controls to a specific dom element to get the input from.
  71531. * @param element Defines the element the controls should be listened from
  71532. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71533. */
  71534. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71535. /**
  71536. * Called on JS contextmenu event.
  71537. * Override this method to provide functionality.
  71538. */
  71539. protected onContextMenu(evt: PointerEvent): void;
  71540. /**
  71541. * Detach the current controls from the specified dom element.
  71542. * @param element Defines the element to stop listening the inputs from
  71543. */
  71544. detachControl(element: Nullable<HTMLElement>): void;
  71545. /**
  71546. * Gets the class name of the current intput.
  71547. * @returns the class name
  71548. */
  71549. getClassName(): string;
  71550. /**
  71551. * Get the friendly name associated with the input class.
  71552. * @returns the input friendly name
  71553. */
  71554. getSimpleName(): string;
  71555. }
  71556. }
  71557. declare module BABYLON {
  71558. /**
  71559. * Manage the touch inputs to control the movement of a free camera.
  71560. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71561. */
  71562. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  71563. /**
  71564. * Defines the camera the input is attached to.
  71565. */
  71566. camera: FreeCamera;
  71567. /**
  71568. * Defines the touch sensibility for rotation.
  71569. * The higher the faster.
  71570. */
  71571. touchAngularSensibility: number;
  71572. /**
  71573. * Defines the touch sensibility for move.
  71574. * The higher the faster.
  71575. */
  71576. touchMoveSensibility: number;
  71577. private _offsetX;
  71578. private _offsetY;
  71579. private _pointerPressed;
  71580. private _pointerInput;
  71581. private _observer;
  71582. private _onLostFocus;
  71583. /**
  71584. * Attach the input controls to a specific dom element to get the input from.
  71585. * @param element Defines the element the controls should be listened from
  71586. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71587. */
  71588. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71589. /**
  71590. * Detach the current controls from the specified dom element.
  71591. * @param element Defines the element to stop listening the inputs from
  71592. */
  71593. detachControl(element: Nullable<HTMLElement>): void;
  71594. /**
  71595. * Update the current camera state depending on the inputs that have been used this frame.
  71596. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71597. */
  71598. checkInputs(): void;
  71599. /**
  71600. * Gets the class name of the current intput.
  71601. * @returns the class name
  71602. */
  71603. getClassName(): string;
  71604. /**
  71605. * Get the friendly name associated with the input class.
  71606. * @returns the input friendly name
  71607. */
  71608. getSimpleName(): string;
  71609. }
  71610. }
  71611. declare module BABYLON {
  71612. /**
  71613. * Default Inputs manager for the FreeCamera.
  71614. * It groups all the default supported inputs for ease of use.
  71615. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71616. */
  71617. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  71618. /**
  71619. * @hidden
  71620. */
  71621. _keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  71622. /**
  71623. * @hidden
  71624. */
  71625. _mouseInput: Nullable<FreeCameraMouseInput>;
  71626. /**
  71627. * Instantiates a new FreeCameraInputsManager.
  71628. * @param camera Defines the camera the inputs belong to
  71629. */
  71630. constructor(camera: FreeCamera);
  71631. /**
  71632. * Add keyboard input support to the input manager.
  71633. * @returns the current input manager
  71634. */
  71635. addKeyboard(): FreeCameraInputsManager;
  71636. /**
  71637. * Add mouse input support to the input manager.
  71638. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  71639. * @returns the current input manager
  71640. */
  71641. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  71642. /**
  71643. * Removes the mouse input support from the manager
  71644. * @returns the current input manager
  71645. */
  71646. removeMouse(): FreeCameraInputsManager;
  71647. /**
  71648. * Add touch input support to the input manager.
  71649. * @returns the current input manager
  71650. */
  71651. addTouch(): FreeCameraInputsManager;
  71652. }
  71653. }
  71654. declare module BABYLON {
  71655. /**
  71656. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  71657. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  71658. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  71659. */
  71660. export class FreeCamera extends TargetCamera {
  71661. /**
  71662. * Define the collision ellipsoid of the camera.
  71663. * This is helpful to simulate a camera body like the player body around the camera
  71664. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  71665. */
  71666. ellipsoid: Vector3;
  71667. /**
  71668. * Define an offset for the position of the ellipsoid around the camera.
  71669. * This can be helpful to determine the center of the body near the gravity center of the body
  71670. * instead of its head.
  71671. */
  71672. ellipsoidOffset: Vector3;
  71673. /**
  71674. * Enable or disable collisions of the camera with the rest of the scene objects.
  71675. */
  71676. checkCollisions: boolean;
  71677. /**
  71678. * Enable or disable gravity on the camera.
  71679. */
  71680. applyGravity: boolean;
  71681. /**
  71682. * Define the input manager associated to the camera.
  71683. */
  71684. inputs: FreeCameraInputsManager;
  71685. /**
  71686. * Gets the input sensibility for a mouse input. (default is 2000.0)
  71687. * Higher values reduce sensitivity.
  71688. */
  71689. /**
  71690. * Sets the input sensibility for a mouse input. (default is 2000.0)
  71691. * Higher values reduce sensitivity.
  71692. */
  71693. angularSensibility: number;
  71694. /**
  71695. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  71696. */
  71697. keysUp: number[];
  71698. /**
  71699. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  71700. */
  71701. keysDown: number[];
  71702. /**
  71703. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  71704. */
  71705. keysLeft: number[];
  71706. /**
  71707. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  71708. */
  71709. keysRight: number[];
  71710. /**
  71711. * Event raised when the camera collide with a mesh in the scene.
  71712. */
  71713. onCollide: (collidedMesh: AbstractMesh) => void;
  71714. private _collider;
  71715. private _needMoveForGravity;
  71716. private _oldPosition;
  71717. private _diffPosition;
  71718. private _newPosition;
  71719. /** @hidden */
  71720. _localDirection: Vector3;
  71721. /** @hidden */
  71722. _transformedDirection: Vector3;
  71723. /**
  71724. * Instantiates a Free Camera.
  71725. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  71726. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  71727. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  71728. * @param name Define the name of the camera in the scene
  71729. * @param position Define the start position of the camera in the scene
  71730. * @param scene Define the scene the camera belongs to
  71731. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  71732. */
  71733. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  71734. /**
  71735. * Attached controls to the current camera.
  71736. * @param element Defines the element the controls should be listened from
  71737. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71738. */
  71739. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71740. /**
  71741. * Detach the current controls from the camera.
  71742. * The camera will stop reacting to inputs.
  71743. * @param element Defines the element to stop listening the inputs from
  71744. */
  71745. detachControl(element: HTMLElement): void;
  71746. private _collisionMask;
  71747. /**
  71748. * Define a collision mask to limit the list of object the camera can collide with
  71749. */
  71750. collisionMask: number;
  71751. /** @hidden */
  71752. _collideWithWorld(displacement: Vector3): void;
  71753. private _onCollisionPositionChange;
  71754. /** @hidden */
  71755. _checkInputs(): void;
  71756. /** @hidden */
  71757. _decideIfNeedsToMove(): boolean;
  71758. /** @hidden */
  71759. _updatePosition(): void;
  71760. /**
  71761. * Destroy the camera and release the current resources hold by it.
  71762. */
  71763. dispose(): void;
  71764. /**
  71765. * Gets the current object class name.
  71766. * @return the class name
  71767. */
  71768. getClassName(): string;
  71769. }
  71770. }
  71771. declare module BABYLON {
  71772. /**
  71773. * Represents a gamepad control stick position
  71774. */
  71775. export class StickValues {
  71776. /**
  71777. * The x component of the control stick
  71778. */
  71779. x: number;
  71780. /**
  71781. * The y component of the control stick
  71782. */
  71783. y: number;
  71784. /**
  71785. * Initializes the gamepad x and y control stick values
  71786. * @param x The x component of the gamepad control stick value
  71787. * @param y The y component of the gamepad control stick value
  71788. */
  71789. constructor(
  71790. /**
  71791. * The x component of the control stick
  71792. */
  71793. x: number,
  71794. /**
  71795. * The y component of the control stick
  71796. */
  71797. y: number);
  71798. }
  71799. /**
  71800. * An interface which manages callbacks for gamepad button changes
  71801. */
  71802. export interface GamepadButtonChanges {
  71803. /**
  71804. * Called when a gamepad has been changed
  71805. */
  71806. changed: boolean;
  71807. /**
  71808. * Called when a gamepad press event has been triggered
  71809. */
  71810. pressChanged: boolean;
  71811. /**
  71812. * Called when a touch event has been triggered
  71813. */
  71814. touchChanged: boolean;
  71815. /**
  71816. * Called when a value has changed
  71817. */
  71818. valueChanged: boolean;
  71819. }
  71820. /**
  71821. * Represents a gamepad
  71822. */
  71823. export class Gamepad {
  71824. /**
  71825. * The id of the gamepad
  71826. */
  71827. id: string;
  71828. /**
  71829. * The index of the gamepad
  71830. */
  71831. index: number;
  71832. /**
  71833. * The browser gamepad
  71834. */
  71835. browserGamepad: any;
  71836. /**
  71837. * Specifies what type of gamepad this represents
  71838. */
  71839. type: number;
  71840. private _leftStick;
  71841. private _rightStick;
  71842. /** @hidden */
  71843. _isConnected: boolean;
  71844. private _leftStickAxisX;
  71845. private _leftStickAxisY;
  71846. private _rightStickAxisX;
  71847. private _rightStickAxisY;
  71848. /**
  71849. * Triggered when the left control stick has been changed
  71850. */
  71851. private _onleftstickchanged;
  71852. /**
  71853. * Triggered when the right control stick has been changed
  71854. */
  71855. private _onrightstickchanged;
  71856. /**
  71857. * Represents a gamepad controller
  71858. */
  71859. static GAMEPAD: number;
  71860. /**
  71861. * Represents a generic controller
  71862. */
  71863. static GENERIC: number;
  71864. /**
  71865. * Represents an XBox controller
  71866. */
  71867. static XBOX: number;
  71868. /**
  71869. * Represents a pose-enabled controller
  71870. */
  71871. static POSE_ENABLED: number;
  71872. /**
  71873. * Specifies whether the left control stick should be Y-inverted
  71874. */
  71875. protected _invertLeftStickY: boolean;
  71876. /**
  71877. * Specifies if the gamepad has been connected
  71878. */
  71879. readonly isConnected: boolean;
  71880. /**
  71881. * Initializes the gamepad
  71882. * @param id The id of the gamepad
  71883. * @param index The index of the gamepad
  71884. * @param browserGamepad The browser gamepad
  71885. * @param leftStickX The x component of the left joystick
  71886. * @param leftStickY The y component of the left joystick
  71887. * @param rightStickX The x component of the right joystick
  71888. * @param rightStickY The y component of the right joystick
  71889. */
  71890. constructor(
  71891. /**
  71892. * The id of the gamepad
  71893. */
  71894. id: string,
  71895. /**
  71896. * The index of the gamepad
  71897. */
  71898. index: number,
  71899. /**
  71900. * The browser gamepad
  71901. */
  71902. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  71903. /**
  71904. * Callback triggered when the left joystick has changed
  71905. * @param callback
  71906. */
  71907. onleftstickchanged(callback: (values: StickValues) => void): void;
  71908. /**
  71909. * Callback triggered when the right joystick has changed
  71910. * @param callback
  71911. */
  71912. onrightstickchanged(callback: (values: StickValues) => void): void;
  71913. /**
  71914. * Gets the left joystick
  71915. */
  71916. /**
  71917. * Sets the left joystick values
  71918. */
  71919. leftStick: StickValues;
  71920. /**
  71921. * Gets the right joystick
  71922. */
  71923. /**
  71924. * Sets the right joystick value
  71925. */
  71926. rightStick: StickValues;
  71927. /**
  71928. * Updates the gamepad joystick positions
  71929. */
  71930. update(): void;
  71931. /**
  71932. * Disposes the gamepad
  71933. */
  71934. dispose(): void;
  71935. }
  71936. /**
  71937. * Represents a generic gamepad
  71938. */
  71939. export class GenericPad extends Gamepad {
  71940. private _buttons;
  71941. private _onbuttondown;
  71942. private _onbuttonup;
  71943. /**
  71944. * Observable triggered when a button has been pressed
  71945. */
  71946. onButtonDownObservable: Observable<number>;
  71947. /**
  71948. * Observable triggered when a button has been released
  71949. */
  71950. onButtonUpObservable: Observable<number>;
  71951. /**
  71952. * Callback triggered when a button has been pressed
  71953. * @param callback Called when a button has been pressed
  71954. */
  71955. onbuttondown(callback: (buttonPressed: number) => void): void;
  71956. /**
  71957. * Callback triggered when a button has been released
  71958. * @param callback Called when a button has been released
  71959. */
  71960. onbuttonup(callback: (buttonReleased: number) => void): void;
  71961. /**
  71962. * Initializes the generic gamepad
  71963. * @param id The id of the generic gamepad
  71964. * @param index The index of the generic gamepad
  71965. * @param browserGamepad The browser gamepad
  71966. */
  71967. constructor(id: string, index: number, browserGamepad: any);
  71968. private _setButtonValue;
  71969. /**
  71970. * Updates the generic gamepad
  71971. */
  71972. update(): void;
  71973. /**
  71974. * Disposes the generic gamepad
  71975. */
  71976. dispose(): void;
  71977. }
  71978. }
  71979. declare module BABYLON {
  71980. /**
  71981. * Defines the types of pose enabled controllers that are supported
  71982. */
  71983. export enum PoseEnabledControllerType {
  71984. /**
  71985. * HTC Vive
  71986. */
  71987. VIVE = 0,
  71988. /**
  71989. * Oculus Rift
  71990. */
  71991. OCULUS = 1,
  71992. /**
  71993. * Windows mixed reality
  71994. */
  71995. WINDOWS = 2,
  71996. /**
  71997. * Samsung gear VR
  71998. */
  71999. GEAR_VR = 3,
  72000. /**
  72001. * Google Daydream
  72002. */
  72003. DAYDREAM = 4,
  72004. /**
  72005. * Generic
  72006. */
  72007. GENERIC = 5
  72008. }
  72009. /**
  72010. * Defines the MutableGamepadButton interface for the state of a gamepad button
  72011. */
  72012. export interface MutableGamepadButton {
  72013. /**
  72014. * Value of the button/trigger
  72015. */
  72016. value: number;
  72017. /**
  72018. * If the button/trigger is currently touched
  72019. */
  72020. touched: boolean;
  72021. /**
  72022. * If the button/trigger is currently pressed
  72023. */
  72024. pressed: boolean;
  72025. }
  72026. /**
  72027. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  72028. * @hidden
  72029. */
  72030. export interface ExtendedGamepadButton extends GamepadButton {
  72031. /**
  72032. * If the button/trigger is currently pressed
  72033. */
  72034. readonly pressed: boolean;
  72035. /**
  72036. * If the button/trigger is currently touched
  72037. */
  72038. readonly touched: boolean;
  72039. /**
  72040. * Value of the button/trigger
  72041. */
  72042. readonly value: number;
  72043. }
  72044. /** @hidden */
  72045. export interface _GamePadFactory {
  72046. /**
  72047. * Returns wether or not the current gamepad can be created for this type of controller.
  72048. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  72049. * @returns true if it can be created, otherwise false
  72050. */
  72051. canCreate(gamepadInfo: any): boolean;
  72052. /**
  72053. * Creates a new instance of the Gamepad.
  72054. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  72055. * @returns the new gamepad instance
  72056. */
  72057. create(gamepadInfo: any): Gamepad;
  72058. }
  72059. /**
  72060. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  72061. */
  72062. export class PoseEnabledControllerHelper {
  72063. /** @hidden */
  72064. static _ControllerFactories: _GamePadFactory[];
  72065. /** @hidden */
  72066. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  72067. /**
  72068. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  72069. * @param vrGamepad the gamepad to initialized
  72070. * @returns a vr controller of the type the gamepad identified as
  72071. */
  72072. static InitiateController(vrGamepad: any): Gamepad;
  72073. }
  72074. /**
  72075. * Defines the PoseEnabledController object that contains state of a vr capable controller
  72076. */
  72077. export class PoseEnabledController extends Gamepad implements PoseControlled {
  72078. private _deviceRoomPosition;
  72079. private _deviceRoomRotationQuaternion;
  72080. /**
  72081. * The device position in babylon space
  72082. */
  72083. devicePosition: Vector3;
  72084. /**
  72085. * The device rotation in babylon space
  72086. */
  72087. deviceRotationQuaternion: Quaternion;
  72088. /**
  72089. * The scale factor of the device in babylon space
  72090. */
  72091. deviceScaleFactor: number;
  72092. /**
  72093. * (Likely devicePosition should be used instead) The device position in its room space
  72094. */
  72095. position: Vector3;
  72096. /**
  72097. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  72098. */
  72099. rotationQuaternion: Quaternion;
  72100. /**
  72101. * The type of controller (Eg. Windows mixed reality)
  72102. */
  72103. controllerType: PoseEnabledControllerType;
  72104. protected _calculatedPosition: Vector3;
  72105. private _calculatedRotation;
  72106. /**
  72107. * The raw pose from the device
  72108. */
  72109. rawPose: DevicePose;
  72110. private _trackPosition;
  72111. private _maxRotationDistFromHeadset;
  72112. private _draggedRoomRotation;
  72113. /**
  72114. * @hidden
  72115. */
  72116. _disableTrackPosition(fixedPosition: Vector3): void;
  72117. /**
  72118. * Internal, the mesh attached to the controller
  72119. * @hidden
  72120. */
  72121. _mesh: Nullable<AbstractMesh>;
  72122. private _poseControlledCamera;
  72123. private _leftHandSystemQuaternion;
  72124. /**
  72125. * Internal, matrix used to convert room space to babylon space
  72126. * @hidden
  72127. */
  72128. _deviceToWorld: Matrix;
  72129. /**
  72130. * Node to be used when casting a ray from the controller
  72131. * @hidden
  72132. */
  72133. _pointingPoseNode: Nullable<TransformNode>;
  72134. /**
  72135. * Name of the child mesh that can be used to cast a ray from the controller
  72136. */
  72137. static readonly POINTING_POSE: string;
  72138. /**
  72139. * Creates a new PoseEnabledController from a gamepad
  72140. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  72141. */
  72142. constructor(browserGamepad: any);
  72143. private _workingMatrix;
  72144. /**
  72145. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  72146. */
  72147. update(): void;
  72148. /**
  72149. * Updates only the pose device and mesh without doing any button event checking
  72150. */
  72151. protected _updatePoseAndMesh(): void;
  72152. /**
  72153. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  72154. * @param poseData raw pose fromthe device
  72155. */
  72156. updateFromDevice(poseData: DevicePose): void;
  72157. /**
  72158. * @hidden
  72159. */
  72160. _meshAttachedObservable: Observable<AbstractMesh>;
  72161. /**
  72162. * Attaches a mesh to the controller
  72163. * @param mesh the mesh to be attached
  72164. */
  72165. attachToMesh(mesh: AbstractMesh): void;
  72166. /**
  72167. * Attaches the controllers mesh to a camera
  72168. * @param camera the camera the mesh should be attached to
  72169. */
  72170. attachToPoseControlledCamera(camera: TargetCamera): void;
  72171. /**
  72172. * Disposes of the controller
  72173. */
  72174. dispose(): void;
  72175. /**
  72176. * The mesh that is attached to the controller
  72177. */
  72178. readonly mesh: Nullable<AbstractMesh>;
  72179. /**
  72180. * Gets the ray of the controller in the direction the controller is pointing
  72181. * @param length the length the resulting ray should be
  72182. * @returns a ray in the direction the controller is pointing
  72183. */
  72184. getForwardRay(length?: number): Ray;
  72185. }
  72186. }
  72187. declare module BABYLON {
  72188. /**
  72189. * Defines the WebVRController object that represents controllers tracked in 3D space
  72190. */
  72191. export abstract class WebVRController extends PoseEnabledController {
  72192. /**
  72193. * Internal, the default controller model for the controller
  72194. */
  72195. protected _defaultModel: AbstractMesh;
  72196. /**
  72197. * Fired when the trigger state has changed
  72198. */
  72199. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  72200. /**
  72201. * Fired when the main button state has changed
  72202. */
  72203. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  72204. /**
  72205. * Fired when the secondary button state has changed
  72206. */
  72207. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  72208. /**
  72209. * Fired when the pad state has changed
  72210. */
  72211. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  72212. /**
  72213. * Fired when controllers stick values have changed
  72214. */
  72215. onPadValuesChangedObservable: Observable<StickValues>;
  72216. /**
  72217. * Array of button availible on the controller
  72218. */
  72219. protected _buttons: Array<MutableGamepadButton>;
  72220. private _onButtonStateChange;
  72221. /**
  72222. * Fired when a controller button's state has changed
  72223. * @param callback the callback containing the button that was modified
  72224. */
  72225. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  72226. /**
  72227. * X and Y axis corrisponding to the controllers joystick
  72228. */
  72229. pad: StickValues;
  72230. /**
  72231. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  72232. */
  72233. hand: string;
  72234. /**
  72235. * The default controller model for the controller
  72236. */
  72237. readonly defaultModel: AbstractMesh;
  72238. /**
  72239. * Creates a new WebVRController from a gamepad
  72240. * @param vrGamepad the gamepad that the WebVRController should be created from
  72241. */
  72242. constructor(vrGamepad: any);
  72243. /**
  72244. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  72245. */
  72246. update(): void;
  72247. /**
  72248. * Function to be called when a button is modified
  72249. */
  72250. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  72251. /**
  72252. * Loads a mesh and attaches it to the controller
  72253. * @param scene the scene the mesh should be added to
  72254. * @param meshLoaded callback for when the mesh has been loaded
  72255. */
  72256. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  72257. private _setButtonValue;
  72258. private _changes;
  72259. private _checkChanges;
  72260. /**
  72261. * Disposes of th webVRCOntroller
  72262. */
  72263. dispose(): void;
  72264. }
  72265. }
  72266. declare module BABYLON {
  72267. /**
  72268. * The HemisphericLight simulates the ambient environment light,
  72269. * so the passed direction is the light reflection direction, not the incoming direction.
  72270. */
  72271. export class HemisphericLight extends Light {
  72272. /**
  72273. * The groundColor is the light in the opposite direction to the one specified during creation.
  72274. * 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.
  72275. */
  72276. groundColor: Color3;
  72277. /**
  72278. * The light reflection direction, not the incoming direction.
  72279. */
  72280. direction: Vector3;
  72281. /**
  72282. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  72283. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  72284. * The HemisphericLight can't cast shadows.
  72285. * Documentation : https://doc.babylonjs.com/babylon101/lights
  72286. * @param name The friendly name of the light
  72287. * @param direction The direction of the light reflection
  72288. * @param scene The scene the light belongs to
  72289. */
  72290. constructor(name: string, direction: Vector3, scene: Scene);
  72291. protected _buildUniformLayout(): void;
  72292. /**
  72293. * Returns the string "HemisphericLight".
  72294. * @return The class name
  72295. */
  72296. getClassName(): string;
  72297. /**
  72298. * Sets the HemisphericLight direction towards the passed target (Vector3).
  72299. * Returns the updated direction.
  72300. * @param target The target the direction should point to
  72301. * @return The computed direction
  72302. */
  72303. setDirectionToTarget(target: Vector3): Vector3;
  72304. /**
  72305. * Returns the shadow generator associated to the light.
  72306. * @returns Always null for hemispheric lights because it does not support shadows.
  72307. */
  72308. getShadowGenerator(): Nullable<IShadowGenerator>;
  72309. /**
  72310. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  72311. * @param effect The effect to update
  72312. * @param lightIndex The index of the light in the effect to update
  72313. * @returns The hemispheric light
  72314. */
  72315. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  72316. /**
  72317. * Computes the world matrix of the node
  72318. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  72319. * @param useWasUpdatedFlag defines a reserved property
  72320. * @returns the world matrix
  72321. */
  72322. computeWorldMatrix(): Matrix;
  72323. /**
  72324. * Returns the integer 3.
  72325. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  72326. */
  72327. getTypeID(): number;
  72328. /**
  72329. * Prepares the list of defines specific to the light type.
  72330. * @param defines the list of defines
  72331. * @param lightIndex defines the index of the light for the effect
  72332. */
  72333. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  72334. }
  72335. }
  72336. declare module BABYLON {
  72337. /** @hidden */
  72338. export var vrMultiviewToSingleviewPixelShader: {
  72339. name: string;
  72340. shader: string;
  72341. };
  72342. }
  72343. declare module BABYLON {
  72344. /**
  72345. * Renders to multiple views with a single draw call
  72346. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  72347. */
  72348. export class MultiviewRenderTarget extends RenderTargetTexture {
  72349. /**
  72350. * Creates a multiview render target
  72351. * @param scene scene used with the render target
  72352. * @param size the size of the render target (used for each view)
  72353. */
  72354. constructor(scene: Scene, size?: number | {
  72355. width: number;
  72356. height: number;
  72357. } | {
  72358. ratio: number;
  72359. });
  72360. /**
  72361. * @hidden
  72362. * @param faceIndex the face index, if its a cube texture
  72363. */
  72364. _bindFrameBuffer(faceIndex?: number): void;
  72365. /**
  72366. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  72367. * @returns the view count
  72368. */
  72369. getViewCount(): number;
  72370. }
  72371. }
  72372. declare module BABYLON {
  72373. interface Engine {
  72374. /**
  72375. * Creates a new multiview render target
  72376. * @param width defines the width of the texture
  72377. * @param height defines the height of the texture
  72378. * @returns the created multiview texture
  72379. */
  72380. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  72381. /**
  72382. * Binds a multiview framebuffer to be drawn to
  72383. * @param multiviewTexture texture to bind
  72384. */
  72385. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  72386. }
  72387. interface Camera {
  72388. /**
  72389. * @hidden
  72390. * 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)
  72391. */
  72392. _useMultiviewToSingleView: boolean;
  72393. /**
  72394. * @hidden
  72395. * 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)
  72396. */
  72397. _multiviewTexture: Nullable<RenderTargetTexture>;
  72398. /**
  72399. * @hidden
  72400. * ensures the multiview texture of the camera exists and has the specified width/height
  72401. * @param width height to set on the multiview texture
  72402. * @param height width to set on the multiview texture
  72403. */
  72404. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  72405. }
  72406. interface Scene {
  72407. /** @hidden */
  72408. _transformMatrixR: Matrix;
  72409. /** @hidden */
  72410. _multiviewSceneUbo: Nullable<UniformBuffer>;
  72411. /** @hidden */
  72412. _createMultiviewUbo(): void;
  72413. /** @hidden */
  72414. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  72415. /** @hidden */
  72416. _renderMultiviewToSingleView(camera: Camera): void;
  72417. }
  72418. }
  72419. declare module BABYLON {
  72420. /**
  72421. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  72422. * This will not be used for webXR as it supports displaying texture arrays directly
  72423. */
  72424. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  72425. /**
  72426. * Initializes a VRMultiviewToSingleview
  72427. * @param name name of the post process
  72428. * @param camera camera to be applied to
  72429. * @param scaleFactor scaling factor to the size of the output texture
  72430. */
  72431. constructor(name: string, camera: Camera, scaleFactor: number);
  72432. }
  72433. }
  72434. declare module BABYLON {
  72435. /**
  72436. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  72437. * IMPORTANT!! The data is right-hand data.
  72438. * @export
  72439. * @interface DevicePose
  72440. */
  72441. export interface DevicePose {
  72442. /**
  72443. * The position of the device, values in array are [x,y,z].
  72444. */
  72445. readonly position: Nullable<Float32Array>;
  72446. /**
  72447. * The linearVelocity of the device, values in array are [x,y,z].
  72448. */
  72449. readonly linearVelocity: Nullable<Float32Array>;
  72450. /**
  72451. * The linearAcceleration of the device, values in array are [x,y,z].
  72452. */
  72453. readonly linearAcceleration: Nullable<Float32Array>;
  72454. /**
  72455. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  72456. */
  72457. readonly orientation: Nullable<Float32Array>;
  72458. /**
  72459. * The angularVelocity of the device, values in array are [x,y,z].
  72460. */
  72461. readonly angularVelocity: Nullable<Float32Array>;
  72462. /**
  72463. * The angularAcceleration of the device, values in array are [x,y,z].
  72464. */
  72465. readonly angularAcceleration: Nullable<Float32Array>;
  72466. }
  72467. /**
  72468. * Interface representing a pose controlled object in Babylon.
  72469. * A pose controlled object has both regular pose values as well as pose values
  72470. * from an external device such as a VR head mounted display
  72471. */
  72472. export interface PoseControlled {
  72473. /**
  72474. * The position of the object in babylon space.
  72475. */
  72476. position: Vector3;
  72477. /**
  72478. * The rotation quaternion of the object in babylon space.
  72479. */
  72480. rotationQuaternion: Quaternion;
  72481. /**
  72482. * The position of the device in babylon space.
  72483. */
  72484. devicePosition?: Vector3;
  72485. /**
  72486. * The rotation quaternion of the device in babylon space.
  72487. */
  72488. deviceRotationQuaternion: Quaternion;
  72489. /**
  72490. * The raw pose coming from the device.
  72491. */
  72492. rawPose: Nullable<DevicePose>;
  72493. /**
  72494. * The scale of the device to be used when translating from device space to babylon space.
  72495. */
  72496. deviceScaleFactor: number;
  72497. /**
  72498. * Updates the poseControlled values based on the input device pose.
  72499. * @param poseData the pose data to update the object with
  72500. */
  72501. updateFromDevice(poseData: DevicePose): void;
  72502. }
  72503. /**
  72504. * Set of options to customize the webVRCamera
  72505. */
  72506. export interface WebVROptions {
  72507. /**
  72508. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  72509. */
  72510. trackPosition?: boolean;
  72511. /**
  72512. * Sets the scale of the vrDevice in babylon space. (default: 1)
  72513. */
  72514. positionScale?: number;
  72515. /**
  72516. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  72517. */
  72518. displayName?: string;
  72519. /**
  72520. * Should the native controller meshes be initialized. (default: true)
  72521. */
  72522. controllerMeshes?: boolean;
  72523. /**
  72524. * Creating a default HemiLight only on controllers. (default: true)
  72525. */
  72526. defaultLightingOnControllers?: boolean;
  72527. /**
  72528. * If you don't want to use the default VR button of the helper. (default: false)
  72529. */
  72530. useCustomVRButton?: boolean;
  72531. /**
  72532. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  72533. */
  72534. customVRButton?: HTMLButtonElement;
  72535. /**
  72536. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  72537. */
  72538. rayLength?: number;
  72539. /**
  72540. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  72541. */
  72542. defaultHeight?: number;
  72543. /**
  72544. * If multiview should be used if availible (default: false)
  72545. */
  72546. useMultiview?: boolean;
  72547. }
  72548. /**
  72549. * This represents a WebVR camera.
  72550. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  72551. * @example http://doc.babylonjs.com/how_to/webvr_camera
  72552. */
  72553. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  72554. private webVROptions;
  72555. /**
  72556. * @hidden
  72557. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  72558. */
  72559. _vrDevice: any;
  72560. /**
  72561. * The rawPose of the vrDevice.
  72562. */
  72563. rawPose: Nullable<DevicePose>;
  72564. private _onVREnabled;
  72565. private _specsVersion;
  72566. private _attached;
  72567. private _frameData;
  72568. protected _descendants: Array<Node>;
  72569. private _deviceRoomPosition;
  72570. /** @hidden */
  72571. _deviceRoomRotationQuaternion: Quaternion;
  72572. private _standingMatrix;
  72573. /**
  72574. * Represents device position in babylon space.
  72575. */
  72576. devicePosition: Vector3;
  72577. /**
  72578. * Represents device rotation in babylon space.
  72579. */
  72580. deviceRotationQuaternion: Quaternion;
  72581. /**
  72582. * The scale of the device to be used when translating from device space to babylon space.
  72583. */
  72584. deviceScaleFactor: number;
  72585. private _deviceToWorld;
  72586. private _worldToDevice;
  72587. /**
  72588. * References to the webVR controllers for the vrDevice.
  72589. */
  72590. controllers: Array<WebVRController>;
  72591. /**
  72592. * Emits an event when a controller is attached.
  72593. */
  72594. onControllersAttachedObservable: Observable<WebVRController[]>;
  72595. /**
  72596. * Emits an event when a controller's mesh has been loaded;
  72597. */
  72598. onControllerMeshLoadedObservable: Observable<WebVRController>;
  72599. /**
  72600. * Emits an event when the HMD's pose has been updated.
  72601. */
  72602. onPoseUpdatedFromDeviceObservable: Observable<any>;
  72603. private _poseSet;
  72604. /**
  72605. * If the rig cameras be used as parent instead of this camera.
  72606. */
  72607. rigParenting: boolean;
  72608. private _lightOnControllers;
  72609. private _defaultHeight?;
  72610. /**
  72611. * Instantiates a WebVRFreeCamera.
  72612. * @param name The name of the WebVRFreeCamera
  72613. * @param position The starting anchor position for the camera
  72614. * @param scene The scene the camera belongs to
  72615. * @param webVROptions a set of customizable options for the webVRCamera
  72616. */
  72617. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  72618. /**
  72619. * Gets the device distance from the ground in meters.
  72620. * @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.
  72621. */
  72622. deviceDistanceToRoomGround(): number;
  72623. /**
  72624. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  72625. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  72626. */
  72627. useStandingMatrix(callback?: (bool: boolean) => void): void;
  72628. /**
  72629. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  72630. * @returns A promise with a boolean set to if the standing matrix is supported.
  72631. */
  72632. useStandingMatrixAsync(): Promise<boolean>;
  72633. /**
  72634. * Disposes the camera
  72635. */
  72636. dispose(): void;
  72637. /**
  72638. * Gets a vrController by name.
  72639. * @param name The name of the controller to retreive
  72640. * @returns the controller matching the name specified or null if not found
  72641. */
  72642. getControllerByName(name: string): Nullable<WebVRController>;
  72643. private _leftController;
  72644. /**
  72645. * The controller corrisponding to the users left hand.
  72646. */
  72647. readonly leftController: Nullable<WebVRController>;
  72648. private _rightController;
  72649. /**
  72650. * The controller corrisponding to the users right hand.
  72651. */
  72652. readonly rightController: Nullable<WebVRController>;
  72653. /**
  72654. * Casts a ray forward from the vrCamera's gaze.
  72655. * @param length Length of the ray (default: 100)
  72656. * @returns the ray corrisponding to the gaze
  72657. */
  72658. getForwardRay(length?: number): Ray;
  72659. /**
  72660. * @hidden
  72661. * Updates the camera based on device's frame data
  72662. */
  72663. _checkInputs(): void;
  72664. /**
  72665. * Updates the poseControlled values based on the input device pose.
  72666. * @param poseData Pose coming from the device
  72667. */
  72668. updateFromDevice(poseData: DevicePose): void;
  72669. private _htmlElementAttached;
  72670. private _detachIfAttached;
  72671. /**
  72672. * WebVR's attach control will start broadcasting frames to the device.
  72673. * Note that in certain browsers (chrome for example) this function must be called
  72674. * within a user-interaction callback. Example:
  72675. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  72676. *
  72677. * @param element html element to attach the vrDevice to
  72678. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  72679. */
  72680. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72681. /**
  72682. * Detaches the camera from the html element and disables VR
  72683. *
  72684. * @param element html element to detach from
  72685. */
  72686. detachControl(element: HTMLElement): void;
  72687. /**
  72688. * @returns the name of this class
  72689. */
  72690. getClassName(): string;
  72691. /**
  72692. * Calls resetPose on the vrDisplay
  72693. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  72694. */
  72695. resetToCurrentRotation(): void;
  72696. /**
  72697. * @hidden
  72698. * Updates the rig cameras (left and right eye)
  72699. */
  72700. _updateRigCameras(): void;
  72701. private _workingVector;
  72702. private _oneVector;
  72703. private _workingMatrix;
  72704. private updateCacheCalled;
  72705. private _correctPositionIfNotTrackPosition;
  72706. /**
  72707. * @hidden
  72708. * Updates the cached values of the camera
  72709. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  72710. */
  72711. _updateCache(ignoreParentClass?: boolean): void;
  72712. /**
  72713. * @hidden
  72714. * Get current device position in babylon world
  72715. */
  72716. _computeDevicePosition(): void;
  72717. /**
  72718. * Updates the current device position and rotation in the babylon world
  72719. */
  72720. update(): void;
  72721. /**
  72722. * @hidden
  72723. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  72724. * @returns an identity matrix
  72725. */
  72726. _getViewMatrix(): Matrix;
  72727. private _tmpMatrix;
  72728. /**
  72729. * This function is called by the two RIG cameras.
  72730. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  72731. * @hidden
  72732. */
  72733. _getWebVRViewMatrix(): Matrix;
  72734. /** @hidden */
  72735. _getWebVRProjectionMatrix(): Matrix;
  72736. private _onGamepadConnectedObserver;
  72737. private _onGamepadDisconnectedObserver;
  72738. private _updateCacheWhenTrackingDisabledObserver;
  72739. /**
  72740. * Initializes the controllers and their meshes
  72741. */
  72742. initControllers(): void;
  72743. }
  72744. }
  72745. declare module BABYLON {
  72746. /**
  72747. * Size options for a post process
  72748. */
  72749. export type PostProcessOptions = {
  72750. width: number;
  72751. height: number;
  72752. };
  72753. /**
  72754. * PostProcess can be used to apply a shader to a texture after it has been rendered
  72755. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72756. */
  72757. export class PostProcess {
  72758. /** Name of the PostProcess. */
  72759. name: string;
  72760. /**
  72761. * Gets or sets the unique id of the post process
  72762. */
  72763. uniqueId: number;
  72764. /**
  72765. * Width of the texture to apply the post process on
  72766. */
  72767. width: number;
  72768. /**
  72769. * Height of the texture to apply the post process on
  72770. */
  72771. height: number;
  72772. /**
  72773. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  72774. * @hidden
  72775. */
  72776. _outputTexture: Nullable<InternalTexture>;
  72777. /**
  72778. * Sampling mode used by the shader
  72779. * See https://doc.babylonjs.com/classes/3.1/texture
  72780. */
  72781. renderTargetSamplingMode: number;
  72782. /**
  72783. * Clear color to use when screen clearing
  72784. */
  72785. clearColor: Color4;
  72786. /**
  72787. * If the buffer needs to be cleared before applying the post process. (default: true)
  72788. * Should be set to false if shader will overwrite all previous pixels.
  72789. */
  72790. autoClear: boolean;
  72791. /**
  72792. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  72793. */
  72794. alphaMode: number;
  72795. /**
  72796. * Sets the setAlphaBlendConstants of the babylon engine
  72797. */
  72798. alphaConstants: Color4;
  72799. /**
  72800. * Animations to be used for the post processing
  72801. */
  72802. animations: Animation[];
  72803. /**
  72804. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  72805. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  72806. */
  72807. enablePixelPerfectMode: boolean;
  72808. /**
  72809. * Force the postprocess to be applied without taking in account viewport
  72810. */
  72811. forceFullscreenViewport: boolean;
  72812. /**
  72813. * List of inspectable custom properties (used by the Inspector)
  72814. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  72815. */
  72816. inspectableCustomProperties: IInspectable[];
  72817. /**
  72818. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  72819. *
  72820. * | Value | Type | Description |
  72821. * | ----- | ----------------------------------- | ----------- |
  72822. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  72823. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  72824. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  72825. *
  72826. */
  72827. scaleMode: number;
  72828. /**
  72829. * Force textures to be a power of two (default: false)
  72830. */
  72831. alwaysForcePOT: boolean;
  72832. private _samples;
  72833. /**
  72834. * Number of sample textures (default: 1)
  72835. */
  72836. samples: number;
  72837. /**
  72838. * Modify the scale of the post process to be the same as the viewport (default: false)
  72839. */
  72840. adaptScaleToCurrentViewport: boolean;
  72841. private _camera;
  72842. private _scene;
  72843. private _engine;
  72844. private _options;
  72845. private _reusable;
  72846. private _textureType;
  72847. /**
  72848. * Smart array of input and output textures for the post process.
  72849. * @hidden
  72850. */
  72851. _textures: SmartArray<InternalTexture>;
  72852. /**
  72853. * The index in _textures that corresponds to the output texture.
  72854. * @hidden
  72855. */
  72856. _currentRenderTextureInd: number;
  72857. private _effect;
  72858. private _samplers;
  72859. private _fragmentUrl;
  72860. private _vertexUrl;
  72861. private _parameters;
  72862. private _scaleRatio;
  72863. protected _indexParameters: any;
  72864. private _shareOutputWithPostProcess;
  72865. private _texelSize;
  72866. private _forcedOutputTexture;
  72867. /**
  72868. * Returns the fragment url or shader name used in the post process.
  72869. * @returns the fragment url or name in the shader store.
  72870. */
  72871. getEffectName(): string;
  72872. /**
  72873. * An event triggered when the postprocess is activated.
  72874. */
  72875. onActivateObservable: Observable<Camera>;
  72876. private _onActivateObserver;
  72877. /**
  72878. * A function that is added to the onActivateObservable
  72879. */
  72880. onActivate: Nullable<(camera: Camera) => void>;
  72881. /**
  72882. * An event triggered when the postprocess changes its size.
  72883. */
  72884. onSizeChangedObservable: Observable<PostProcess>;
  72885. private _onSizeChangedObserver;
  72886. /**
  72887. * A function that is added to the onSizeChangedObservable
  72888. */
  72889. onSizeChanged: (postProcess: PostProcess) => void;
  72890. /**
  72891. * An event triggered when the postprocess applies its effect.
  72892. */
  72893. onApplyObservable: Observable<Effect>;
  72894. private _onApplyObserver;
  72895. /**
  72896. * A function that is added to the onApplyObservable
  72897. */
  72898. onApply: (effect: Effect) => void;
  72899. /**
  72900. * An event triggered before rendering the postprocess
  72901. */
  72902. onBeforeRenderObservable: Observable<Effect>;
  72903. private _onBeforeRenderObserver;
  72904. /**
  72905. * A function that is added to the onBeforeRenderObservable
  72906. */
  72907. onBeforeRender: (effect: Effect) => void;
  72908. /**
  72909. * An event triggered after rendering the postprocess
  72910. */
  72911. onAfterRenderObservable: Observable<Effect>;
  72912. private _onAfterRenderObserver;
  72913. /**
  72914. * A function that is added to the onAfterRenderObservable
  72915. */
  72916. onAfterRender: (efect: Effect) => void;
  72917. /**
  72918. * 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
  72919. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  72920. */
  72921. inputTexture: InternalTexture;
  72922. /**
  72923. * Gets the camera which post process is applied to.
  72924. * @returns The camera the post process is applied to.
  72925. */
  72926. getCamera(): Camera;
  72927. /**
  72928. * Gets the texel size of the postprocess.
  72929. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  72930. */
  72931. readonly texelSize: Vector2;
  72932. /**
  72933. * Creates a new instance PostProcess
  72934. * @param name The name of the PostProcess.
  72935. * @param fragmentUrl The url of the fragment shader to be used.
  72936. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  72937. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  72938. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  72939. * @param camera The camera to apply the render pass to.
  72940. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72941. * @param engine The engine which the post process will be applied. (default: current engine)
  72942. * @param reusable If the post process can be reused on the same frame. (default: false)
  72943. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  72944. * @param textureType Type of textures used when performing the post process. (default: 0)
  72945. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  72946. * @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
  72947. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  72948. */
  72949. constructor(
  72950. /** Name of the PostProcess. */
  72951. 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);
  72952. /**
  72953. * Gets a string idenfifying the name of the class
  72954. * @returns "PostProcess" string
  72955. */
  72956. getClassName(): string;
  72957. /**
  72958. * Gets the engine which this post process belongs to.
  72959. * @returns The engine the post process was enabled with.
  72960. */
  72961. getEngine(): Engine;
  72962. /**
  72963. * The effect that is created when initializing the post process.
  72964. * @returns The created effect corrisponding the the postprocess.
  72965. */
  72966. getEffect(): Effect;
  72967. /**
  72968. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  72969. * @param postProcess The post process to share the output with.
  72970. * @returns This post process.
  72971. */
  72972. shareOutputWith(postProcess: PostProcess): PostProcess;
  72973. /**
  72974. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  72975. * This should be called if the post process that shares output with this post process is disabled/disposed.
  72976. */
  72977. useOwnOutput(): void;
  72978. /**
  72979. * Updates the effect with the current post process compile time values and recompiles the shader.
  72980. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  72981. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  72982. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  72983. * @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
  72984. * @param onCompiled Called when the shader has been compiled.
  72985. * @param onError Called if there is an error when compiling a shader.
  72986. */
  72987. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  72988. /**
  72989. * The post process is reusable if it can be used multiple times within one frame.
  72990. * @returns If the post process is reusable
  72991. */
  72992. isReusable(): boolean;
  72993. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  72994. markTextureDirty(): void;
  72995. /**
  72996. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  72997. * 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.
  72998. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  72999. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  73000. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  73001. * @returns The target texture that was bound to be written to.
  73002. */
  73003. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  73004. /**
  73005. * If the post process is supported.
  73006. */
  73007. readonly isSupported: boolean;
  73008. /**
  73009. * The aspect ratio of the output texture.
  73010. */
  73011. readonly aspectRatio: number;
  73012. /**
  73013. * Get a value indicating if the post-process is ready to be used
  73014. * @returns true if the post-process is ready (shader is compiled)
  73015. */
  73016. isReady(): boolean;
  73017. /**
  73018. * Binds all textures and uniforms to the shader, this will be run on every pass.
  73019. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  73020. */
  73021. apply(): Nullable<Effect>;
  73022. private _disposeTextures;
  73023. /**
  73024. * Disposes the post process.
  73025. * @param camera The camera to dispose the post process on.
  73026. */
  73027. dispose(camera?: Camera): void;
  73028. }
  73029. }
  73030. declare module BABYLON {
  73031. /**
  73032. * PostProcessManager is used to manage one or more post processes or post process pipelines
  73033. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73034. */
  73035. export class PostProcessManager {
  73036. private _scene;
  73037. private _indexBuffer;
  73038. private _vertexBuffers;
  73039. /**
  73040. * Creates a new instance PostProcess
  73041. * @param scene The scene that the post process is associated with.
  73042. */
  73043. constructor(scene: Scene);
  73044. private _prepareBuffers;
  73045. private _buildIndexBuffer;
  73046. /**
  73047. * Rebuilds the vertex buffers of the manager.
  73048. * @hidden
  73049. */
  73050. _rebuild(): void;
  73051. /**
  73052. * Prepares a frame to be run through a post process.
  73053. * @param sourceTexture The input texture to the post procesess. (default: null)
  73054. * @param postProcesses An array of post processes to be run. (default: null)
  73055. * @returns True if the post processes were able to be run.
  73056. * @hidden
  73057. */
  73058. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  73059. /**
  73060. * Manually render a set of post processes to a texture.
  73061. * @param postProcesses An array of post processes to be run.
  73062. * @param targetTexture The target texture to render to.
  73063. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  73064. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  73065. * @param lodLevel defines which lod of the texture to render to
  73066. */
  73067. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  73068. /**
  73069. * Finalize the result of the output of the postprocesses.
  73070. * @param doNotPresent If true the result will not be displayed to the screen.
  73071. * @param targetTexture The target texture to render to.
  73072. * @param faceIndex The index of the face to bind the target texture to.
  73073. * @param postProcesses The array of post processes to render.
  73074. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  73075. * @hidden
  73076. */
  73077. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  73078. /**
  73079. * Disposes of the post process manager.
  73080. */
  73081. dispose(): void;
  73082. }
  73083. }
  73084. declare module BABYLON {
  73085. interface AbstractScene {
  73086. /**
  73087. * The list of layers (background and foreground) of the scene
  73088. */
  73089. layers: Array<Layer>;
  73090. }
  73091. /**
  73092. * Defines the layer scene component responsible to manage any layers
  73093. * in a given scene.
  73094. */
  73095. export class LayerSceneComponent implements ISceneComponent {
  73096. /**
  73097. * The component name helpfull to identify the component in the list of scene components.
  73098. */
  73099. readonly name: string;
  73100. /**
  73101. * The scene the component belongs to.
  73102. */
  73103. scene: Scene;
  73104. private _engine;
  73105. /**
  73106. * Creates a new instance of the component for the given scene
  73107. * @param scene Defines the scene to register the component in
  73108. */
  73109. constructor(scene: Scene);
  73110. /**
  73111. * Registers the component in a given scene
  73112. */
  73113. register(): void;
  73114. /**
  73115. * Rebuilds the elements related to this component in case of
  73116. * context lost for instance.
  73117. */
  73118. rebuild(): void;
  73119. /**
  73120. * Disposes the component and the associated ressources.
  73121. */
  73122. dispose(): void;
  73123. private _draw;
  73124. private _drawCameraPredicate;
  73125. private _drawCameraBackground;
  73126. private _drawCameraForeground;
  73127. private _drawRenderTargetPredicate;
  73128. private _drawRenderTargetBackground;
  73129. private _drawRenderTargetForeground;
  73130. }
  73131. }
  73132. declare module BABYLON {
  73133. /** @hidden */
  73134. export var layerPixelShader: {
  73135. name: string;
  73136. shader: string;
  73137. };
  73138. }
  73139. declare module BABYLON {
  73140. /** @hidden */
  73141. export var layerVertexShader: {
  73142. name: string;
  73143. shader: string;
  73144. };
  73145. }
  73146. declare module BABYLON {
  73147. /**
  73148. * This represents a full screen 2d layer.
  73149. * This can be useful to display a picture in the background of your scene for instance.
  73150. * @see https://www.babylonjs-playground.com/#08A2BS#1
  73151. */
  73152. export class Layer {
  73153. /**
  73154. * Define the name of the layer.
  73155. */
  73156. name: string;
  73157. /**
  73158. * Define the texture the layer should display.
  73159. */
  73160. texture: Nullable<Texture>;
  73161. /**
  73162. * Is the layer in background or foreground.
  73163. */
  73164. isBackground: boolean;
  73165. /**
  73166. * Define the color of the layer (instead of texture).
  73167. */
  73168. color: Color4;
  73169. /**
  73170. * Define the scale of the layer in order to zoom in out of the texture.
  73171. */
  73172. scale: Vector2;
  73173. /**
  73174. * Define an offset for the layer in order to shift the texture.
  73175. */
  73176. offset: Vector2;
  73177. /**
  73178. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  73179. */
  73180. alphaBlendingMode: number;
  73181. /**
  73182. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  73183. * Alpha test will not mix with the background color in case of transparency.
  73184. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  73185. */
  73186. alphaTest: boolean;
  73187. /**
  73188. * Define a mask to restrict the layer to only some of the scene cameras.
  73189. */
  73190. layerMask: number;
  73191. /**
  73192. * Define the list of render target the layer is visible into.
  73193. */
  73194. renderTargetTextures: RenderTargetTexture[];
  73195. /**
  73196. * Define if the layer is only used in renderTarget or if it also
  73197. * renders in the main frame buffer of the canvas.
  73198. */
  73199. renderOnlyInRenderTargetTextures: boolean;
  73200. private _scene;
  73201. private _vertexBuffers;
  73202. private _indexBuffer;
  73203. private _effect;
  73204. private _alphaTestEffect;
  73205. /**
  73206. * An event triggered when the layer is disposed.
  73207. */
  73208. onDisposeObservable: Observable<Layer>;
  73209. private _onDisposeObserver;
  73210. /**
  73211. * Back compatibility with callback before the onDisposeObservable existed.
  73212. * The set callback will be triggered when the layer has been disposed.
  73213. */
  73214. onDispose: () => void;
  73215. /**
  73216. * An event triggered before rendering the scene
  73217. */
  73218. onBeforeRenderObservable: Observable<Layer>;
  73219. private _onBeforeRenderObserver;
  73220. /**
  73221. * Back compatibility with callback before the onBeforeRenderObservable existed.
  73222. * The set callback will be triggered just before rendering the layer.
  73223. */
  73224. onBeforeRender: () => void;
  73225. /**
  73226. * An event triggered after rendering the scene
  73227. */
  73228. onAfterRenderObservable: Observable<Layer>;
  73229. private _onAfterRenderObserver;
  73230. /**
  73231. * Back compatibility with callback before the onAfterRenderObservable existed.
  73232. * The set callback will be triggered just after rendering the layer.
  73233. */
  73234. onAfterRender: () => void;
  73235. /**
  73236. * Instantiates a new layer.
  73237. * This represents a full screen 2d layer.
  73238. * This can be useful to display a picture in the background of your scene for instance.
  73239. * @see https://www.babylonjs-playground.com/#08A2BS#1
  73240. * @param name Define the name of the layer in the scene
  73241. * @param imgUrl Define the url of the texture to display in the layer
  73242. * @param scene Define the scene the layer belongs to
  73243. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  73244. * @param color Defines a color for the layer
  73245. */
  73246. constructor(
  73247. /**
  73248. * Define the name of the layer.
  73249. */
  73250. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  73251. private _createIndexBuffer;
  73252. /** @hidden */
  73253. _rebuild(): void;
  73254. /**
  73255. * Renders the layer in the scene.
  73256. */
  73257. render(): void;
  73258. /**
  73259. * Disposes and releases the associated ressources.
  73260. */
  73261. dispose(): void;
  73262. }
  73263. }
  73264. declare module BABYLON {
  73265. interface AbstractScene {
  73266. /**
  73267. * The list of procedural textures added to the scene
  73268. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  73269. */
  73270. proceduralTextures: Array<ProceduralTexture>;
  73271. }
  73272. /**
  73273. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  73274. * in a given scene.
  73275. */
  73276. export class ProceduralTextureSceneComponent implements ISceneComponent {
  73277. /**
  73278. * The component name helpfull to identify the component in the list of scene components.
  73279. */
  73280. readonly name: string;
  73281. /**
  73282. * The scene the component belongs to.
  73283. */
  73284. scene: Scene;
  73285. /**
  73286. * Creates a new instance of the component for the given scene
  73287. * @param scene Defines the scene to register the component in
  73288. */
  73289. constructor(scene: Scene);
  73290. /**
  73291. * Registers the component in a given scene
  73292. */
  73293. register(): void;
  73294. /**
  73295. * Rebuilds the elements related to this component in case of
  73296. * context lost for instance.
  73297. */
  73298. rebuild(): void;
  73299. /**
  73300. * Disposes the component and the associated ressources.
  73301. */
  73302. dispose(): void;
  73303. private _beforeClear;
  73304. }
  73305. }
  73306. declare module BABYLON {
  73307. /** @hidden */
  73308. export var proceduralVertexShader: {
  73309. name: string;
  73310. shader: string;
  73311. };
  73312. }
  73313. declare module BABYLON {
  73314. /**
  73315. * 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.
  73316. * This is the base class of any Procedural texture and contains most of the shareable code.
  73317. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  73318. */
  73319. export class ProceduralTexture extends Texture {
  73320. isCube: boolean;
  73321. /**
  73322. * Define if the texture is enabled or not (disabled texture will not render)
  73323. */
  73324. isEnabled: boolean;
  73325. /**
  73326. * Define if the texture must be cleared before rendering (default is true)
  73327. */
  73328. autoClear: boolean;
  73329. /**
  73330. * Callback called when the texture is generated
  73331. */
  73332. onGenerated: () => void;
  73333. /**
  73334. * Event raised when the texture is generated
  73335. */
  73336. onGeneratedObservable: Observable<ProceduralTexture>;
  73337. /** @hidden */
  73338. _generateMipMaps: boolean;
  73339. /** @hidden **/
  73340. _effect: Effect;
  73341. /** @hidden */
  73342. _textures: {
  73343. [key: string]: Texture;
  73344. };
  73345. private _size;
  73346. private _currentRefreshId;
  73347. private _refreshRate;
  73348. private _vertexBuffers;
  73349. private _indexBuffer;
  73350. private _uniforms;
  73351. private _samplers;
  73352. private _fragment;
  73353. private _floats;
  73354. private _ints;
  73355. private _floatsArrays;
  73356. private _colors3;
  73357. private _colors4;
  73358. private _vectors2;
  73359. private _vectors3;
  73360. private _matrices;
  73361. private _fallbackTexture;
  73362. private _fallbackTextureUsed;
  73363. private _engine;
  73364. private _cachedDefines;
  73365. private _contentUpdateId;
  73366. private _contentData;
  73367. /**
  73368. * Instantiates a new procedural texture.
  73369. * 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.
  73370. * This is the base class of any Procedural texture and contains most of the shareable code.
  73371. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  73372. * @param name Define the name of the texture
  73373. * @param size Define the size of the texture to create
  73374. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  73375. * @param scene Define the scene the texture belongs to
  73376. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  73377. * @param generateMipMaps Define if the texture should creates mip maps or not
  73378. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  73379. */
  73380. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  73381. /**
  73382. * The effect that is created when initializing the post process.
  73383. * @returns The created effect corrisponding the the postprocess.
  73384. */
  73385. getEffect(): Effect;
  73386. /**
  73387. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  73388. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  73389. */
  73390. getContent(): Nullable<ArrayBufferView>;
  73391. private _createIndexBuffer;
  73392. /** @hidden */
  73393. _rebuild(): void;
  73394. /**
  73395. * Resets the texture in order to recreate its associated resources.
  73396. * This can be called in case of context loss
  73397. */
  73398. reset(): void;
  73399. protected _getDefines(): string;
  73400. /**
  73401. * Is the texture ready to be used ? (rendered at least once)
  73402. * @returns true if ready, otherwise, false.
  73403. */
  73404. isReady(): boolean;
  73405. /**
  73406. * Resets the refresh counter of the texture and start bak from scratch.
  73407. * Could be useful to regenerate the texture if it is setup to render only once.
  73408. */
  73409. resetRefreshCounter(): void;
  73410. /**
  73411. * Set the fragment shader to use in order to render the texture.
  73412. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  73413. */
  73414. setFragment(fragment: any): void;
  73415. /**
  73416. * Define the refresh rate of the texture or the rendering frequency.
  73417. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  73418. */
  73419. refreshRate: number;
  73420. /** @hidden */
  73421. _shouldRender(): boolean;
  73422. /**
  73423. * Get the size the texture is rendering at.
  73424. * @returns the size (texture is always squared)
  73425. */
  73426. getRenderSize(): number;
  73427. /**
  73428. * Resize the texture to new value.
  73429. * @param size Define the new size the texture should have
  73430. * @param generateMipMaps Define whether the new texture should create mip maps
  73431. */
  73432. resize(size: number, generateMipMaps: boolean): void;
  73433. private _checkUniform;
  73434. /**
  73435. * Set a texture in the shader program used to render.
  73436. * @param name Define the name of the uniform samplers as defined in the shader
  73437. * @param texture Define the texture to bind to this sampler
  73438. * @return the texture itself allowing "fluent" like uniform updates
  73439. */
  73440. setTexture(name: string, texture: Texture): ProceduralTexture;
  73441. /**
  73442. * Set a float in the shader.
  73443. * @param name Define the name of the uniform as defined in the shader
  73444. * @param value Define the value to give to the uniform
  73445. * @return the texture itself allowing "fluent" like uniform updates
  73446. */
  73447. setFloat(name: string, value: number): ProceduralTexture;
  73448. /**
  73449. * Set a int in the shader.
  73450. * @param name Define the name of the uniform as defined in the shader
  73451. * @param value Define the value to give to the uniform
  73452. * @return the texture itself allowing "fluent" like uniform updates
  73453. */
  73454. setInt(name: string, value: number): ProceduralTexture;
  73455. /**
  73456. * Set an array of floats in the shader.
  73457. * @param name Define the name of the uniform as defined in the shader
  73458. * @param value Define the value to give to the uniform
  73459. * @return the texture itself allowing "fluent" like uniform updates
  73460. */
  73461. setFloats(name: string, value: number[]): ProceduralTexture;
  73462. /**
  73463. * Set a vec3 in the shader from a Color3.
  73464. * @param name Define the name of the uniform as defined in the shader
  73465. * @param value Define the value to give to the uniform
  73466. * @return the texture itself allowing "fluent" like uniform updates
  73467. */
  73468. setColor3(name: string, value: Color3): ProceduralTexture;
  73469. /**
  73470. * Set a vec4 in the shader from a Color4.
  73471. * @param name Define the name of the uniform as defined in the shader
  73472. * @param value Define the value to give to the uniform
  73473. * @return the texture itself allowing "fluent" like uniform updates
  73474. */
  73475. setColor4(name: string, value: Color4): ProceduralTexture;
  73476. /**
  73477. * Set a vec2 in the shader from a Vector2.
  73478. * @param name Define the name of the uniform as defined in the shader
  73479. * @param value Define the value to give to the uniform
  73480. * @return the texture itself allowing "fluent" like uniform updates
  73481. */
  73482. setVector2(name: string, value: Vector2): ProceduralTexture;
  73483. /**
  73484. * Set a vec3 in the shader from a Vector3.
  73485. * @param name Define the name of the uniform as defined in the shader
  73486. * @param value Define the value to give to the uniform
  73487. * @return the texture itself allowing "fluent" like uniform updates
  73488. */
  73489. setVector3(name: string, value: Vector3): ProceduralTexture;
  73490. /**
  73491. * Set a mat4 in the shader from a MAtrix.
  73492. * @param name Define the name of the uniform as defined in the shader
  73493. * @param value Define the value to give to the uniform
  73494. * @return the texture itself allowing "fluent" like uniform updates
  73495. */
  73496. setMatrix(name: string, value: Matrix): ProceduralTexture;
  73497. /**
  73498. * Render the texture to its associated render target.
  73499. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  73500. */
  73501. render(useCameraPostProcess?: boolean): void;
  73502. /**
  73503. * Clone the texture.
  73504. * @returns the cloned texture
  73505. */
  73506. clone(): ProceduralTexture;
  73507. /**
  73508. * Dispose the texture and release its asoociated resources.
  73509. */
  73510. dispose(): void;
  73511. }
  73512. }
  73513. declare module BABYLON {
  73514. /**
  73515. * This represents the base class for particle system in Babylon.
  73516. * 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.
  73517. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  73518. * @example https://doc.babylonjs.com/babylon101/particles
  73519. */
  73520. export class BaseParticleSystem {
  73521. /**
  73522. * Source color is added to the destination color without alpha affecting the result
  73523. */
  73524. static BLENDMODE_ONEONE: number;
  73525. /**
  73526. * Blend current color and particle color using particle’s alpha
  73527. */
  73528. static BLENDMODE_STANDARD: number;
  73529. /**
  73530. * Add current color and particle color multiplied by particle’s alpha
  73531. */
  73532. static BLENDMODE_ADD: number;
  73533. /**
  73534. * Multiply current color with particle color
  73535. */
  73536. static BLENDMODE_MULTIPLY: number;
  73537. /**
  73538. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  73539. */
  73540. static BLENDMODE_MULTIPLYADD: number;
  73541. /**
  73542. * List of animations used by the particle system.
  73543. */
  73544. animations: Animation[];
  73545. /**
  73546. * The id of the Particle system.
  73547. */
  73548. id: string;
  73549. /**
  73550. * The friendly name of the Particle system.
  73551. */
  73552. name: string;
  73553. /**
  73554. * The rendering group used by the Particle system to chose when to render.
  73555. */
  73556. renderingGroupId: number;
  73557. /**
  73558. * The emitter represents the Mesh or position we are attaching the particle system to.
  73559. */
  73560. emitter: Nullable<AbstractMesh | Vector3>;
  73561. /**
  73562. * The maximum number of particles to emit per frame
  73563. */
  73564. emitRate: number;
  73565. /**
  73566. * If you want to launch only a few particles at once, that can be done, as well.
  73567. */
  73568. manualEmitCount: number;
  73569. /**
  73570. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  73571. */
  73572. updateSpeed: number;
  73573. /**
  73574. * The amount of time the particle system is running (depends of the overall update speed).
  73575. */
  73576. targetStopDuration: number;
  73577. /**
  73578. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  73579. */
  73580. disposeOnStop: boolean;
  73581. /**
  73582. * Minimum power of emitting particles.
  73583. */
  73584. minEmitPower: number;
  73585. /**
  73586. * Maximum power of emitting particles.
  73587. */
  73588. maxEmitPower: number;
  73589. /**
  73590. * Minimum life time of emitting particles.
  73591. */
  73592. minLifeTime: number;
  73593. /**
  73594. * Maximum life time of emitting particles.
  73595. */
  73596. maxLifeTime: number;
  73597. /**
  73598. * Minimum Size of emitting particles.
  73599. */
  73600. minSize: number;
  73601. /**
  73602. * Maximum Size of emitting particles.
  73603. */
  73604. maxSize: number;
  73605. /**
  73606. * Minimum scale of emitting particles on X axis.
  73607. */
  73608. minScaleX: number;
  73609. /**
  73610. * Maximum scale of emitting particles on X axis.
  73611. */
  73612. maxScaleX: number;
  73613. /**
  73614. * Minimum scale of emitting particles on Y axis.
  73615. */
  73616. minScaleY: number;
  73617. /**
  73618. * Maximum scale of emitting particles on Y axis.
  73619. */
  73620. maxScaleY: number;
  73621. /**
  73622. * Gets or sets the minimal initial rotation in radians.
  73623. */
  73624. minInitialRotation: number;
  73625. /**
  73626. * Gets or sets the maximal initial rotation in radians.
  73627. */
  73628. maxInitialRotation: number;
  73629. /**
  73630. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  73631. */
  73632. minAngularSpeed: number;
  73633. /**
  73634. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  73635. */
  73636. maxAngularSpeed: number;
  73637. /**
  73638. * The texture used to render each particle. (this can be a spritesheet)
  73639. */
  73640. particleTexture: Nullable<Texture>;
  73641. /**
  73642. * The layer mask we are rendering the particles through.
  73643. */
  73644. layerMask: number;
  73645. /**
  73646. * This can help using your own shader to render the particle system.
  73647. * The according effect will be created
  73648. */
  73649. customShader: any;
  73650. /**
  73651. * By default particle system starts as soon as they are created. This prevents the
  73652. * automatic start to happen and let you decide when to start emitting particles.
  73653. */
  73654. preventAutoStart: boolean;
  73655. private _noiseTexture;
  73656. /**
  73657. * Gets or sets a texture used to add random noise to particle positions
  73658. */
  73659. noiseTexture: Nullable<ProceduralTexture>;
  73660. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  73661. noiseStrength: Vector3;
  73662. /**
  73663. * Callback triggered when the particle animation is ending.
  73664. */
  73665. onAnimationEnd: Nullable<() => void>;
  73666. /**
  73667. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  73668. */
  73669. blendMode: number;
  73670. /**
  73671. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  73672. * to override the particles.
  73673. */
  73674. forceDepthWrite: boolean;
  73675. /** 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 */
  73676. preWarmCycles: number;
  73677. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  73678. preWarmStepOffset: number;
  73679. /**
  73680. * 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)
  73681. */
  73682. spriteCellChangeSpeed: number;
  73683. /**
  73684. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  73685. */
  73686. startSpriteCellID: number;
  73687. /**
  73688. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  73689. */
  73690. endSpriteCellID: number;
  73691. /**
  73692. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  73693. */
  73694. spriteCellWidth: number;
  73695. /**
  73696. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  73697. */
  73698. spriteCellHeight: number;
  73699. /**
  73700. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  73701. */
  73702. spriteRandomStartCell: boolean;
  73703. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  73704. translationPivot: Vector2;
  73705. /** @hidden */
  73706. protected _isAnimationSheetEnabled: boolean;
  73707. /**
  73708. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  73709. */
  73710. beginAnimationOnStart: boolean;
  73711. /**
  73712. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  73713. */
  73714. beginAnimationFrom: number;
  73715. /**
  73716. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  73717. */
  73718. beginAnimationTo: number;
  73719. /**
  73720. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  73721. */
  73722. beginAnimationLoop: boolean;
  73723. /**
  73724. * Gets or sets a world offset applied to all particles
  73725. */
  73726. worldOffset: Vector3;
  73727. /**
  73728. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  73729. */
  73730. isAnimationSheetEnabled: boolean;
  73731. /**
  73732. * Get hosting scene
  73733. * @returns the scene
  73734. */
  73735. getScene(): Scene;
  73736. /**
  73737. * You can use gravity if you want to give an orientation to your particles.
  73738. */
  73739. gravity: Vector3;
  73740. protected _colorGradients: Nullable<Array<ColorGradient>>;
  73741. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  73742. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  73743. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  73744. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  73745. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  73746. protected _dragGradients: Nullable<Array<FactorGradient>>;
  73747. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  73748. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  73749. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  73750. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  73751. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  73752. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  73753. /**
  73754. * Defines the delay in milliseconds before starting the system (0 by default)
  73755. */
  73756. startDelay: number;
  73757. /**
  73758. * Gets the current list of drag gradients.
  73759. * You must use addDragGradient and removeDragGradient to udpate this list
  73760. * @returns the list of drag gradients
  73761. */
  73762. getDragGradients(): Nullable<Array<FactorGradient>>;
  73763. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  73764. limitVelocityDamping: number;
  73765. /**
  73766. * Gets the current list of limit velocity gradients.
  73767. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  73768. * @returns the list of limit velocity gradients
  73769. */
  73770. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  73771. /**
  73772. * Gets the current list of color gradients.
  73773. * You must use addColorGradient and removeColorGradient to udpate this list
  73774. * @returns the list of color gradients
  73775. */
  73776. getColorGradients(): Nullable<Array<ColorGradient>>;
  73777. /**
  73778. * Gets the current list of size gradients.
  73779. * You must use addSizeGradient and removeSizeGradient to udpate this list
  73780. * @returns the list of size gradients
  73781. */
  73782. getSizeGradients(): Nullable<Array<FactorGradient>>;
  73783. /**
  73784. * Gets the current list of color remap gradients.
  73785. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  73786. * @returns the list of color remap gradients
  73787. */
  73788. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  73789. /**
  73790. * Gets the current list of alpha remap gradients.
  73791. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  73792. * @returns the list of alpha remap gradients
  73793. */
  73794. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  73795. /**
  73796. * Gets the current list of life time gradients.
  73797. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  73798. * @returns the list of life time gradients
  73799. */
  73800. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  73801. /**
  73802. * Gets the current list of angular speed gradients.
  73803. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  73804. * @returns the list of angular speed gradients
  73805. */
  73806. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  73807. /**
  73808. * Gets the current list of velocity gradients.
  73809. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  73810. * @returns the list of velocity gradients
  73811. */
  73812. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  73813. /**
  73814. * Gets the current list of start size gradients.
  73815. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  73816. * @returns the list of start size gradients
  73817. */
  73818. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  73819. /**
  73820. * Gets the current list of emit rate gradients.
  73821. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  73822. * @returns the list of emit rate gradients
  73823. */
  73824. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  73825. /**
  73826. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73827. * This only works when particleEmitterTyps is a BoxParticleEmitter
  73828. */
  73829. direction1: Vector3;
  73830. /**
  73831. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73832. * This only works when particleEmitterTyps is a BoxParticleEmitter
  73833. */
  73834. direction2: Vector3;
  73835. /**
  73836. * 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.
  73837. * This only works when particleEmitterTyps is a BoxParticleEmitter
  73838. */
  73839. minEmitBox: Vector3;
  73840. /**
  73841. * 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.
  73842. * This only works when particleEmitterTyps is a BoxParticleEmitter
  73843. */
  73844. maxEmitBox: Vector3;
  73845. /**
  73846. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  73847. */
  73848. color1: Color4;
  73849. /**
  73850. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  73851. */
  73852. color2: Color4;
  73853. /**
  73854. * Color the particle will have at the end of its lifetime
  73855. */
  73856. colorDead: Color4;
  73857. /**
  73858. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  73859. */
  73860. textureMask: Color4;
  73861. /**
  73862. * The particle emitter type defines the emitter used by the particle system.
  73863. * It can be for example box, sphere, or cone...
  73864. */
  73865. particleEmitterType: IParticleEmitterType;
  73866. /** @hidden */
  73867. _isSubEmitter: boolean;
  73868. /**
  73869. * Gets or sets the billboard mode to use when isBillboardBased = true.
  73870. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  73871. */
  73872. billboardMode: number;
  73873. protected _isBillboardBased: boolean;
  73874. /**
  73875. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  73876. */
  73877. isBillboardBased: boolean;
  73878. /**
  73879. * The scene the particle system belongs to.
  73880. */
  73881. protected _scene: Scene;
  73882. /**
  73883. * Local cache of defines for image processing.
  73884. */
  73885. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  73886. /**
  73887. * Default configuration related to image processing available in the standard Material.
  73888. */
  73889. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  73890. /**
  73891. * Gets the image processing configuration used either in this material.
  73892. */
  73893. /**
  73894. * Sets the Default image processing configuration used either in the this material.
  73895. *
  73896. * If sets to null, the scene one is in use.
  73897. */
  73898. imageProcessingConfiguration: ImageProcessingConfiguration;
  73899. /**
  73900. * Attaches a new image processing configuration to the Standard Material.
  73901. * @param configuration
  73902. */
  73903. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  73904. /** @hidden */
  73905. protected _reset(): void;
  73906. /** @hidden */
  73907. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  73908. /**
  73909. * Instantiates a particle system.
  73910. * 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.
  73911. * @param name The name of the particle system
  73912. */
  73913. constructor(name: string);
  73914. /**
  73915. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  73916. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73917. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73918. * @returns the emitter
  73919. */
  73920. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  73921. /**
  73922. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  73923. * @param radius The radius of the hemisphere to emit from
  73924. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73925. * @returns the emitter
  73926. */
  73927. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  73928. /**
  73929. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  73930. * @param radius The radius of the sphere to emit from
  73931. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73932. * @returns the emitter
  73933. */
  73934. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  73935. /**
  73936. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  73937. * @param radius The radius of the sphere to emit from
  73938. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  73939. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  73940. * @returns the emitter
  73941. */
  73942. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  73943. /**
  73944. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  73945. * @param radius The radius of the emission cylinder
  73946. * @param height The height of the emission cylinder
  73947. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  73948. * @param directionRandomizer How much to randomize the particle direction [0-1]
  73949. * @returns the emitter
  73950. */
  73951. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  73952. /**
  73953. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  73954. * @param radius The radius of the cylinder to emit from
  73955. * @param height The height of the emission cylinder
  73956. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73957. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  73958. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  73959. * @returns the emitter
  73960. */
  73961. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  73962. /**
  73963. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  73964. * @param radius The radius of the cone to emit from
  73965. * @param angle The base angle of the cone
  73966. * @returns the emitter
  73967. */
  73968. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  73969. /**
  73970. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  73971. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73972. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73973. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73974. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73975. * @returns the emitter
  73976. */
  73977. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  73978. }
  73979. }
  73980. declare module BABYLON {
  73981. /**
  73982. * Type of sub emitter
  73983. */
  73984. export enum SubEmitterType {
  73985. /**
  73986. * Attached to the particle over it's lifetime
  73987. */
  73988. ATTACHED = 0,
  73989. /**
  73990. * Created when the particle dies
  73991. */
  73992. END = 1
  73993. }
  73994. /**
  73995. * Sub emitter class used to emit particles from an existing particle
  73996. */
  73997. export class SubEmitter {
  73998. /**
  73999. * the particle system to be used by the sub emitter
  74000. */
  74001. particleSystem: ParticleSystem;
  74002. /**
  74003. * Type of the submitter (Default: END)
  74004. */
  74005. type: SubEmitterType;
  74006. /**
  74007. * 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)
  74008. * Note: This only is supported when using an emitter of type Mesh
  74009. */
  74010. inheritDirection: boolean;
  74011. /**
  74012. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  74013. */
  74014. inheritedVelocityAmount: number;
  74015. /**
  74016. * Creates a sub emitter
  74017. * @param particleSystem the particle system to be used by the sub emitter
  74018. */
  74019. constructor(
  74020. /**
  74021. * the particle system to be used by the sub emitter
  74022. */
  74023. particleSystem: ParticleSystem);
  74024. /**
  74025. * Clones the sub emitter
  74026. * @returns the cloned sub emitter
  74027. */
  74028. clone(): SubEmitter;
  74029. /**
  74030. * Serialize current object to a JSON object
  74031. * @returns the serialized object
  74032. */
  74033. serialize(): any;
  74034. /** @hidden */
  74035. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  74036. /**
  74037. * Creates a new SubEmitter from a serialized JSON version
  74038. * @param serializationObject defines the JSON object to read from
  74039. * @param scene defines the hosting scene
  74040. * @param rootUrl defines the rootUrl for data loading
  74041. * @returns a new SubEmitter
  74042. */
  74043. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  74044. /** Release associated resources */
  74045. dispose(): void;
  74046. }
  74047. }
  74048. declare module BABYLON {
  74049. /** @hidden */
  74050. export var clipPlaneFragmentDeclaration: {
  74051. name: string;
  74052. shader: string;
  74053. };
  74054. }
  74055. declare module BABYLON {
  74056. /** @hidden */
  74057. export var imageProcessingDeclaration: {
  74058. name: string;
  74059. shader: string;
  74060. };
  74061. }
  74062. declare module BABYLON {
  74063. /** @hidden */
  74064. export var imageProcessingFunctions: {
  74065. name: string;
  74066. shader: string;
  74067. };
  74068. }
  74069. declare module BABYLON {
  74070. /** @hidden */
  74071. export var clipPlaneFragment: {
  74072. name: string;
  74073. shader: string;
  74074. };
  74075. }
  74076. declare module BABYLON {
  74077. /** @hidden */
  74078. export var particlesPixelShader: {
  74079. name: string;
  74080. shader: string;
  74081. };
  74082. }
  74083. declare module BABYLON {
  74084. /** @hidden */
  74085. export var clipPlaneVertexDeclaration: {
  74086. name: string;
  74087. shader: string;
  74088. };
  74089. }
  74090. declare module BABYLON {
  74091. /** @hidden */
  74092. export var clipPlaneVertex: {
  74093. name: string;
  74094. shader: string;
  74095. };
  74096. }
  74097. declare module BABYLON {
  74098. /** @hidden */
  74099. export var particlesVertexShader: {
  74100. name: string;
  74101. shader: string;
  74102. };
  74103. }
  74104. declare module BABYLON {
  74105. /**
  74106. * This represents a particle system in Babylon.
  74107. * 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.
  74108. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  74109. * @example https://doc.babylonjs.com/babylon101/particles
  74110. */
  74111. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  74112. /**
  74113. * Billboard mode will only apply to Y axis
  74114. */
  74115. static readonly BILLBOARDMODE_Y: number;
  74116. /**
  74117. * Billboard mode will apply to all axes
  74118. */
  74119. static readonly BILLBOARDMODE_ALL: number;
  74120. /**
  74121. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  74122. */
  74123. static readonly BILLBOARDMODE_STRETCHED: number;
  74124. /**
  74125. * This function can be defined to provide custom update for active particles.
  74126. * This function will be called instead of regular update (age, position, color, etc.).
  74127. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  74128. */
  74129. updateFunction: (particles: Particle[]) => void;
  74130. private _emitterWorldMatrix;
  74131. /**
  74132. * This function can be defined to specify initial direction for every new particle.
  74133. * It by default use the emitterType defined function
  74134. */
  74135. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  74136. /**
  74137. * This function can be defined to specify initial position for every new particle.
  74138. * It by default use the emitterType defined function
  74139. */
  74140. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  74141. /**
  74142. * @hidden
  74143. */
  74144. _inheritedVelocityOffset: Vector3;
  74145. /**
  74146. * An event triggered when the system is disposed
  74147. */
  74148. onDisposeObservable: Observable<ParticleSystem>;
  74149. private _onDisposeObserver;
  74150. /**
  74151. * Sets a callback that will be triggered when the system is disposed
  74152. */
  74153. onDispose: () => void;
  74154. private _particles;
  74155. private _epsilon;
  74156. private _capacity;
  74157. private _stockParticles;
  74158. private _newPartsExcess;
  74159. private _vertexData;
  74160. private _vertexBuffer;
  74161. private _vertexBuffers;
  74162. private _spriteBuffer;
  74163. private _indexBuffer;
  74164. private _effect;
  74165. private _customEffect;
  74166. private _cachedDefines;
  74167. private _scaledColorStep;
  74168. private _colorDiff;
  74169. private _scaledDirection;
  74170. private _scaledGravity;
  74171. private _currentRenderId;
  74172. private _alive;
  74173. private _useInstancing;
  74174. private _started;
  74175. private _stopped;
  74176. private _actualFrame;
  74177. private _scaledUpdateSpeed;
  74178. private _vertexBufferSize;
  74179. /** @hidden */
  74180. _currentEmitRateGradient: Nullable<FactorGradient>;
  74181. /** @hidden */
  74182. _currentEmitRate1: number;
  74183. /** @hidden */
  74184. _currentEmitRate2: number;
  74185. /** @hidden */
  74186. _currentStartSizeGradient: Nullable<FactorGradient>;
  74187. /** @hidden */
  74188. _currentStartSize1: number;
  74189. /** @hidden */
  74190. _currentStartSize2: number;
  74191. private readonly _rawTextureWidth;
  74192. private _rampGradientsTexture;
  74193. private _useRampGradients;
  74194. /** Gets or sets a boolean indicating that ramp gradients must be used
  74195. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  74196. */
  74197. useRampGradients: boolean;
  74198. /**
  74199. * 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.
  74200. * 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: [])
  74201. */
  74202. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  74203. private _subEmitters;
  74204. /**
  74205. * @hidden
  74206. * If the particle systems emitter should be disposed when the particle system is disposed
  74207. */
  74208. _disposeEmitterOnDispose: boolean;
  74209. /**
  74210. * The current active Sub-systems, this property is used by the root particle system only.
  74211. */
  74212. activeSubSystems: Array<ParticleSystem>;
  74213. private _rootParticleSystem;
  74214. /**
  74215. * Gets the current list of active particles
  74216. */
  74217. readonly particles: Particle[];
  74218. /**
  74219. * Returns the string "ParticleSystem"
  74220. * @returns a string containing the class name
  74221. */
  74222. getClassName(): string;
  74223. /**
  74224. * Instantiates a particle system.
  74225. * 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.
  74226. * @param name The name of the particle system
  74227. * @param capacity The max number of particles alive at the same time
  74228. * @param scene The scene the particle system belongs to
  74229. * @param customEffect a custom effect used to change the way particles are rendered by default
  74230. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  74231. * @param epsilon Offset used to render the particles
  74232. */
  74233. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  74234. private _addFactorGradient;
  74235. private _removeFactorGradient;
  74236. /**
  74237. * Adds a new life time gradient
  74238. * @param gradient defines the gradient to use (between 0 and 1)
  74239. * @param factor defines the life time factor to affect to the specified gradient
  74240. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74241. * @returns the current particle system
  74242. */
  74243. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74244. /**
  74245. * Remove a specific life time gradient
  74246. * @param gradient defines the gradient to remove
  74247. * @returns the current particle system
  74248. */
  74249. removeLifeTimeGradient(gradient: number): IParticleSystem;
  74250. /**
  74251. * Adds a new size gradient
  74252. * @param gradient defines the gradient to use (between 0 and 1)
  74253. * @param factor defines the size factor to affect to the specified gradient
  74254. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74255. * @returns the current particle system
  74256. */
  74257. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74258. /**
  74259. * Remove a specific size gradient
  74260. * @param gradient defines the gradient to remove
  74261. * @returns the current particle system
  74262. */
  74263. removeSizeGradient(gradient: number): IParticleSystem;
  74264. /**
  74265. * Adds a new color remap gradient
  74266. * @param gradient defines the gradient to use (between 0 and 1)
  74267. * @param min defines the color remap minimal range
  74268. * @param max defines the color remap maximal range
  74269. * @returns the current particle system
  74270. */
  74271. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  74272. /**
  74273. * Remove a specific color remap gradient
  74274. * @param gradient defines the gradient to remove
  74275. * @returns the current particle system
  74276. */
  74277. removeColorRemapGradient(gradient: number): IParticleSystem;
  74278. /**
  74279. * Adds a new alpha remap gradient
  74280. * @param gradient defines the gradient to use (between 0 and 1)
  74281. * @param min defines the alpha remap minimal range
  74282. * @param max defines the alpha remap maximal range
  74283. * @returns the current particle system
  74284. */
  74285. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  74286. /**
  74287. * Remove a specific alpha remap gradient
  74288. * @param gradient defines the gradient to remove
  74289. * @returns the current particle system
  74290. */
  74291. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  74292. /**
  74293. * Adds a new angular speed gradient
  74294. * @param gradient defines the gradient to use (between 0 and 1)
  74295. * @param factor defines the angular speed to affect to the specified gradient
  74296. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74297. * @returns the current particle system
  74298. */
  74299. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74300. /**
  74301. * Remove a specific angular speed gradient
  74302. * @param gradient defines the gradient to remove
  74303. * @returns the current particle system
  74304. */
  74305. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  74306. /**
  74307. * Adds a new velocity gradient
  74308. * @param gradient defines the gradient to use (between 0 and 1)
  74309. * @param factor defines the velocity to affect to the specified gradient
  74310. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74311. * @returns the current particle system
  74312. */
  74313. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74314. /**
  74315. * Remove a specific velocity gradient
  74316. * @param gradient defines the gradient to remove
  74317. * @returns the current particle system
  74318. */
  74319. removeVelocityGradient(gradient: number): IParticleSystem;
  74320. /**
  74321. * Adds a new limit velocity gradient
  74322. * @param gradient defines the gradient to use (between 0 and 1)
  74323. * @param factor defines the limit velocity value to affect to the specified gradient
  74324. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74325. * @returns the current particle system
  74326. */
  74327. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74328. /**
  74329. * Remove a specific limit velocity gradient
  74330. * @param gradient defines the gradient to remove
  74331. * @returns the current particle system
  74332. */
  74333. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  74334. /**
  74335. * Adds a new drag gradient
  74336. * @param gradient defines the gradient to use (between 0 and 1)
  74337. * @param factor defines the drag value to affect to the specified gradient
  74338. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74339. * @returns the current particle system
  74340. */
  74341. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74342. /**
  74343. * Remove a specific drag gradient
  74344. * @param gradient defines the gradient to remove
  74345. * @returns the current particle system
  74346. */
  74347. removeDragGradient(gradient: number): IParticleSystem;
  74348. /**
  74349. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  74350. * @param gradient defines the gradient to use (between 0 and 1)
  74351. * @param factor defines the emit rate value to affect to the specified gradient
  74352. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74353. * @returns the current particle system
  74354. */
  74355. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74356. /**
  74357. * Remove a specific emit rate gradient
  74358. * @param gradient defines the gradient to remove
  74359. * @returns the current particle system
  74360. */
  74361. removeEmitRateGradient(gradient: number): IParticleSystem;
  74362. /**
  74363. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  74364. * @param gradient defines the gradient to use (between 0 and 1)
  74365. * @param factor defines the start size value to affect to the specified gradient
  74366. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74367. * @returns the current particle system
  74368. */
  74369. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74370. /**
  74371. * Remove a specific start size gradient
  74372. * @param gradient defines the gradient to remove
  74373. * @returns the current particle system
  74374. */
  74375. removeStartSizeGradient(gradient: number): IParticleSystem;
  74376. private _createRampGradientTexture;
  74377. /**
  74378. * Gets the current list of ramp gradients.
  74379. * You must use addRampGradient and removeRampGradient to udpate this list
  74380. * @returns the list of ramp gradients
  74381. */
  74382. getRampGradients(): Nullable<Array<Color3Gradient>>;
  74383. /**
  74384. * Adds a new ramp gradient used to remap particle colors
  74385. * @param gradient defines the gradient to use (between 0 and 1)
  74386. * @param color defines the color to affect to the specified gradient
  74387. * @returns the current particle system
  74388. */
  74389. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  74390. /**
  74391. * Remove a specific ramp gradient
  74392. * @param gradient defines the gradient to remove
  74393. * @returns the current particle system
  74394. */
  74395. removeRampGradient(gradient: number): ParticleSystem;
  74396. /**
  74397. * Adds a new color gradient
  74398. * @param gradient defines the gradient to use (between 0 and 1)
  74399. * @param color1 defines the color to affect to the specified gradient
  74400. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  74401. * @returns this particle system
  74402. */
  74403. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  74404. /**
  74405. * Remove a specific color gradient
  74406. * @param gradient defines the gradient to remove
  74407. * @returns this particle system
  74408. */
  74409. removeColorGradient(gradient: number): IParticleSystem;
  74410. private _fetchR;
  74411. protected _reset(): void;
  74412. private _resetEffect;
  74413. private _createVertexBuffers;
  74414. private _createIndexBuffer;
  74415. /**
  74416. * Gets the maximum number of particles active at the same time.
  74417. * @returns The max number of active particles.
  74418. */
  74419. getCapacity(): number;
  74420. /**
  74421. * Gets whether there are still active particles in the system.
  74422. * @returns True if it is alive, otherwise false.
  74423. */
  74424. isAlive(): boolean;
  74425. /**
  74426. * Gets if the system has been started. (Note: this will still be true after stop is called)
  74427. * @returns True if it has been started, otherwise false.
  74428. */
  74429. isStarted(): boolean;
  74430. private _prepareSubEmitterInternalArray;
  74431. /**
  74432. * Starts the particle system and begins to emit
  74433. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  74434. */
  74435. start(delay?: number): void;
  74436. /**
  74437. * Stops the particle system.
  74438. * @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.
  74439. */
  74440. stop(stopSubEmitters?: boolean): void;
  74441. /**
  74442. * Remove all active particles
  74443. */
  74444. reset(): void;
  74445. /**
  74446. * @hidden (for internal use only)
  74447. */
  74448. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  74449. /**
  74450. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  74451. * Its lifetime will start back at 0.
  74452. */
  74453. recycleParticle: (particle: Particle) => void;
  74454. private _stopSubEmitters;
  74455. private _createParticle;
  74456. private _removeFromRoot;
  74457. private _emitFromParticle;
  74458. private _update;
  74459. /** @hidden */
  74460. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  74461. /** @hidden */
  74462. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  74463. /** @hidden */
  74464. private _getEffect;
  74465. /**
  74466. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  74467. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  74468. */
  74469. animate(preWarmOnly?: boolean): void;
  74470. private _appendParticleVertices;
  74471. /**
  74472. * Rebuilds the particle system.
  74473. */
  74474. rebuild(): void;
  74475. /**
  74476. * Is this system ready to be used/rendered
  74477. * @return true if the system is ready
  74478. */
  74479. isReady(): boolean;
  74480. private _render;
  74481. /**
  74482. * Renders the particle system in its current state.
  74483. * @returns the current number of particles
  74484. */
  74485. render(): number;
  74486. /**
  74487. * Disposes the particle system and free the associated resources
  74488. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  74489. */
  74490. dispose(disposeTexture?: boolean): void;
  74491. /**
  74492. * Clones the particle system.
  74493. * @param name The name of the cloned object
  74494. * @param newEmitter The new emitter to use
  74495. * @returns the cloned particle system
  74496. */
  74497. clone(name: string, newEmitter: any): ParticleSystem;
  74498. /**
  74499. * Serializes the particle system to a JSON object.
  74500. * @returns the JSON object
  74501. */
  74502. serialize(): any;
  74503. /** @hidden */
  74504. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  74505. /** @hidden */
  74506. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  74507. /**
  74508. * Parses a JSON object to create a particle system.
  74509. * @param parsedParticleSystem The JSON object to parse
  74510. * @param scene The scene to create the particle system in
  74511. * @param rootUrl The root url to use to load external dependencies like texture
  74512. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  74513. * @returns the Parsed particle system
  74514. */
  74515. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  74516. }
  74517. }
  74518. declare module BABYLON {
  74519. /**
  74520. * A particle represents one of the element emitted by a particle system.
  74521. * This is mainly define by its coordinates, direction, velocity and age.
  74522. */
  74523. export class Particle {
  74524. /**
  74525. * The particle system the particle belongs to.
  74526. */
  74527. particleSystem: ParticleSystem;
  74528. private static _Count;
  74529. /**
  74530. * Unique ID of the particle
  74531. */
  74532. id: number;
  74533. /**
  74534. * The world position of the particle in the scene.
  74535. */
  74536. position: Vector3;
  74537. /**
  74538. * The world direction of the particle in the scene.
  74539. */
  74540. direction: Vector3;
  74541. /**
  74542. * The color of the particle.
  74543. */
  74544. color: Color4;
  74545. /**
  74546. * The color change of the particle per step.
  74547. */
  74548. colorStep: Color4;
  74549. /**
  74550. * Defines how long will the life of the particle be.
  74551. */
  74552. lifeTime: number;
  74553. /**
  74554. * The current age of the particle.
  74555. */
  74556. age: number;
  74557. /**
  74558. * The current size of the particle.
  74559. */
  74560. size: number;
  74561. /**
  74562. * The current scale of the particle.
  74563. */
  74564. scale: Vector2;
  74565. /**
  74566. * The current angle of the particle.
  74567. */
  74568. angle: number;
  74569. /**
  74570. * Defines how fast is the angle changing.
  74571. */
  74572. angularSpeed: number;
  74573. /**
  74574. * Defines the cell index used by the particle to be rendered from a sprite.
  74575. */
  74576. cellIndex: number;
  74577. /**
  74578. * The information required to support color remapping
  74579. */
  74580. remapData: Vector4;
  74581. /** @hidden */
  74582. _randomCellOffset?: number;
  74583. /** @hidden */
  74584. _initialDirection: Nullable<Vector3>;
  74585. /** @hidden */
  74586. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  74587. /** @hidden */
  74588. _initialStartSpriteCellID: number;
  74589. /** @hidden */
  74590. _initialEndSpriteCellID: number;
  74591. /** @hidden */
  74592. _currentColorGradient: Nullable<ColorGradient>;
  74593. /** @hidden */
  74594. _currentColor1: Color4;
  74595. /** @hidden */
  74596. _currentColor2: Color4;
  74597. /** @hidden */
  74598. _currentSizeGradient: Nullable<FactorGradient>;
  74599. /** @hidden */
  74600. _currentSize1: number;
  74601. /** @hidden */
  74602. _currentSize2: number;
  74603. /** @hidden */
  74604. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  74605. /** @hidden */
  74606. _currentAngularSpeed1: number;
  74607. /** @hidden */
  74608. _currentAngularSpeed2: number;
  74609. /** @hidden */
  74610. _currentVelocityGradient: Nullable<FactorGradient>;
  74611. /** @hidden */
  74612. _currentVelocity1: number;
  74613. /** @hidden */
  74614. _currentVelocity2: number;
  74615. /** @hidden */
  74616. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  74617. /** @hidden */
  74618. _currentLimitVelocity1: number;
  74619. /** @hidden */
  74620. _currentLimitVelocity2: number;
  74621. /** @hidden */
  74622. _currentDragGradient: Nullable<FactorGradient>;
  74623. /** @hidden */
  74624. _currentDrag1: number;
  74625. /** @hidden */
  74626. _currentDrag2: number;
  74627. /** @hidden */
  74628. _randomNoiseCoordinates1: Vector3;
  74629. /** @hidden */
  74630. _randomNoiseCoordinates2: Vector3;
  74631. /**
  74632. * Creates a new instance Particle
  74633. * @param particleSystem the particle system the particle belongs to
  74634. */
  74635. constructor(
  74636. /**
  74637. * The particle system the particle belongs to.
  74638. */
  74639. particleSystem: ParticleSystem);
  74640. private updateCellInfoFromSystem;
  74641. /**
  74642. * Defines how the sprite cell index is updated for the particle
  74643. */
  74644. updateCellIndex(): void;
  74645. /** @hidden */
  74646. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  74647. /** @hidden */
  74648. _inheritParticleInfoToSubEmitters(): void;
  74649. /** @hidden */
  74650. _reset(): void;
  74651. /**
  74652. * Copy the properties of particle to another one.
  74653. * @param other the particle to copy the information to.
  74654. */
  74655. copyTo(other: Particle): void;
  74656. }
  74657. }
  74658. declare module BABYLON {
  74659. /**
  74660. * Particle emitter represents a volume emitting particles.
  74661. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  74662. */
  74663. export interface IParticleEmitterType {
  74664. /**
  74665. * Called by the particle System when the direction is computed for the created particle.
  74666. * @param worldMatrix is the world matrix of the particle system
  74667. * @param directionToUpdate is the direction vector to update with the result
  74668. * @param particle is the particle we are computed the direction for
  74669. */
  74670. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74671. /**
  74672. * Called by the particle System when the position is computed for the created particle.
  74673. * @param worldMatrix is the world matrix of the particle system
  74674. * @param positionToUpdate is the position vector to update with the result
  74675. * @param particle is the particle we are computed the position for
  74676. */
  74677. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74678. /**
  74679. * Clones the current emitter and returns a copy of it
  74680. * @returns the new emitter
  74681. */
  74682. clone(): IParticleEmitterType;
  74683. /**
  74684. * Called by the GPUParticleSystem to setup the update shader
  74685. * @param effect defines the update shader
  74686. */
  74687. applyToShader(effect: Effect): void;
  74688. /**
  74689. * Returns a string to use to update the GPU particles update shader
  74690. * @returns the effect defines string
  74691. */
  74692. getEffectDefines(): string;
  74693. /**
  74694. * Returns a string representing the class name
  74695. * @returns a string containing the class name
  74696. */
  74697. getClassName(): string;
  74698. /**
  74699. * Serializes the particle system to a JSON object.
  74700. * @returns the JSON object
  74701. */
  74702. serialize(): any;
  74703. /**
  74704. * Parse properties from a JSON object
  74705. * @param serializationObject defines the JSON object
  74706. */
  74707. parse(serializationObject: any): void;
  74708. }
  74709. }
  74710. declare module BABYLON {
  74711. /**
  74712. * Particle emitter emitting particles from the inside of a box.
  74713. * It emits the particles randomly between 2 given directions.
  74714. */
  74715. export class BoxParticleEmitter implements IParticleEmitterType {
  74716. /**
  74717. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74718. */
  74719. direction1: Vector3;
  74720. /**
  74721. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74722. */
  74723. direction2: Vector3;
  74724. /**
  74725. * 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.
  74726. */
  74727. minEmitBox: Vector3;
  74728. /**
  74729. * 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.
  74730. */
  74731. maxEmitBox: Vector3;
  74732. /**
  74733. * Creates a new instance BoxParticleEmitter
  74734. */
  74735. constructor();
  74736. /**
  74737. * Called by the particle System when the direction is computed for the created particle.
  74738. * @param worldMatrix is the world matrix of the particle system
  74739. * @param directionToUpdate is the direction vector to update with the result
  74740. * @param particle is the particle we are computed the direction for
  74741. */
  74742. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74743. /**
  74744. * Called by the particle System when the position is computed for the created particle.
  74745. * @param worldMatrix is the world matrix of the particle system
  74746. * @param positionToUpdate is the position vector to update with the result
  74747. * @param particle is the particle we are computed the position for
  74748. */
  74749. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74750. /**
  74751. * Clones the current emitter and returns a copy of it
  74752. * @returns the new emitter
  74753. */
  74754. clone(): BoxParticleEmitter;
  74755. /**
  74756. * Called by the GPUParticleSystem to setup the update shader
  74757. * @param effect defines the update shader
  74758. */
  74759. applyToShader(effect: Effect): void;
  74760. /**
  74761. * Returns a string to use to update the GPU particles update shader
  74762. * @returns a string containng the defines string
  74763. */
  74764. getEffectDefines(): string;
  74765. /**
  74766. * Returns the string "BoxParticleEmitter"
  74767. * @returns a string containing the class name
  74768. */
  74769. getClassName(): string;
  74770. /**
  74771. * Serializes the particle system to a JSON object.
  74772. * @returns the JSON object
  74773. */
  74774. serialize(): any;
  74775. /**
  74776. * Parse properties from a JSON object
  74777. * @param serializationObject defines the JSON object
  74778. */
  74779. parse(serializationObject: any): void;
  74780. }
  74781. }
  74782. declare module BABYLON {
  74783. /**
  74784. * Particle emitter emitting particles from the inside of a cone.
  74785. * It emits the particles alongside the cone volume from the base to the particle.
  74786. * The emission direction might be randomized.
  74787. */
  74788. export class ConeParticleEmitter implements IParticleEmitterType {
  74789. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  74790. directionRandomizer: number;
  74791. private _radius;
  74792. private _angle;
  74793. private _height;
  74794. /**
  74795. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  74796. */
  74797. radiusRange: number;
  74798. /**
  74799. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  74800. */
  74801. heightRange: number;
  74802. /**
  74803. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  74804. */
  74805. emitFromSpawnPointOnly: boolean;
  74806. /**
  74807. * Gets or sets the radius of the emission cone
  74808. */
  74809. radius: number;
  74810. /**
  74811. * Gets or sets the angle of the emission cone
  74812. */
  74813. angle: number;
  74814. private _buildHeight;
  74815. /**
  74816. * Creates a new instance ConeParticleEmitter
  74817. * @param radius the radius of the emission cone (1 by default)
  74818. * @param angle the cone base angle (PI by default)
  74819. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  74820. */
  74821. constructor(radius?: number, angle?: number,
  74822. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  74823. directionRandomizer?: number);
  74824. /**
  74825. * Called by the particle System when the direction is computed for the created particle.
  74826. * @param worldMatrix is the world matrix of the particle system
  74827. * @param directionToUpdate is the direction vector to update with the result
  74828. * @param particle is the particle we are computed the direction for
  74829. */
  74830. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74831. /**
  74832. * Called by the particle System when the position is computed for the created particle.
  74833. * @param worldMatrix is the world matrix of the particle system
  74834. * @param positionToUpdate is the position vector to update with the result
  74835. * @param particle is the particle we are computed the position for
  74836. */
  74837. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74838. /**
  74839. * Clones the current emitter and returns a copy of it
  74840. * @returns the new emitter
  74841. */
  74842. clone(): ConeParticleEmitter;
  74843. /**
  74844. * Called by the GPUParticleSystem to setup the update shader
  74845. * @param effect defines the update shader
  74846. */
  74847. applyToShader(effect: Effect): void;
  74848. /**
  74849. * Returns a string to use to update the GPU particles update shader
  74850. * @returns a string containng the defines string
  74851. */
  74852. getEffectDefines(): string;
  74853. /**
  74854. * Returns the string "ConeParticleEmitter"
  74855. * @returns a string containing the class name
  74856. */
  74857. getClassName(): string;
  74858. /**
  74859. * Serializes the particle system to a JSON object.
  74860. * @returns the JSON object
  74861. */
  74862. serialize(): any;
  74863. /**
  74864. * Parse properties from a JSON object
  74865. * @param serializationObject defines the JSON object
  74866. */
  74867. parse(serializationObject: any): void;
  74868. }
  74869. }
  74870. declare module BABYLON {
  74871. /**
  74872. * Particle emitter emitting particles from the inside of a cylinder.
  74873. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  74874. */
  74875. export class CylinderParticleEmitter implements IParticleEmitterType {
  74876. /**
  74877. * The radius of the emission cylinder.
  74878. */
  74879. radius: number;
  74880. /**
  74881. * The height of the emission cylinder.
  74882. */
  74883. height: number;
  74884. /**
  74885. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74886. */
  74887. radiusRange: number;
  74888. /**
  74889. * How much to randomize the particle direction [0-1].
  74890. */
  74891. directionRandomizer: number;
  74892. /**
  74893. * Creates a new instance CylinderParticleEmitter
  74894. * @param radius the radius of the emission cylinder (1 by default)
  74895. * @param height the height of the emission cylinder (1 by default)
  74896. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74897. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  74898. */
  74899. constructor(
  74900. /**
  74901. * The radius of the emission cylinder.
  74902. */
  74903. radius?: number,
  74904. /**
  74905. * The height of the emission cylinder.
  74906. */
  74907. height?: number,
  74908. /**
  74909. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74910. */
  74911. radiusRange?: number,
  74912. /**
  74913. * How much to randomize the particle direction [0-1].
  74914. */
  74915. directionRandomizer?: number);
  74916. /**
  74917. * Called by the particle System when the direction is computed for the created particle.
  74918. * @param worldMatrix is the world matrix of the particle system
  74919. * @param directionToUpdate is the direction vector to update with the result
  74920. * @param particle is the particle we are computed the direction for
  74921. */
  74922. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74923. /**
  74924. * Called by the particle System when the position is computed for the created particle.
  74925. * @param worldMatrix is the world matrix of the particle system
  74926. * @param positionToUpdate is the position vector to update with the result
  74927. * @param particle is the particle we are computed the position for
  74928. */
  74929. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74930. /**
  74931. * Clones the current emitter and returns a copy of it
  74932. * @returns the new emitter
  74933. */
  74934. clone(): CylinderParticleEmitter;
  74935. /**
  74936. * Called by the GPUParticleSystem to setup the update shader
  74937. * @param effect defines the update shader
  74938. */
  74939. applyToShader(effect: Effect): void;
  74940. /**
  74941. * Returns a string to use to update the GPU particles update shader
  74942. * @returns a string containng the defines string
  74943. */
  74944. getEffectDefines(): string;
  74945. /**
  74946. * Returns the string "CylinderParticleEmitter"
  74947. * @returns a string containing the class name
  74948. */
  74949. getClassName(): string;
  74950. /**
  74951. * Serializes the particle system to a JSON object.
  74952. * @returns the JSON object
  74953. */
  74954. serialize(): any;
  74955. /**
  74956. * Parse properties from a JSON object
  74957. * @param serializationObject defines the JSON object
  74958. */
  74959. parse(serializationObject: any): void;
  74960. }
  74961. /**
  74962. * Particle emitter emitting particles from the inside of a cylinder.
  74963. * It emits the particles randomly between two vectors.
  74964. */
  74965. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  74966. /**
  74967. * The min limit of the emission direction.
  74968. */
  74969. direction1: Vector3;
  74970. /**
  74971. * The max limit of the emission direction.
  74972. */
  74973. direction2: Vector3;
  74974. /**
  74975. * Creates a new instance CylinderDirectedParticleEmitter
  74976. * @param radius the radius of the emission cylinder (1 by default)
  74977. * @param height the height of the emission cylinder (1 by default)
  74978. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74979. * @param direction1 the min limit of the emission direction (up vector by default)
  74980. * @param direction2 the max limit of the emission direction (up vector by default)
  74981. */
  74982. constructor(radius?: number, height?: number, radiusRange?: number,
  74983. /**
  74984. * The min limit of the emission direction.
  74985. */
  74986. direction1?: Vector3,
  74987. /**
  74988. * The max limit of the emission direction.
  74989. */
  74990. direction2?: Vector3);
  74991. /**
  74992. * Called by the particle System when the direction is computed for the created particle.
  74993. * @param worldMatrix is the world matrix of the particle system
  74994. * @param directionToUpdate is the direction vector to update with the result
  74995. * @param particle is the particle we are computed the direction for
  74996. */
  74997. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74998. /**
  74999. * Clones the current emitter and returns a copy of it
  75000. * @returns the new emitter
  75001. */
  75002. clone(): CylinderDirectedParticleEmitter;
  75003. /**
  75004. * Called by the GPUParticleSystem to setup the update shader
  75005. * @param effect defines the update shader
  75006. */
  75007. applyToShader(effect: Effect): void;
  75008. /**
  75009. * Returns a string to use to update the GPU particles update shader
  75010. * @returns a string containng the defines string
  75011. */
  75012. getEffectDefines(): string;
  75013. /**
  75014. * Returns the string "CylinderDirectedParticleEmitter"
  75015. * @returns a string containing the class name
  75016. */
  75017. getClassName(): string;
  75018. /**
  75019. * Serializes the particle system to a JSON object.
  75020. * @returns the JSON object
  75021. */
  75022. serialize(): any;
  75023. /**
  75024. * Parse properties from a JSON object
  75025. * @param serializationObject defines the JSON object
  75026. */
  75027. parse(serializationObject: any): void;
  75028. }
  75029. }
  75030. declare module BABYLON {
  75031. /**
  75032. * Particle emitter emitting particles from the inside of a hemisphere.
  75033. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  75034. */
  75035. export class HemisphericParticleEmitter implements IParticleEmitterType {
  75036. /**
  75037. * The radius of the emission hemisphere.
  75038. */
  75039. radius: number;
  75040. /**
  75041. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75042. */
  75043. radiusRange: number;
  75044. /**
  75045. * How much to randomize the particle direction [0-1].
  75046. */
  75047. directionRandomizer: number;
  75048. /**
  75049. * Creates a new instance HemisphericParticleEmitter
  75050. * @param radius the radius of the emission hemisphere (1 by default)
  75051. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75052. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75053. */
  75054. constructor(
  75055. /**
  75056. * The radius of the emission hemisphere.
  75057. */
  75058. radius?: number,
  75059. /**
  75060. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75061. */
  75062. radiusRange?: number,
  75063. /**
  75064. * How much to randomize the particle direction [0-1].
  75065. */
  75066. directionRandomizer?: number);
  75067. /**
  75068. * Called by the particle System when the direction is computed for the created particle.
  75069. * @param worldMatrix is the world matrix of the particle system
  75070. * @param directionToUpdate is the direction vector to update with the result
  75071. * @param particle is the particle we are computed the direction for
  75072. */
  75073. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75074. /**
  75075. * Called by the particle System when the position is computed for the created particle.
  75076. * @param worldMatrix is the world matrix of the particle system
  75077. * @param positionToUpdate is the position vector to update with the result
  75078. * @param particle is the particle we are computed the position for
  75079. */
  75080. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75081. /**
  75082. * Clones the current emitter and returns a copy of it
  75083. * @returns the new emitter
  75084. */
  75085. clone(): HemisphericParticleEmitter;
  75086. /**
  75087. * Called by the GPUParticleSystem to setup the update shader
  75088. * @param effect defines the update shader
  75089. */
  75090. applyToShader(effect: Effect): void;
  75091. /**
  75092. * Returns a string to use to update the GPU particles update shader
  75093. * @returns a string containng the defines string
  75094. */
  75095. getEffectDefines(): string;
  75096. /**
  75097. * Returns the string "HemisphericParticleEmitter"
  75098. * @returns a string containing the class name
  75099. */
  75100. getClassName(): string;
  75101. /**
  75102. * Serializes the particle system to a JSON object.
  75103. * @returns the JSON object
  75104. */
  75105. serialize(): any;
  75106. /**
  75107. * Parse properties from a JSON object
  75108. * @param serializationObject defines the JSON object
  75109. */
  75110. parse(serializationObject: any): void;
  75111. }
  75112. }
  75113. declare module BABYLON {
  75114. /**
  75115. * Particle emitter emitting particles from a point.
  75116. * It emits the particles randomly between 2 given directions.
  75117. */
  75118. export class PointParticleEmitter implements IParticleEmitterType {
  75119. /**
  75120. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75121. */
  75122. direction1: Vector3;
  75123. /**
  75124. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75125. */
  75126. direction2: Vector3;
  75127. /**
  75128. * Creates a new instance PointParticleEmitter
  75129. */
  75130. constructor();
  75131. /**
  75132. * Called by the particle System when the direction is computed for the created particle.
  75133. * @param worldMatrix is the world matrix of the particle system
  75134. * @param directionToUpdate is the direction vector to update with the result
  75135. * @param particle is the particle we are computed the direction for
  75136. */
  75137. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75138. /**
  75139. * Called by the particle System when the position is computed for the created particle.
  75140. * @param worldMatrix is the world matrix of the particle system
  75141. * @param positionToUpdate is the position vector to update with the result
  75142. * @param particle is the particle we are computed the position for
  75143. */
  75144. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75145. /**
  75146. * Clones the current emitter and returns a copy of it
  75147. * @returns the new emitter
  75148. */
  75149. clone(): PointParticleEmitter;
  75150. /**
  75151. * Called by the GPUParticleSystem to setup the update shader
  75152. * @param effect defines the update shader
  75153. */
  75154. applyToShader(effect: Effect): void;
  75155. /**
  75156. * Returns a string to use to update the GPU particles update shader
  75157. * @returns a string containng the defines string
  75158. */
  75159. getEffectDefines(): string;
  75160. /**
  75161. * Returns the string "PointParticleEmitter"
  75162. * @returns a string containing the class name
  75163. */
  75164. getClassName(): string;
  75165. /**
  75166. * Serializes the particle system to a JSON object.
  75167. * @returns the JSON object
  75168. */
  75169. serialize(): any;
  75170. /**
  75171. * Parse properties from a JSON object
  75172. * @param serializationObject defines the JSON object
  75173. */
  75174. parse(serializationObject: any): void;
  75175. }
  75176. }
  75177. declare module BABYLON {
  75178. /**
  75179. * Particle emitter emitting particles from the inside of a sphere.
  75180. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  75181. */
  75182. export class SphereParticleEmitter implements IParticleEmitterType {
  75183. /**
  75184. * The radius of the emission sphere.
  75185. */
  75186. radius: number;
  75187. /**
  75188. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75189. */
  75190. radiusRange: number;
  75191. /**
  75192. * How much to randomize the particle direction [0-1].
  75193. */
  75194. directionRandomizer: number;
  75195. /**
  75196. * Creates a new instance SphereParticleEmitter
  75197. * @param radius the radius of the emission sphere (1 by default)
  75198. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75199. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75200. */
  75201. constructor(
  75202. /**
  75203. * The radius of the emission sphere.
  75204. */
  75205. radius?: number,
  75206. /**
  75207. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75208. */
  75209. radiusRange?: number,
  75210. /**
  75211. * How much to randomize the particle direction [0-1].
  75212. */
  75213. directionRandomizer?: number);
  75214. /**
  75215. * Called by the particle System when the direction is computed for the created particle.
  75216. * @param worldMatrix is the world matrix of the particle system
  75217. * @param directionToUpdate is the direction vector to update with the result
  75218. * @param particle is the particle we are computed the direction for
  75219. */
  75220. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75221. /**
  75222. * Called by the particle System when the position is computed for the created particle.
  75223. * @param worldMatrix is the world matrix of the particle system
  75224. * @param positionToUpdate is the position vector to update with the result
  75225. * @param particle is the particle we are computed the position for
  75226. */
  75227. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75228. /**
  75229. * Clones the current emitter and returns a copy of it
  75230. * @returns the new emitter
  75231. */
  75232. clone(): SphereParticleEmitter;
  75233. /**
  75234. * Called by the GPUParticleSystem to setup the update shader
  75235. * @param effect defines the update shader
  75236. */
  75237. applyToShader(effect: Effect): void;
  75238. /**
  75239. * Returns a string to use to update the GPU particles update shader
  75240. * @returns a string containng the defines string
  75241. */
  75242. getEffectDefines(): string;
  75243. /**
  75244. * Returns the string "SphereParticleEmitter"
  75245. * @returns a string containing the class name
  75246. */
  75247. getClassName(): string;
  75248. /**
  75249. * Serializes the particle system to a JSON object.
  75250. * @returns the JSON object
  75251. */
  75252. serialize(): any;
  75253. /**
  75254. * Parse properties from a JSON object
  75255. * @param serializationObject defines the JSON object
  75256. */
  75257. parse(serializationObject: any): void;
  75258. }
  75259. /**
  75260. * Particle emitter emitting particles from the inside of a sphere.
  75261. * It emits the particles randomly between two vectors.
  75262. */
  75263. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  75264. /**
  75265. * The min limit of the emission direction.
  75266. */
  75267. direction1: Vector3;
  75268. /**
  75269. * The max limit of the emission direction.
  75270. */
  75271. direction2: Vector3;
  75272. /**
  75273. * Creates a new instance SphereDirectedParticleEmitter
  75274. * @param radius the radius of the emission sphere (1 by default)
  75275. * @param direction1 the min limit of the emission direction (up vector by default)
  75276. * @param direction2 the max limit of the emission direction (up vector by default)
  75277. */
  75278. constructor(radius?: number,
  75279. /**
  75280. * The min limit of the emission direction.
  75281. */
  75282. direction1?: Vector3,
  75283. /**
  75284. * The max limit of the emission direction.
  75285. */
  75286. direction2?: Vector3);
  75287. /**
  75288. * Called by the particle System when the direction is computed for the created particle.
  75289. * @param worldMatrix is the world matrix of the particle system
  75290. * @param directionToUpdate is the direction vector to update with the result
  75291. * @param particle is the particle we are computed the direction for
  75292. */
  75293. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75294. /**
  75295. * Clones the current emitter and returns a copy of it
  75296. * @returns the new emitter
  75297. */
  75298. clone(): SphereDirectedParticleEmitter;
  75299. /**
  75300. * Called by the GPUParticleSystem to setup the update shader
  75301. * @param effect defines the update shader
  75302. */
  75303. applyToShader(effect: Effect): void;
  75304. /**
  75305. * Returns a string to use to update the GPU particles update shader
  75306. * @returns a string containng the defines string
  75307. */
  75308. getEffectDefines(): string;
  75309. /**
  75310. * Returns the string "SphereDirectedParticleEmitter"
  75311. * @returns a string containing the class name
  75312. */
  75313. getClassName(): string;
  75314. /**
  75315. * Serializes the particle system to a JSON object.
  75316. * @returns the JSON object
  75317. */
  75318. serialize(): any;
  75319. /**
  75320. * Parse properties from a JSON object
  75321. * @param serializationObject defines the JSON object
  75322. */
  75323. parse(serializationObject: any): void;
  75324. }
  75325. }
  75326. declare module BABYLON {
  75327. /**
  75328. * Interface representing a particle system in Babylon.js.
  75329. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  75330. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  75331. */
  75332. export interface IParticleSystem {
  75333. /**
  75334. * List of animations used by the particle system.
  75335. */
  75336. animations: Animation[];
  75337. /**
  75338. * The id of the Particle system.
  75339. */
  75340. id: string;
  75341. /**
  75342. * The name of the Particle system.
  75343. */
  75344. name: string;
  75345. /**
  75346. * The emitter represents the Mesh or position we are attaching the particle system to.
  75347. */
  75348. emitter: Nullable<AbstractMesh | Vector3>;
  75349. /**
  75350. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  75351. */
  75352. isBillboardBased: boolean;
  75353. /**
  75354. * The rendering group used by the Particle system to chose when to render.
  75355. */
  75356. renderingGroupId: number;
  75357. /**
  75358. * The layer mask we are rendering the particles through.
  75359. */
  75360. layerMask: number;
  75361. /**
  75362. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  75363. */
  75364. updateSpeed: number;
  75365. /**
  75366. * The amount of time the particle system is running (depends of the overall update speed).
  75367. */
  75368. targetStopDuration: number;
  75369. /**
  75370. * The texture used to render each particle. (this can be a spritesheet)
  75371. */
  75372. particleTexture: Nullable<Texture>;
  75373. /**
  75374. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  75375. */
  75376. blendMode: number;
  75377. /**
  75378. * Minimum life time of emitting particles.
  75379. */
  75380. minLifeTime: number;
  75381. /**
  75382. * Maximum life time of emitting particles.
  75383. */
  75384. maxLifeTime: number;
  75385. /**
  75386. * Minimum Size of emitting particles.
  75387. */
  75388. minSize: number;
  75389. /**
  75390. * Maximum Size of emitting particles.
  75391. */
  75392. maxSize: number;
  75393. /**
  75394. * Minimum scale of emitting particles on X axis.
  75395. */
  75396. minScaleX: number;
  75397. /**
  75398. * Maximum scale of emitting particles on X axis.
  75399. */
  75400. maxScaleX: number;
  75401. /**
  75402. * Minimum scale of emitting particles on Y axis.
  75403. */
  75404. minScaleY: number;
  75405. /**
  75406. * Maximum scale of emitting particles on Y axis.
  75407. */
  75408. maxScaleY: number;
  75409. /**
  75410. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  75411. */
  75412. color1: Color4;
  75413. /**
  75414. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  75415. */
  75416. color2: Color4;
  75417. /**
  75418. * Color the particle will have at the end of its lifetime.
  75419. */
  75420. colorDead: Color4;
  75421. /**
  75422. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  75423. */
  75424. emitRate: number;
  75425. /**
  75426. * You can use gravity if you want to give an orientation to your particles.
  75427. */
  75428. gravity: Vector3;
  75429. /**
  75430. * Minimum power of emitting particles.
  75431. */
  75432. minEmitPower: number;
  75433. /**
  75434. * Maximum power of emitting particles.
  75435. */
  75436. maxEmitPower: number;
  75437. /**
  75438. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  75439. */
  75440. minAngularSpeed: number;
  75441. /**
  75442. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  75443. */
  75444. maxAngularSpeed: number;
  75445. /**
  75446. * Gets or sets the minimal initial rotation in radians.
  75447. */
  75448. minInitialRotation: number;
  75449. /**
  75450. * Gets or sets the maximal initial rotation in radians.
  75451. */
  75452. maxInitialRotation: number;
  75453. /**
  75454. * The particle emitter type defines the emitter used by the particle system.
  75455. * It can be for example box, sphere, or cone...
  75456. */
  75457. particleEmitterType: Nullable<IParticleEmitterType>;
  75458. /**
  75459. * Defines the delay in milliseconds before starting the system (0 by default)
  75460. */
  75461. startDelay: number;
  75462. /**
  75463. * 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
  75464. */
  75465. preWarmCycles: number;
  75466. /**
  75467. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  75468. */
  75469. preWarmStepOffset: number;
  75470. /**
  75471. * 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)
  75472. */
  75473. spriteCellChangeSpeed: number;
  75474. /**
  75475. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  75476. */
  75477. startSpriteCellID: number;
  75478. /**
  75479. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  75480. */
  75481. endSpriteCellID: number;
  75482. /**
  75483. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  75484. */
  75485. spriteCellWidth: number;
  75486. /**
  75487. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  75488. */
  75489. spriteCellHeight: number;
  75490. /**
  75491. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  75492. */
  75493. spriteRandomStartCell: boolean;
  75494. /**
  75495. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  75496. */
  75497. isAnimationSheetEnabled: boolean;
  75498. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  75499. translationPivot: Vector2;
  75500. /**
  75501. * Gets or sets a texture used to add random noise to particle positions
  75502. */
  75503. noiseTexture: Nullable<BaseTexture>;
  75504. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  75505. noiseStrength: Vector3;
  75506. /**
  75507. * Gets or sets the billboard mode to use when isBillboardBased = true.
  75508. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  75509. */
  75510. billboardMode: number;
  75511. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  75512. limitVelocityDamping: number;
  75513. /**
  75514. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  75515. */
  75516. beginAnimationOnStart: boolean;
  75517. /**
  75518. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  75519. */
  75520. beginAnimationFrom: number;
  75521. /**
  75522. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  75523. */
  75524. beginAnimationTo: number;
  75525. /**
  75526. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  75527. */
  75528. beginAnimationLoop: boolean;
  75529. /**
  75530. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  75531. */
  75532. disposeOnStop: boolean;
  75533. /**
  75534. * Gets the maximum number of particles active at the same time.
  75535. * @returns The max number of active particles.
  75536. */
  75537. getCapacity(): number;
  75538. /**
  75539. * Gets if the system has been started. (Note: this will still be true after stop is called)
  75540. * @returns True if it has been started, otherwise false.
  75541. */
  75542. isStarted(): boolean;
  75543. /**
  75544. * Animates the particle system for this frame.
  75545. */
  75546. animate(): void;
  75547. /**
  75548. * Renders the particle system in its current state.
  75549. * @returns the current number of particles
  75550. */
  75551. render(): number;
  75552. /**
  75553. * Dispose the particle system and frees its associated resources.
  75554. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  75555. */
  75556. dispose(disposeTexture?: boolean): void;
  75557. /**
  75558. * Clones the particle system.
  75559. * @param name The name of the cloned object
  75560. * @param newEmitter The new emitter to use
  75561. * @returns the cloned particle system
  75562. */
  75563. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  75564. /**
  75565. * Serializes the particle system to a JSON object.
  75566. * @returns the JSON object
  75567. */
  75568. serialize(): any;
  75569. /**
  75570. * Rebuild the particle system
  75571. */
  75572. rebuild(): void;
  75573. /**
  75574. * Starts the particle system and begins to emit
  75575. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  75576. */
  75577. start(delay?: number): void;
  75578. /**
  75579. * Stops the particle system.
  75580. */
  75581. stop(): void;
  75582. /**
  75583. * Remove all active particles
  75584. */
  75585. reset(): void;
  75586. /**
  75587. * Is this system ready to be used/rendered
  75588. * @return true if the system is ready
  75589. */
  75590. isReady(): boolean;
  75591. /**
  75592. * Adds a new color gradient
  75593. * @param gradient defines the gradient to use (between 0 and 1)
  75594. * @param color1 defines the color to affect to the specified gradient
  75595. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  75596. * @returns the current particle system
  75597. */
  75598. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  75599. /**
  75600. * Remove a specific color gradient
  75601. * @param gradient defines the gradient to remove
  75602. * @returns the current particle system
  75603. */
  75604. removeColorGradient(gradient: number): IParticleSystem;
  75605. /**
  75606. * Adds a new size gradient
  75607. * @param gradient defines the gradient to use (between 0 and 1)
  75608. * @param factor defines the size factor to affect to the specified gradient
  75609. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75610. * @returns the current particle system
  75611. */
  75612. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75613. /**
  75614. * Remove a specific size gradient
  75615. * @param gradient defines the gradient to remove
  75616. * @returns the current particle system
  75617. */
  75618. removeSizeGradient(gradient: number): IParticleSystem;
  75619. /**
  75620. * Gets the current list of color gradients.
  75621. * You must use addColorGradient and removeColorGradient to udpate this list
  75622. * @returns the list of color gradients
  75623. */
  75624. getColorGradients(): Nullable<Array<ColorGradient>>;
  75625. /**
  75626. * Gets the current list of size gradients.
  75627. * You must use addSizeGradient and removeSizeGradient to udpate this list
  75628. * @returns the list of size gradients
  75629. */
  75630. getSizeGradients(): Nullable<Array<FactorGradient>>;
  75631. /**
  75632. * Gets the current list of angular speed gradients.
  75633. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  75634. * @returns the list of angular speed gradients
  75635. */
  75636. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  75637. /**
  75638. * Adds a new angular speed gradient
  75639. * @param gradient defines the gradient to use (between 0 and 1)
  75640. * @param factor defines the angular speed to affect to the specified gradient
  75641. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75642. * @returns the current particle system
  75643. */
  75644. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75645. /**
  75646. * Remove a specific angular speed gradient
  75647. * @param gradient defines the gradient to remove
  75648. * @returns the current particle system
  75649. */
  75650. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  75651. /**
  75652. * Gets the current list of velocity gradients.
  75653. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  75654. * @returns the list of velocity gradients
  75655. */
  75656. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  75657. /**
  75658. * Adds a new velocity gradient
  75659. * @param gradient defines the gradient to use (between 0 and 1)
  75660. * @param factor defines the velocity to affect to the specified gradient
  75661. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75662. * @returns the current particle system
  75663. */
  75664. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75665. /**
  75666. * Remove a specific velocity gradient
  75667. * @param gradient defines the gradient to remove
  75668. * @returns the current particle system
  75669. */
  75670. removeVelocityGradient(gradient: number): IParticleSystem;
  75671. /**
  75672. * Gets the current list of limit velocity gradients.
  75673. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  75674. * @returns the list of limit velocity gradients
  75675. */
  75676. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  75677. /**
  75678. * Adds a new limit velocity gradient
  75679. * @param gradient defines the gradient to use (between 0 and 1)
  75680. * @param factor defines the limit velocity to affect to the specified gradient
  75681. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75682. * @returns the current particle system
  75683. */
  75684. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75685. /**
  75686. * Remove a specific limit velocity gradient
  75687. * @param gradient defines the gradient to remove
  75688. * @returns the current particle system
  75689. */
  75690. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  75691. /**
  75692. * Adds a new drag gradient
  75693. * @param gradient defines the gradient to use (between 0 and 1)
  75694. * @param factor defines the drag to affect to the specified gradient
  75695. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75696. * @returns the current particle system
  75697. */
  75698. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75699. /**
  75700. * Remove a specific drag gradient
  75701. * @param gradient defines the gradient to remove
  75702. * @returns the current particle system
  75703. */
  75704. removeDragGradient(gradient: number): IParticleSystem;
  75705. /**
  75706. * Gets the current list of drag gradients.
  75707. * You must use addDragGradient and removeDragGradient to udpate this list
  75708. * @returns the list of drag gradients
  75709. */
  75710. getDragGradients(): Nullable<Array<FactorGradient>>;
  75711. /**
  75712. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  75713. * @param gradient defines the gradient to use (between 0 and 1)
  75714. * @param factor defines the emit rate to affect to the specified gradient
  75715. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75716. * @returns the current particle system
  75717. */
  75718. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75719. /**
  75720. * Remove a specific emit rate gradient
  75721. * @param gradient defines the gradient to remove
  75722. * @returns the current particle system
  75723. */
  75724. removeEmitRateGradient(gradient: number): IParticleSystem;
  75725. /**
  75726. * Gets the current list of emit rate gradients.
  75727. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  75728. * @returns the list of emit rate gradients
  75729. */
  75730. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  75731. /**
  75732. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  75733. * @param gradient defines the gradient to use (between 0 and 1)
  75734. * @param factor defines the start size to affect to the specified gradient
  75735. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75736. * @returns the current particle system
  75737. */
  75738. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75739. /**
  75740. * Remove a specific start size gradient
  75741. * @param gradient defines the gradient to remove
  75742. * @returns the current particle system
  75743. */
  75744. removeStartSizeGradient(gradient: number): IParticleSystem;
  75745. /**
  75746. * Gets the current list of start size gradients.
  75747. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  75748. * @returns the list of start size gradients
  75749. */
  75750. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  75751. /**
  75752. * Adds a new life time gradient
  75753. * @param gradient defines the gradient to use (between 0 and 1)
  75754. * @param factor defines the life time factor to affect to the specified gradient
  75755. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75756. * @returns the current particle system
  75757. */
  75758. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75759. /**
  75760. * Remove a specific life time gradient
  75761. * @param gradient defines the gradient to remove
  75762. * @returns the current particle system
  75763. */
  75764. removeLifeTimeGradient(gradient: number): IParticleSystem;
  75765. /**
  75766. * Gets the current list of life time gradients.
  75767. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  75768. * @returns the list of life time gradients
  75769. */
  75770. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  75771. /**
  75772. * Gets the current list of color gradients.
  75773. * You must use addColorGradient and removeColorGradient to udpate this list
  75774. * @returns the list of color gradients
  75775. */
  75776. getColorGradients(): Nullable<Array<ColorGradient>>;
  75777. /**
  75778. * Adds a new ramp gradient used to remap particle colors
  75779. * @param gradient defines the gradient to use (between 0 and 1)
  75780. * @param color defines the color to affect to the specified gradient
  75781. * @returns the current particle system
  75782. */
  75783. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  75784. /**
  75785. * Gets the current list of ramp gradients.
  75786. * You must use addRampGradient and removeRampGradient to udpate this list
  75787. * @returns the list of ramp gradients
  75788. */
  75789. getRampGradients(): Nullable<Array<Color3Gradient>>;
  75790. /** Gets or sets a boolean indicating that ramp gradients must be used
  75791. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  75792. */
  75793. useRampGradients: boolean;
  75794. /**
  75795. * Adds a new color remap gradient
  75796. * @param gradient defines the gradient to use (between 0 and 1)
  75797. * @param min defines the color remap minimal range
  75798. * @param max defines the color remap maximal range
  75799. * @returns the current particle system
  75800. */
  75801. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75802. /**
  75803. * Gets the current list of color remap gradients.
  75804. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  75805. * @returns the list of color remap gradients
  75806. */
  75807. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  75808. /**
  75809. * Adds a new alpha remap gradient
  75810. * @param gradient defines the gradient to use (between 0 and 1)
  75811. * @param min defines the alpha remap minimal range
  75812. * @param max defines the alpha remap maximal range
  75813. * @returns the current particle system
  75814. */
  75815. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75816. /**
  75817. * Gets the current list of alpha remap gradients.
  75818. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  75819. * @returns the list of alpha remap gradients
  75820. */
  75821. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  75822. /**
  75823. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  75824. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  75825. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  75826. * @returns the emitter
  75827. */
  75828. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  75829. /**
  75830. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  75831. * @param radius The radius of the hemisphere to emit from
  75832. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  75833. * @returns the emitter
  75834. */
  75835. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  75836. /**
  75837. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  75838. * @param radius The radius of the sphere to emit from
  75839. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  75840. * @returns the emitter
  75841. */
  75842. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  75843. /**
  75844. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  75845. * @param radius The radius of the sphere to emit from
  75846. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  75847. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  75848. * @returns the emitter
  75849. */
  75850. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  75851. /**
  75852. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  75853. * @param radius The radius of the emission cylinder
  75854. * @param height The height of the emission cylinder
  75855. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  75856. * @param directionRandomizer How much to randomize the particle direction [0-1]
  75857. * @returns the emitter
  75858. */
  75859. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  75860. /**
  75861. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  75862. * @param radius The radius of the cylinder to emit from
  75863. * @param height The height of the emission cylinder
  75864. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75865. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  75866. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  75867. * @returns the emitter
  75868. */
  75869. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  75870. /**
  75871. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  75872. * @param radius The radius of the cone to emit from
  75873. * @param angle The base angle of the cone
  75874. * @returns the emitter
  75875. */
  75876. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  75877. /**
  75878. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  75879. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  75880. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  75881. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  75882. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  75883. * @returns the emitter
  75884. */
  75885. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  75886. /**
  75887. * Get hosting scene
  75888. * @returns the scene
  75889. */
  75890. getScene(): Scene;
  75891. }
  75892. }
  75893. declare module BABYLON {
  75894. /**
  75895. * Creates an instance based on a source mesh.
  75896. */
  75897. export class InstancedMesh extends AbstractMesh {
  75898. private _sourceMesh;
  75899. private _currentLOD;
  75900. /** @hidden */
  75901. _indexInSourceMeshInstanceArray: number;
  75902. constructor(name: string, source: Mesh);
  75903. /**
  75904. * Returns the string "InstancedMesh".
  75905. */
  75906. getClassName(): string;
  75907. /**
  75908. * If the source mesh receives shadows
  75909. */
  75910. readonly receiveShadows: boolean;
  75911. /**
  75912. * The material of the source mesh
  75913. */
  75914. readonly material: Nullable<Material>;
  75915. /**
  75916. * Visibility of the source mesh
  75917. */
  75918. readonly visibility: number;
  75919. /**
  75920. * Skeleton of the source mesh
  75921. */
  75922. readonly skeleton: Nullable<Skeleton>;
  75923. /**
  75924. * Rendering ground id of the source mesh
  75925. */
  75926. renderingGroupId: number;
  75927. /**
  75928. * Returns the total number of vertices (integer).
  75929. */
  75930. getTotalVertices(): number;
  75931. /**
  75932. * Returns a positive integer : the total number of indices in this mesh geometry.
  75933. * @returns the numner of indices or zero if the mesh has no geometry.
  75934. */
  75935. getTotalIndices(): number;
  75936. /**
  75937. * The source mesh of the instance
  75938. */
  75939. readonly sourceMesh: Mesh;
  75940. /**
  75941. * Is this node ready to be used/rendered
  75942. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  75943. * @return {boolean} is it ready
  75944. */
  75945. isReady(completeCheck?: boolean): boolean;
  75946. /**
  75947. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  75948. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  75949. * @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.
  75950. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  75951. */
  75952. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  75953. /**
  75954. * Sets the vertex data of the mesh geometry for the requested `kind`.
  75955. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  75956. * The `data` are either a numeric array either a Float32Array.
  75957. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  75958. * 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).
  75959. * Note that a new underlying VertexBuffer object is created each call.
  75960. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  75961. *
  75962. * Possible `kind` values :
  75963. * - VertexBuffer.PositionKind
  75964. * - VertexBuffer.UVKind
  75965. * - VertexBuffer.UV2Kind
  75966. * - VertexBuffer.UV3Kind
  75967. * - VertexBuffer.UV4Kind
  75968. * - VertexBuffer.UV5Kind
  75969. * - VertexBuffer.UV6Kind
  75970. * - VertexBuffer.ColorKind
  75971. * - VertexBuffer.MatricesIndicesKind
  75972. * - VertexBuffer.MatricesIndicesExtraKind
  75973. * - VertexBuffer.MatricesWeightsKind
  75974. * - VertexBuffer.MatricesWeightsExtraKind
  75975. *
  75976. * Returns the Mesh.
  75977. */
  75978. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  75979. /**
  75980. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  75981. * If the mesh has no geometry, it is simply returned as it is.
  75982. * The `data` are either a numeric array either a Float32Array.
  75983. * No new underlying VertexBuffer object is created.
  75984. * 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.
  75985. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  75986. *
  75987. * Possible `kind` values :
  75988. * - VertexBuffer.PositionKind
  75989. * - VertexBuffer.UVKind
  75990. * - VertexBuffer.UV2Kind
  75991. * - VertexBuffer.UV3Kind
  75992. * - VertexBuffer.UV4Kind
  75993. * - VertexBuffer.UV5Kind
  75994. * - VertexBuffer.UV6Kind
  75995. * - VertexBuffer.ColorKind
  75996. * - VertexBuffer.MatricesIndicesKind
  75997. * - VertexBuffer.MatricesIndicesExtraKind
  75998. * - VertexBuffer.MatricesWeightsKind
  75999. * - VertexBuffer.MatricesWeightsExtraKind
  76000. *
  76001. * Returns the Mesh.
  76002. */
  76003. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  76004. /**
  76005. * Sets the mesh indices.
  76006. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  76007. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  76008. * This method creates a new index buffer each call.
  76009. * Returns the Mesh.
  76010. */
  76011. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  76012. /**
  76013. * Boolean : True if the mesh owns the requested kind of data.
  76014. */
  76015. isVerticesDataPresent(kind: string): boolean;
  76016. /**
  76017. * Returns an array of indices (IndicesArray).
  76018. */
  76019. getIndices(): Nullable<IndicesArray>;
  76020. readonly _positions: Nullable<Vector3[]>;
  76021. /**
  76022. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  76023. * This means the mesh underlying bounding box and sphere are recomputed.
  76024. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  76025. * @returns the current mesh
  76026. */
  76027. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  76028. /** @hidden */
  76029. _preActivate(): InstancedMesh;
  76030. /** @hidden */
  76031. _activate(renderId: number): boolean;
  76032. /**
  76033. * Returns the current associated LOD AbstractMesh.
  76034. */
  76035. getLOD(camera: Camera): AbstractMesh;
  76036. /** @hidden */
  76037. _syncSubMeshes(): InstancedMesh;
  76038. /** @hidden */
  76039. _generatePointsArray(): boolean;
  76040. /**
  76041. * Creates a new InstancedMesh from the current mesh.
  76042. * - name (string) : the cloned mesh name
  76043. * - newParent (optional Node) : the optional Node to parent the clone to.
  76044. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  76045. *
  76046. * Returns the clone.
  76047. */
  76048. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  76049. /**
  76050. * Disposes the InstancedMesh.
  76051. * Returns nothing.
  76052. */
  76053. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  76054. }
  76055. }
  76056. declare module BABYLON {
  76057. /**
  76058. * Defines the options associated with the creation of a shader material.
  76059. */
  76060. export interface IShaderMaterialOptions {
  76061. /**
  76062. * Does the material work in alpha blend mode
  76063. */
  76064. needAlphaBlending: boolean;
  76065. /**
  76066. * Does the material work in alpha test mode
  76067. */
  76068. needAlphaTesting: boolean;
  76069. /**
  76070. * The list of attribute names used in the shader
  76071. */
  76072. attributes: string[];
  76073. /**
  76074. * The list of unifrom names used in the shader
  76075. */
  76076. uniforms: string[];
  76077. /**
  76078. * The list of UBO names used in the shader
  76079. */
  76080. uniformBuffers: string[];
  76081. /**
  76082. * The list of sampler names used in the shader
  76083. */
  76084. samplers: string[];
  76085. /**
  76086. * The list of defines used in the shader
  76087. */
  76088. defines: string[];
  76089. }
  76090. /**
  76091. * 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.
  76092. *
  76093. * This returned material effects how the mesh will look based on the code in the shaders.
  76094. *
  76095. * @see http://doc.babylonjs.com/how_to/shader_material
  76096. */
  76097. export class ShaderMaterial extends Material {
  76098. private _shaderPath;
  76099. private _options;
  76100. private _textures;
  76101. private _textureArrays;
  76102. private _floats;
  76103. private _ints;
  76104. private _floatsArrays;
  76105. private _colors3;
  76106. private _colors3Arrays;
  76107. private _colors4;
  76108. private _vectors2;
  76109. private _vectors3;
  76110. private _vectors4;
  76111. private _matrices;
  76112. private _matrices3x3;
  76113. private _matrices2x2;
  76114. private _vectors2Arrays;
  76115. private _vectors3Arrays;
  76116. private _cachedWorldViewMatrix;
  76117. private _renderId;
  76118. /**
  76119. * Instantiate a new shader material.
  76120. * 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.
  76121. * This returned material effects how the mesh will look based on the code in the shaders.
  76122. * @see http://doc.babylonjs.com/how_to/shader_material
  76123. * @param name Define the name of the material in the scene
  76124. * @param scene Define the scene the material belongs to
  76125. * @param shaderPath Defines the route to the shader code in one of three ways:
  76126. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  76127. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  76128. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  76129. * @param options Define the options used to create the shader
  76130. */
  76131. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  76132. /**
  76133. * Gets the options used to compile the shader.
  76134. * They can be modified to trigger a new compilation
  76135. */
  76136. readonly options: IShaderMaterialOptions;
  76137. /**
  76138. * Gets the current class name of the material e.g. "ShaderMaterial"
  76139. * Mainly use in serialization.
  76140. * @returns the class name
  76141. */
  76142. getClassName(): string;
  76143. /**
  76144. * Specifies if the material will require alpha blending
  76145. * @returns a boolean specifying if alpha blending is needed
  76146. */
  76147. needAlphaBlending(): boolean;
  76148. /**
  76149. * Specifies if this material should be rendered in alpha test mode
  76150. * @returns a boolean specifying if an alpha test is needed.
  76151. */
  76152. needAlphaTesting(): boolean;
  76153. private _checkUniform;
  76154. /**
  76155. * Set a texture in the shader.
  76156. * @param name Define the name of the uniform samplers as defined in the shader
  76157. * @param texture Define the texture to bind to this sampler
  76158. * @return the material itself allowing "fluent" like uniform updates
  76159. */
  76160. setTexture(name: string, texture: Texture): ShaderMaterial;
  76161. /**
  76162. * Set a texture array in the shader.
  76163. * @param name Define the name of the uniform sampler array as defined in the shader
  76164. * @param textures Define the list of textures to bind to this sampler
  76165. * @return the material itself allowing "fluent" like uniform updates
  76166. */
  76167. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  76168. /**
  76169. * Set a float in the shader.
  76170. * @param name Define the name of the uniform as defined in the shader
  76171. * @param value Define the value to give to the uniform
  76172. * @return the material itself allowing "fluent" like uniform updates
  76173. */
  76174. setFloat(name: string, value: number): ShaderMaterial;
  76175. /**
  76176. * Set a int in the shader.
  76177. * @param name Define the name of the uniform as defined in the shader
  76178. * @param value Define the value to give to the uniform
  76179. * @return the material itself allowing "fluent" like uniform updates
  76180. */
  76181. setInt(name: string, value: number): ShaderMaterial;
  76182. /**
  76183. * Set an array of floats in the shader.
  76184. * @param name Define the name of the uniform as defined in the shader
  76185. * @param value Define the value to give to the uniform
  76186. * @return the material itself allowing "fluent" like uniform updates
  76187. */
  76188. setFloats(name: string, value: number[]): ShaderMaterial;
  76189. /**
  76190. * Set a vec3 in the shader from a Color3.
  76191. * @param name Define the name of the uniform as defined in the shader
  76192. * @param value Define the value to give to the uniform
  76193. * @return the material itself allowing "fluent" like uniform updates
  76194. */
  76195. setColor3(name: string, value: Color3): ShaderMaterial;
  76196. /**
  76197. * Set a vec3 array in the shader from a Color3 array.
  76198. * @param name Define the name of the uniform as defined in the shader
  76199. * @param value Define the value to give to the uniform
  76200. * @return the material itself allowing "fluent" like uniform updates
  76201. */
  76202. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  76203. /**
  76204. * Set a vec4 in the shader from a Color4.
  76205. * @param name Define the name of the uniform as defined in the shader
  76206. * @param value Define the value to give to the uniform
  76207. * @return the material itself allowing "fluent" like uniform updates
  76208. */
  76209. setColor4(name: string, value: Color4): ShaderMaterial;
  76210. /**
  76211. * Set a vec2 in the shader from a Vector2.
  76212. * @param name Define the name of the uniform as defined in the shader
  76213. * @param value Define the value to give to the uniform
  76214. * @return the material itself allowing "fluent" like uniform updates
  76215. */
  76216. setVector2(name: string, value: Vector2): ShaderMaterial;
  76217. /**
  76218. * Set a vec3 in the shader from a Vector3.
  76219. * @param name Define the name of the uniform as defined in the shader
  76220. * @param value Define the value to give to the uniform
  76221. * @return the material itself allowing "fluent" like uniform updates
  76222. */
  76223. setVector3(name: string, value: Vector3): ShaderMaterial;
  76224. /**
  76225. * Set a vec4 in the shader from a Vector4.
  76226. * @param name Define the name of the uniform as defined in the shader
  76227. * @param value Define the value to give to the uniform
  76228. * @return the material itself allowing "fluent" like uniform updates
  76229. */
  76230. setVector4(name: string, value: Vector4): ShaderMaterial;
  76231. /**
  76232. * Set a mat4 in the shader from a Matrix.
  76233. * @param name Define the name of the uniform as defined in the shader
  76234. * @param value Define the value to give to the uniform
  76235. * @return the material itself allowing "fluent" like uniform updates
  76236. */
  76237. setMatrix(name: string, value: Matrix): ShaderMaterial;
  76238. /**
  76239. * Set a mat3 in the shader from a Float32Array.
  76240. * @param name Define the name of the uniform as defined in the shader
  76241. * @param value Define the value to give to the uniform
  76242. * @return the material itself allowing "fluent" like uniform updates
  76243. */
  76244. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  76245. /**
  76246. * Set a mat2 in the shader from a Float32Array.
  76247. * @param name Define the name of the uniform as defined in the shader
  76248. * @param value Define the value to give to the uniform
  76249. * @return the material itself allowing "fluent" like uniform updates
  76250. */
  76251. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  76252. /**
  76253. * Set a vec2 array in the shader from a number array.
  76254. * @param name Define the name of the uniform as defined in the shader
  76255. * @param value Define the value to give to the uniform
  76256. * @return the material itself allowing "fluent" like uniform updates
  76257. */
  76258. setArray2(name: string, value: number[]): ShaderMaterial;
  76259. /**
  76260. * Set a vec3 array in the shader from a number array.
  76261. * @param name Define the name of the uniform as defined in the shader
  76262. * @param value Define the value to give to the uniform
  76263. * @return the material itself allowing "fluent" like uniform updates
  76264. */
  76265. setArray3(name: string, value: number[]): ShaderMaterial;
  76266. private _checkCache;
  76267. /**
  76268. * Specifies that the submesh is ready to be used
  76269. * @param mesh defines the mesh to check
  76270. * @param subMesh defines which submesh to check
  76271. * @param useInstances specifies that instances should be used
  76272. * @returns a boolean indicating that the submesh is ready or not
  76273. */
  76274. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  76275. /**
  76276. * Checks if the material is ready to render the requested mesh
  76277. * @param mesh Define the mesh to render
  76278. * @param useInstances Define whether or not the material is used with instances
  76279. * @returns true if ready, otherwise false
  76280. */
  76281. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  76282. /**
  76283. * Binds the world matrix to the material
  76284. * @param world defines the world transformation matrix
  76285. */
  76286. bindOnlyWorldMatrix(world: Matrix): void;
  76287. /**
  76288. * Binds the material to the mesh
  76289. * @param world defines the world transformation matrix
  76290. * @param mesh defines the mesh to bind the material to
  76291. */
  76292. bind(world: Matrix, mesh?: Mesh): void;
  76293. /**
  76294. * Gets the active textures from the material
  76295. * @returns an array of textures
  76296. */
  76297. getActiveTextures(): BaseTexture[];
  76298. /**
  76299. * Specifies if the material uses a texture
  76300. * @param texture defines the texture to check against the material
  76301. * @returns a boolean specifying if the material uses the texture
  76302. */
  76303. hasTexture(texture: BaseTexture): boolean;
  76304. /**
  76305. * Makes a duplicate of the material, and gives it a new name
  76306. * @param name defines the new name for the duplicated material
  76307. * @returns the cloned material
  76308. */
  76309. clone(name: string): ShaderMaterial;
  76310. /**
  76311. * Disposes the material
  76312. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  76313. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  76314. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  76315. */
  76316. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  76317. /**
  76318. * Serializes this material in a JSON representation
  76319. * @returns the serialized material object
  76320. */
  76321. serialize(): any;
  76322. /**
  76323. * Creates a shader material from parsed shader material data
  76324. * @param source defines the JSON represnetation of the material
  76325. * @param scene defines the hosting scene
  76326. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  76327. * @returns a new material
  76328. */
  76329. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  76330. }
  76331. }
  76332. declare module BABYLON {
  76333. /** @hidden */
  76334. export var colorPixelShader: {
  76335. name: string;
  76336. shader: string;
  76337. };
  76338. }
  76339. declare module BABYLON {
  76340. /** @hidden */
  76341. export var colorVertexShader: {
  76342. name: string;
  76343. shader: string;
  76344. };
  76345. }
  76346. declare module BABYLON {
  76347. /**
  76348. * Line mesh
  76349. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  76350. */
  76351. export class LinesMesh extends Mesh {
  76352. /**
  76353. * If vertex color should be applied to the mesh
  76354. */
  76355. useVertexColor?: boolean | undefined;
  76356. /**
  76357. * If vertex alpha should be applied to the mesh
  76358. */
  76359. useVertexAlpha?: boolean | undefined;
  76360. /**
  76361. * Color of the line (Default: White)
  76362. */
  76363. color: Color3;
  76364. /**
  76365. * Alpha of the line (Default: 1)
  76366. */
  76367. alpha: number;
  76368. /**
  76369. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  76370. * This margin is expressed in world space coordinates, so its value may vary.
  76371. * Default value is 0.1
  76372. */
  76373. intersectionThreshold: number;
  76374. private _colorShader;
  76375. /**
  76376. * Creates a new LinesMesh
  76377. * @param name defines the name
  76378. * @param scene defines the hosting scene
  76379. * @param parent defines the parent mesh if any
  76380. * @param source defines the optional source LinesMesh used to clone data from
  76381. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  76382. * When false, achieved by calling a clone(), also passing False.
  76383. * This will make creation of children, recursive.
  76384. * @param useVertexColor defines if this LinesMesh supports vertex color
  76385. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  76386. */
  76387. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  76388. /**
  76389. * If vertex color should be applied to the mesh
  76390. */
  76391. useVertexColor?: boolean | undefined,
  76392. /**
  76393. * If vertex alpha should be applied to the mesh
  76394. */
  76395. useVertexAlpha?: boolean | undefined);
  76396. private _addClipPlaneDefine;
  76397. private _removeClipPlaneDefine;
  76398. isReady(): boolean;
  76399. /**
  76400. * Returns the string "LineMesh"
  76401. */
  76402. getClassName(): string;
  76403. /**
  76404. * @hidden
  76405. */
  76406. /**
  76407. * @hidden
  76408. */
  76409. material: Material;
  76410. /**
  76411. * @hidden
  76412. */
  76413. readonly checkCollisions: boolean;
  76414. /** @hidden */
  76415. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  76416. /** @hidden */
  76417. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  76418. /**
  76419. * Disposes of the line mesh
  76420. * @param doNotRecurse If children should be disposed
  76421. */
  76422. dispose(doNotRecurse?: boolean): void;
  76423. /**
  76424. * Returns a new LineMesh object cloned from the current one.
  76425. */
  76426. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  76427. /**
  76428. * Creates a new InstancedLinesMesh object from the mesh model.
  76429. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  76430. * @param name defines the name of the new instance
  76431. * @returns a new InstancedLinesMesh
  76432. */
  76433. createInstance(name: string): InstancedLinesMesh;
  76434. }
  76435. /**
  76436. * Creates an instance based on a source LinesMesh
  76437. */
  76438. export class InstancedLinesMesh extends InstancedMesh {
  76439. /**
  76440. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  76441. * This margin is expressed in world space coordinates, so its value may vary.
  76442. * Initilized with the intersectionThreshold value of the source LinesMesh
  76443. */
  76444. intersectionThreshold: number;
  76445. constructor(name: string, source: LinesMesh);
  76446. /**
  76447. * Returns the string "InstancedLinesMesh".
  76448. */
  76449. getClassName(): string;
  76450. }
  76451. }
  76452. declare module BABYLON {
  76453. /** @hidden */
  76454. export var linePixelShader: {
  76455. name: string;
  76456. shader: string;
  76457. };
  76458. }
  76459. declare module BABYLON {
  76460. /** @hidden */
  76461. export var lineVertexShader: {
  76462. name: string;
  76463. shader: string;
  76464. };
  76465. }
  76466. declare module BABYLON {
  76467. interface AbstractMesh {
  76468. /**
  76469. * Disables the mesh edge rendering mode
  76470. * @returns the currentAbstractMesh
  76471. */
  76472. disableEdgesRendering(): AbstractMesh;
  76473. /**
  76474. * Enables the edge rendering mode on the mesh.
  76475. * This mode makes the mesh edges visible
  76476. * @param epsilon defines the maximal distance between two angles to detect a face
  76477. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  76478. * @returns the currentAbstractMesh
  76479. * @see https://www.babylonjs-playground.com/#19O9TU#0
  76480. */
  76481. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  76482. /**
  76483. * Gets the edgesRenderer associated with the mesh
  76484. */
  76485. edgesRenderer: Nullable<EdgesRenderer>;
  76486. }
  76487. interface LinesMesh {
  76488. /**
  76489. * Enables the edge rendering mode on the mesh.
  76490. * This mode makes the mesh edges visible
  76491. * @param epsilon defines the maximal distance between two angles to detect a face
  76492. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  76493. * @returns the currentAbstractMesh
  76494. * @see https://www.babylonjs-playground.com/#19O9TU#0
  76495. */
  76496. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  76497. }
  76498. interface InstancedLinesMesh {
  76499. /**
  76500. * Enables the edge rendering mode on the mesh.
  76501. * This mode makes the mesh edges visible
  76502. * @param epsilon defines the maximal distance between two angles to detect a face
  76503. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  76504. * @returns the current InstancedLinesMesh
  76505. * @see https://www.babylonjs-playground.com/#19O9TU#0
  76506. */
  76507. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  76508. }
  76509. /**
  76510. * Defines the minimum contract an Edges renderer should follow.
  76511. */
  76512. export interface IEdgesRenderer extends IDisposable {
  76513. /**
  76514. * Gets or sets a boolean indicating if the edgesRenderer is active
  76515. */
  76516. isEnabled: boolean;
  76517. /**
  76518. * Renders the edges of the attached mesh,
  76519. */
  76520. render(): void;
  76521. /**
  76522. * Checks wether or not the edges renderer is ready to render.
  76523. * @return true if ready, otherwise false.
  76524. */
  76525. isReady(): boolean;
  76526. }
  76527. /**
  76528. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  76529. */
  76530. export class EdgesRenderer implements IEdgesRenderer {
  76531. /**
  76532. * Define the size of the edges with an orthographic camera
  76533. */
  76534. edgesWidthScalerForOrthographic: number;
  76535. /**
  76536. * Define the size of the edges with a perspective camera
  76537. */
  76538. edgesWidthScalerForPerspective: number;
  76539. protected _source: AbstractMesh;
  76540. protected _linesPositions: number[];
  76541. protected _linesNormals: number[];
  76542. protected _linesIndices: number[];
  76543. protected _epsilon: number;
  76544. protected _indicesCount: number;
  76545. protected _lineShader: ShaderMaterial;
  76546. protected _ib: WebGLBuffer;
  76547. protected _buffers: {
  76548. [key: string]: Nullable<VertexBuffer>;
  76549. };
  76550. protected _checkVerticesInsteadOfIndices: boolean;
  76551. private _meshRebuildObserver;
  76552. private _meshDisposeObserver;
  76553. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  76554. isEnabled: boolean;
  76555. /**
  76556. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  76557. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  76558. * @param source Mesh used to create edges
  76559. * @param epsilon sum of angles in adjacency to check for edge
  76560. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  76561. * @param generateEdgesLines - should generate Lines or only prepare resources.
  76562. */
  76563. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  76564. protected _prepareRessources(): void;
  76565. /** @hidden */
  76566. _rebuild(): void;
  76567. /**
  76568. * Releases the required resources for the edges renderer
  76569. */
  76570. dispose(): void;
  76571. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  76572. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  76573. /**
  76574. * Checks if the pair of p0 and p1 is en edge
  76575. * @param faceIndex
  76576. * @param edge
  76577. * @param faceNormals
  76578. * @param p0
  76579. * @param p1
  76580. * @private
  76581. */
  76582. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  76583. /**
  76584. * push line into the position, normal and index buffer
  76585. * @protected
  76586. */
  76587. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  76588. /**
  76589. * Generates lines edges from adjacencjes
  76590. * @private
  76591. */
  76592. _generateEdgesLines(): void;
  76593. /**
  76594. * Checks wether or not the edges renderer is ready to render.
  76595. * @return true if ready, otherwise false.
  76596. */
  76597. isReady(): boolean;
  76598. /**
  76599. * Renders the edges of the attached mesh,
  76600. */
  76601. render(): void;
  76602. }
  76603. /**
  76604. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  76605. */
  76606. export class LineEdgesRenderer extends EdgesRenderer {
  76607. /**
  76608. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  76609. * @param source LineMesh used to generate edges
  76610. * @param epsilon not important (specified angle for edge detection)
  76611. * @param checkVerticesInsteadOfIndices not important for LineMesh
  76612. */
  76613. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  76614. /**
  76615. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  76616. */
  76617. _generateEdgesLines(): void;
  76618. }
  76619. }
  76620. declare module BABYLON {
  76621. /**
  76622. * This represents the object necessary to create a rendering group.
  76623. * This is exclusively used and created by the rendering manager.
  76624. * To modify the behavior, you use the available helpers in your scene or meshes.
  76625. * @hidden
  76626. */
  76627. export class RenderingGroup {
  76628. index: number;
  76629. private _scene;
  76630. private _opaqueSubMeshes;
  76631. private _transparentSubMeshes;
  76632. private _alphaTestSubMeshes;
  76633. private _depthOnlySubMeshes;
  76634. private _particleSystems;
  76635. private _spriteManagers;
  76636. private _opaqueSortCompareFn;
  76637. private _alphaTestSortCompareFn;
  76638. private _transparentSortCompareFn;
  76639. private _renderOpaque;
  76640. private _renderAlphaTest;
  76641. private _renderTransparent;
  76642. /** @hidden */
  76643. _edgesRenderers: SmartArray<IEdgesRenderer>;
  76644. onBeforeTransparentRendering: () => void;
  76645. /**
  76646. * Set the opaque sort comparison function.
  76647. * If null the sub meshes will be render in the order they were created
  76648. */
  76649. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  76650. /**
  76651. * Set the alpha test sort comparison function.
  76652. * If null the sub meshes will be render in the order they were created
  76653. */
  76654. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  76655. /**
  76656. * Set the transparent sort comparison function.
  76657. * If null the sub meshes will be render in the order they were created
  76658. */
  76659. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  76660. /**
  76661. * Creates a new rendering group.
  76662. * @param index The rendering group index
  76663. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  76664. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  76665. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  76666. */
  76667. 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>);
  76668. /**
  76669. * Render all the sub meshes contained in the group.
  76670. * @param customRenderFunction Used to override the default render behaviour of the group.
  76671. * @returns true if rendered some submeshes.
  76672. */
  76673. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  76674. /**
  76675. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  76676. * @param subMeshes The submeshes to render
  76677. */
  76678. private renderOpaqueSorted;
  76679. /**
  76680. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  76681. * @param subMeshes The submeshes to render
  76682. */
  76683. private renderAlphaTestSorted;
  76684. /**
  76685. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  76686. * @param subMeshes The submeshes to render
  76687. */
  76688. private renderTransparentSorted;
  76689. /**
  76690. * Renders the submeshes in a specified order.
  76691. * @param subMeshes The submeshes to sort before render
  76692. * @param sortCompareFn The comparison function use to sort
  76693. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  76694. * @param transparent Specifies to activate blending if true
  76695. */
  76696. private static renderSorted;
  76697. /**
  76698. * Renders the submeshes in the order they were dispatched (no sort applied).
  76699. * @param subMeshes The submeshes to render
  76700. */
  76701. private static renderUnsorted;
  76702. /**
  76703. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  76704. * are rendered back to front if in the same alpha index.
  76705. *
  76706. * @param a The first submesh
  76707. * @param b The second submesh
  76708. * @returns The result of the comparison
  76709. */
  76710. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  76711. /**
  76712. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  76713. * are rendered back to front.
  76714. *
  76715. * @param a The first submesh
  76716. * @param b The second submesh
  76717. * @returns The result of the comparison
  76718. */
  76719. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  76720. /**
  76721. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  76722. * are rendered front to back (prevent overdraw).
  76723. *
  76724. * @param a The first submesh
  76725. * @param b The second submesh
  76726. * @returns The result of the comparison
  76727. */
  76728. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  76729. /**
  76730. * Resets the different lists of submeshes to prepare a new frame.
  76731. */
  76732. prepare(): void;
  76733. dispose(): void;
  76734. /**
  76735. * Inserts the submesh in its correct queue depending on its material.
  76736. * @param subMesh The submesh to dispatch
  76737. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  76738. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  76739. */
  76740. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  76741. dispatchSprites(spriteManager: ISpriteManager): void;
  76742. dispatchParticles(particleSystem: IParticleSystem): void;
  76743. private _renderParticles;
  76744. private _renderSprites;
  76745. }
  76746. }
  76747. declare module BABYLON {
  76748. /**
  76749. * Interface describing the different options available in the rendering manager
  76750. * regarding Auto Clear between groups.
  76751. */
  76752. export interface IRenderingManagerAutoClearSetup {
  76753. /**
  76754. * Defines whether or not autoclear is enable.
  76755. */
  76756. autoClear: boolean;
  76757. /**
  76758. * Defines whether or not to autoclear the depth buffer.
  76759. */
  76760. depth: boolean;
  76761. /**
  76762. * Defines whether or not to autoclear the stencil buffer.
  76763. */
  76764. stencil: boolean;
  76765. }
  76766. /**
  76767. * This class is used by the onRenderingGroupObservable
  76768. */
  76769. export class RenderingGroupInfo {
  76770. /**
  76771. * The Scene that being rendered
  76772. */
  76773. scene: Scene;
  76774. /**
  76775. * The camera currently used for the rendering pass
  76776. */
  76777. camera: Nullable<Camera>;
  76778. /**
  76779. * The ID of the renderingGroup being processed
  76780. */
  76781. renderingGroupId: number;
  76782. }
  76783. /**
  76784. * This is the manager responsible of all the rendering for meshes sprites and particles.
  76785. * It is enable to manage the different groups as well as the different necessary sort functions.
  76786. * This should not be used directly aside of the few static configurations
  76787. */
  76788. export class RenderingManager {
  76789. /**
  76790. * The max id used for rendering groups (not included)
  76791. */
  76792. static MAX_RENDERINGGROUPS: number;
  76793. /**
  76794. * The min id used for rendering groups (included)
  76795. */
  76796. static MIN_RENDERINGGROUPS: number;
  76797. /**
  76798. * Used to globally prevent autoclearing scenes.
  76799. */
  76800. static AUTOCLEAR: boolean;
  76801. /**
  76802. * @hidden
  76803. */
  76804. _useSceneAutoClearSetup: boolean;
  76805. private _scene;
  76806. private _renderingGroups;
  76807. private _depthStencilBufferAlreadyCleaned;
  76808. private _autoClearDepthStencil;
  76809. private _customOpaqueSortCompareFn;
  76810. private _customAlphaTestSortCompareFn;
  76811. private _customTransparentSortCompareFn;
  76812. private _renderingGroupInfo;
  76813. /**
  76814. * Instantiates a new rendering group for a particular scene
  76815. * @param scene Defines the scene the groups belongs to
  76816. */
  76817. constructor(scene: Scene);
  76818. private _clearDepthStencilBuffer;
  76819. /**
  76820. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  76821. * @hidden
  76822. */
  76823. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  76824. /**
  76825. * Resets the different information of the group to prepare a new frame
  76826. * @hidden
  76827. */
  76828. reset(): void;
  76829. /**
  76830. * Dispose and release the group and its associated resources.
  76831. * @hidden
  76832. */
  76833. dispose(): void;
  76834. /**
  76835. * Clear the info related to rendering groups preventing retention points during dispose.
  76836. */
  76837. freeRenderingGroups(): void;
  76838. private _prepareRenderingGroup;
  76839. /**
  76840. * Add a sprite manager to the rendering manager in order to render it this frame.
  76841. * @param spriteManager Define the sprite manager to render
  76842. */
  76843. dispatchSprites(spriteManager: ISpriteManager): void;
  76844. /**
  76845. * Add a particle system to the rendering manager in order to render it this frame.
  76846. * @param particleSystem Define the particle system to render
  76847. */
  76848. dispatchParticles(particleSystem: IParticleSystem): void;
  76849. /**
  76850. * Add a submesh to the manager in order to render it this frame
  76851. * @param subMesh The submesh to dispatch
  76852. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  76853. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  76854. */
  76855. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  76856. /**
  76857. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  76858. * This allowed control for front to back rendering or reversly depending of the special needs.
  76859. *
  76860. * @param renderingGroupId The rendering group id corresponding to its index
  76861. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  76862. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  76863. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  76864. */
  76865. 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;
  76866. /**
  76867. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  76868. *
  76869. * @param renderingGroupId The rendering group id corresponding to its index
  76870. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  76871. * @param depth Automatically clears depth between groups if true and autoClear is true.
  76872. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  76873. */
  76874. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  76875. /**
  76876. * Gets the current auto clear configuration for one rendering group of the rendering
  76877. * manager.
  76878. * @param index the rendering group index to get the information for
  76879. * @returns The auto clear setup for the requested rendering group
  76880. */
  76881. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  76882. }
  76883. }
  76884. declare module BABYLON {
  76885. /**
  76886. * This Helps creating a texture that will be created from a camera in your scene.
  76887. * It is basically a dynamic texture that could be used to create special effects for instance.
  76888. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  76889. */
  76890. export class RenderTargetTexture extends Texture {
  76891. isCube: boolean;
  76892. /**
  76893. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  76894. */
  76895. static readonly REFRESHRATE_RENDER_ONCE: number;
  76896. /**
  76897. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  76898. */
  76899. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  76900. /**
  76901. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  76902. * the central point of your effect and can save a lot of performances.
  76903. */
  76904. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  76905. /**
  76906. * Use this predicate to dynamically define the list of mesh you want to render.
  76907. * If set, the renderList property will be overwritten.
  76908. */
  76909. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  76910. private _renderList;
  76911. /**
  76912. * Use this list to define the list of mesh you want to render.
  76913. */
  76914. renderList: Nullable<Array<AbstractMesh>>;
  76915. private _hookArray;
  76916. /**
  76917. * Define if particles should be rendered in your texture.
  76918. */
  76919. renderParticles: boolean;
  76920. /**
  76921. * Define if sprites should be rendered in your texture.
  76922. */
  76923. renderSprites: boolean;
  76924. /**
  76925. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  76926. */
  76927. coordinatesMode: number;
  76928. /**
  76929. * Define the camera used to render the texture.
  76930. */
  76931. activeCamera: Nullable<Camera>;
  76932. /**
  76933. * Override the render function of the texture with your own one.
  76934. */
  76935. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  76936. /**
  76937. * Define if camera post processes should be use while rendering the texture.
  76938. */
  76939. useCameraPostProcesses: boolean;
  76940. /**
  76941. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  76942. */
  76943. ignoreCameraViewport: boolean;
  76944. private _postProcessManager;
  76945. private _postProcesses;
  76946. private _resizeObserver;
  76947. /**
  76948. * An event triggered when the texture is unbind.
  76949. */
  76950. onBeforeBindObservable: Observable<RenderTargetTexture>;
  76951. /**
  76952. * An event triggered when the texture is unbind.
  76953. */
  76954. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  76955. private _onAfterUnbindObserver;
  76956. /**
  76957. * Set a after unbind callback in the texture.
  76958. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  76959. */
  76960. onAfterUnbind: () => void;
  76961. /**
  76962. * An event triggered before rendering the texture
  76963. */
  76964. onBeforeRenderObservable: Observable<number>;
  76965. private _onBeforeRenderObserver;
  76966. /**
  76967. * Set a before render callback in the texture.
  76968. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  76969. */
  76970. onBeforeRender: (faceIndex: number) => void;
  76971. /**
  76972. * An event triggered after rendering the texture
  76973. */
  76974. onAfterRenderObservable: Observable<number>;
  76975. private _onAfterRenderObserver;
  76976. /**
  76977. * Set a after render callback in the texture.
  76978. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  76979. */
  76980. onAfterRender: (faceIndex: number) => void;
  76981. /**
  76982. * An event triggered after the texture clear
  76983. */
  76984. onClearObservable: Observable<Engine>;
  76985. private _onClearObserver;
  76986. /**
  76987. * Set a clear callback in the texture.
  76988. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  76989. */
  76990. onClear: (Engine: Engine) => void;
  76991. /**
  76992. * Define the clear color of the Render Target if it should be different from the scene.
  76993. */
  76994. clearColor: Color4;
  76995. protected _size: number | {
  76996. width: number;
  76997. height: number;
  76998. };
  76999. protected _initialSizeParameter: number | {
  77000. width: number;
  77001. height: number;
  77002. } | {
  77003. ratio: number;
  77004. };
  77005. protected _sizeRatio: Nullable<number>;
  77006. /** @hidden */
  77007. _generateMipMaps: boolean;
  77008. protected _renderingManager: RenderingManager;
  77009. /** @hidden */
  77010. _waitingRenderList: string[];
  77011. protected _doNotChangeAspectRatio: boolean;
  77012. protected _currentRefreshId: number;
  77013. protected _refreshRate: number;
  77014. protected _textureMatrix: Matrix;
  77015. protected _samples: number;
  77016. protected _renderTargetOptions: RenderTargetCreationOptions;
  77017. /**
  77018. * Gets render target creation options that were used.
  77019. */
  77020. readonly renderTargetOptions: RenderTargetCreationOptions;
  77021. protected _engine: Engine;
  77022. protected _onRatioRescale(): void;
  77023. /**
  77024. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  77025. * It must define where the camera used to render the texture is set
  77026. */
  77027. boundingBoxPosition: Vector3;
  77028. private _boundingBoxSize;
  77029. /**
  77030. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  77031. * When defined, the cubemap will switch to local mode
  77032. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  77033. * @example https://www.babylonjs-playground.com/#RNASML
  77034. */
  77035. boundingBoxSize: Vector3;
  77036. /**
  77037. * In case the RTT has been created with a depth texture, get the associated
  77038. * depth texture.
  77039. * Otherwise, return null.
  77040. */
  77041. depthStencilTexture: Nullable<InternalTexture>;
  77042. /**
  77043. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  77044. * or used a shadow, depth texture...
  77045. * @param name The friendly name of the texture
  77046. * @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)
  77047. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  77048. * @param generateMipMaps True if mip maps need to be generated after render.
  77049. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  77050. * @param type The type of the buffer in the RTT (int, half float, float...)
  77051. * @param isCube True if a cube texture needs to be created
  77052. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  77053. * @param generateDepthBuffer True to generate a depth buffer
  77054. * @param generateStencilBuffer True to generate a stencil buffer
  77055. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  77056. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  77057. * @param delayAllocation if the texture allocation should be delayed (default: false)
  77058. */
  77059. constructor(name: string, size: number | {
  77060. width: number;
  77061. height: number;
  77062. } | {
  77063. ratio: number;
  77064. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  77065. /**
  77066. * Creates a depth stencil texture.
  77067. * This is only available in WebGL 2 or with the depth texture extension available.
  77068. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  77069. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  77070. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  77071. */
  77072. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  77073. private _processSizeParameter;
  77074. /**
  77075. * Define the number of samples to use in case of MSAA.
  77076. * It defaults to one meaning no MSAA has been enabled.
  77077. */
  77078. samples: number;
  77079. /**
  77080. * Resets the refresh counter of the texture and start bak from scratch.
  77081. * Could be useful to regenerate the texture if it is setup to render only once.
  77082. */
  77083. resetRefreshCounter(): void;
  77084. /**
  77085. * Define the refresh rate of the texture or the rendering frequency.
  77086. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  77087. */
  77088. refreshRate: number;
  77089. /**
  77090. * Adds a post process to the render target rendering passes.
  77091. * @param postProcess define the post process to add
  77092. */
  77093. addPostProcess(postProcess: PostProcess): void;
  77094. /**
  77095. * Clear all the post processes attached to the render target
  77096. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  77097. */
  77098. clearPostProcesses(dispose?: boolean): void;
  77099. /**
  77100. * Remove one of the post process from the list of attached post processes to the texture
  77101. * @param postProcess define the post process to remove from the list
  77102. */
  77103. removePostProcess(postProcess: PostProcess): void;
  77104. /** @hidden */
  77105. _shouldRender(): boolean;
  77106. /**
  77107. * Gets the actual render size of the texture.
  77108. * @returns the width of the render size
  77109. */
  77110. getRenderSize(): number;
  77111. /**
  77112. * Gets the actual render width of the texture.
  77113. * @returns the width of the render size
  77114. */
  77115. getRenderWidth(): number;
  77116. /**
  77117. * Gets the actual render height of the texture.
  77118. * @returns the height of the render size
  77119. */
  77120. getRenderHeight(): number;
  77121. /**
  77122. * Get if the texture can be rescaled or not.
  77123. */
  77124. readonly canRescale: boolean;
  77125. /**
  77126. * Resize the texture using a ratio.
  77127. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  77128. */
  77129. scale(ratio: number): void;
  77130. /**
  77131. * Get the texture reflection matrix used to rotate/transform the reflection.
  77132. * @returns the reflection matrix
  77133. */
  77134. getReflectionTextureMatrix(): Matrix;
  77135. /**
  77136. * Resize the texture to a new desired size.
  77137. * Be carrefull as it will recreate all the data in the new texture.
  77138. * @param size Define the new size. It can be:
  77139. * - a number for squared texture,
  77140. * - an object containing { width: number, height: number }
  77141. * - or an object containing a ratio { ratio: number }
  77142. */
  77143. resize(size: number | {
  77144. width: number;
  77145. height: number;
  77146. } | {
  77147. ratio: number;
  77148. }): void;
  77149. /**
  77150. * Renders all the objects from the render list into the texture.
  77151. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  77152. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  77153. */
  77154. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  77155. private _bestReflectionRenderTargetDimension;
  77156. /**
  77157. * @hidden
  77158. * @param faceIndex face index to bind to if this is a cubetexture
  77159. */
  77160. _bindFrameBuffer(faceIndex?: number): void;
  77161. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  77162. private renderToTarget;
  77163. /**
  77164. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  77165. * This allowed control for front to back rendering or reversly depending of the special needs.
  77166. *
  77167. * @param renderingGroupId The rendering group id corresponding to its index
  77168. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  77169. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  77170. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  77171. */
  77172. 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;
  77173. /**
  77174. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  77175. *
  77176. * @param renderingGroupId The rendering group id corresponding to its index
  77177. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  77178. */
  77179. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  77180. /**
  77181. * Clones the texture.
  77182. * @returns the cloned texture
  77183. */
  77184. clone(): RenderTargetTexture;
  77185. /**
  77186. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  77187. * @returns The JSON representation of the texture
  77188. */
  77189. serialize(): any;
  77190. /**
  77191. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  77192. */
  77193. disposeFramebufferObjects(): void;
  77194. /**
  77195. * Dispose the texture and release its associated resources.
  77196. */
  77197. dispose(): void;
  77198. /** @hidden */
  77199. _rebuild(): void;
  77200. /**
  77201. * Clear the info related to rendering groups preventing retention point in material dispose.
  77202. */
  77203. freeRenderingGroups(): void;
  77204. /**
  77205. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  77206. * @returns the view count
  77207. */
  77208. getViewCount(): number;
  77209. }
  77210. }
  77211. declare module BABYLON {
  77212. /**
  77213. * Mirror texture can be used to simulate the view from a mirror in a scene.
  77214. * It will dynamically be rendered every frame to adapt to the camera point of view.
  77215. * You can then easily use it as a reflectionTexture on a flat surface.
  77216. * In case the surface is not a plane, please consider relying on reflection probes.
  77217. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  77218. */
  77219. export class MirrorTexture extends RenderTargetTexture {
  77220. private scene;
  77221. /**
  77222. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  77223. * 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.
  77224. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  77225. */
  77226. mirrorPlane: Plane;
  77227. /**
  77228. * Define the blur ratio used to blur the reflection if needed.
  77229. */
  77230. blurRatio: number;
  77231. /**
  77232. * Define the adaptive blur kernel used to blur the reflection if needed.
  77233. * This will autocompute the closest best match for the `blurKernel`
  77234. */
  77235. adaptiveBlurKernel: number;
  77236. /**
  77237. * Define the blur kernel used to blur the reflection if needed.
  77238. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  77239. */
  77240. blurKernel: number;
  77241. /**
  77242. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  77243. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  77244. */
  77245. blurKernelX: number;
  77246. /**
  77247. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  77248. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  77249. */
  77250. blurKernelY: number;
  77251. private _autoComputeBlurKernel;
  77252. protected _onRatioRescale(): void;
  77253. private _updateGammaSpace;
  77254. private _imageProcessingConfigChangeObserver;
  77255. private _transformMatrix;
  77256. private _mirrorMatrix;
  77257. private _savedViewMatrix;
  77258. private _blurX;
  77259. private _blurY;
  77260. private _adaptiveBlurKernel;
  77261. private _blurKernelX;
  77262. private _blurKernelY;
  77263. private _blurRatio;
  77264. /**
  77265. * Instantiates a Mirror Texture.
  77266. * Mirror texture can be used to simulate the view from a mirror in a scene.
  77267. * It will dynamically be rendered every frame to adapt to the camera point of view.
  77268. * You can then easily use it as a reflectionTexture on a flat surface.
  77269. * In case the surface is not a plane, please consider relying on reflection probes.
  77270. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  77271. * @param name
  77272. * @param size
  77273. * @param scene
  77274. * @param generateMipMaps
  77275. * @param type
  77276. * @param samplingMode
  77277. * @param generateDepthBuffer
  77278. */
  77279. constructor(name: string, size: number | {
  77280. width: number;
  77281. height: number;
  77282. } | {
  77283. ratio: number;
  77284. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  77285. private _preparePostProcesses;
  77286. /**
  77287. * Clone the mirror texture.
  77288. * @returns the cloned texture
  77289. */
  77290. clone(): MirrorTexture;
  77291. /**
  77292. * Serialize the texture to a JSON representation you could use in Parse later on
  77293. * @returns the serialized JSON representation
  77294. */
  77295. serialize(): any;
  77296. /**
  77297. * Dispose the texture and release its associated resources.
  77298. */
  77299. dispose(): void;
  77300. }
  77301. }
  77302. declare module BABYLON {
  77303. /**
  77304. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  77305. * @see http://doc.babylonjs.com/babylon101/materials#texture
  77306. */
  77307. export class Texture extends BaseTexture {
  77308. /** @hidden */
  77309. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  77310. /** @hidden */
  77311. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  77312. /** @hidden */
  77313. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  77314. /** nearest is mag = nearest and min = nearest and mip = linear */
  77315. static readonly NEAREST_SAMPLINGMODE: number;
  77316. /** nearest is mag = nearest and min = nearest and mip = linear */
  77317. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  77318. /** Bilinear is mag = linear and min = linear and mip = nearest */
  77319. static readonly BILINEAR_SAMPLINGMODE: number;
  77320. /** Bilinear is mag = linear and min = linear and mip = nearest */
  77321. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  77322. /** Trilinear is mag = linear and min = linear and mip = linear */
  77323. static readonly TRILINEAR_SAMPLINGMODE: number;
  77324. /** Trilinear is mag = linear and min = linear and mip = linear */
  77325. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  77326. /** mag = nearest and min = nearest and mip = nearest */
  77327. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  77328. /** mag = nearest and min = linear and mip = nearest */
  77329. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  77330. /** mag = nearest and min = linear and mip = linear */
  77331. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  77332. /** mag = nearest and min = linear and mip = none */
  77333. static readonly NEAREST_LINEAR: number;
  77334. /** mag = nearest and min = nearest and mip = none */
  77335. static readonly NEAREST_NEAREST: number;
  77336. /** mag = linear and min = nearest and mip = nearest */
  77337. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  77338. /** mag = linear and min = nearest and mip = linear */
  77339. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  77340. /** mag = linear and min = linear and mip = none */
  77341. static readonly LINEAR_LINEAR: number;
  77342. /** mag = linear and min = nearest and mip = none */
  77343. static readonly LINEAR_NEAREST: number;
  77344. /** Explicit coordinates mode */
  77345. static readonly EXPLICIT_MODE: number;
  77346. /** Spherical coordinates mode */
  77347. static readonly SPHERICAL_MODE: number;
  77348. /** Planar coordinates mode */
  77349. static readonly PLANAR_MODE: number;
  77350. /** Cubic coordinates mode */
  77351. static readonly CUBIC_MODE: number;
  77352. /** Projection coordinates mode */
  77353. static readonly PROJECTION_MODE: number;
  77354. /** Inverse Cubic coordinates mode */
  77355. static readonly SKYBOX_MODE: number;
  77356. /** Inverse Cubic coordinates mode */
  77357. static readonly INVCUBIC_MODE: number;
  77358. /** Equirectangular coordinates mode */
  77359. static readonly EQUIRECTANGULAR_MODE: number;
  77360. /** Equirectangular Fixed coordinates mode */
  77361. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  77362. /** Equirectangular Fixed Mirrored coordinates mode */
  77363. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  77364. /** Texture is not repeating outside of 0..1 UVs */
  77365. static readonly CLAMP_ADDRESSMODE: number;
  77366. /** Texture is repeating outside of 0..1 UVs */
  77367. static readonly WRAP_ADDRESSMODE: number;
  77368. /** Texture is repeating and mirrored */
  77369. static readonly MIRROR_ADDRESSMODE: number;
  77370. /**
  77371. * 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
  77372. */
  77373. static UseSerializedUrlIfAny: boolean;
  77374. /**
  77375. * Define the url of the texture.
  77376. */
  77377. url: Nullable<string>;
  77378. /**
  77379. * Define an offset on the texture to offset the u coordinates of the UVs
  77380. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  77381. */
  77382. uOffset: number;
  77383. /**
  77384. * Define an offset on the texture to offset the v coordinates of the UVs
  77385. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  77386. */
  77387. vOffset: number;
  77388. /**
  77389. * Define an offset on the texture to scale the u coordinates of the UVs
  77390. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  77391. */
  77392. uScale: number;
  77393. /**
  77394. * Define an offset on the texture to scale the v coordinates of the UVs
  77395. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  77396. */
  77397. vScale: number;
  77398. /**
  77399. * Define an offset on the texture to rotate around the u coordinates of the UVs
  77400. * @see http://doc.babylonjs.com/how_to/more_materials
  77401. */
  77402. uAng: number;
  77403. /**
  77404. * Define an offset on the texture to rotate around the v coordinates of the UVs
  77405. * @see http://doc.babylonjs.com/how_to/more_materials
  77406. */
  77407. vAng: number;
  77408. /**
  77409. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  77410. * @see http://doc.babylonjs.com/how_to/more_materials
  77411. */
  77412. wAng: number;
  77413. /**
  77414. * Defines the center of rotation (U)
  77415. */
  77416. uRotationCenter: number;
  77417. /**
  77418. * Defines the center of rotation (V)
  77419. */
  77420. vRotationCenter: number;
  77421. /**
  77422. * Defines the center of rotation (W)
  77423. */
  77424. wRotationCenter: number;
  77425. /**
  77426. * Are mip maps generated for this texture or not.
  77427. */
  77428. readonly noMipmap: boolean;
  77429. /**
  77430. * List of inspectable custom properties (used by the Inspector)
  77431. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  77432. */
  77433. inspectableCustomProperties: IInspectable[];
  77434. private _noMipmap;
  77435. /** @hidden */
  77436. _invertY: boolean;
  77437. private _rowGenerationMatrix;
  77438. private _cachedTextureMatrix;
  77439. private _projectionModeMatrix;
  77440. private _t0;
  77441. private _t1;
  77442. private _t2;
  77443. private _cachedUOffset;
  77444. private _cachedVOffset;
  77445. private _cachedUScale;
  77446. private _cachedVScale;
  77447. private _cachedUAng;
  77448. private _cachedVAng;
  77449. private _cachedWAng;
  77450. private _cachedProjectionMatrixId;
  77451. private _cachedCoordinatesMode;
  77452. /** @hidden */
  77453. protected _initialSamplingMode: number;
  77454. /** @hidden */
  77455. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  77456. private _deleteBuffer;
  77457. protected _format: Nullable<number>;
  77458. private _delayedOnLoad;
  77459. private _delayedOnError;
  77460. /**
  77461. * Observable triggered once the texture has been loaded.
  77462. */
  77463. onLoadObservable: Observable<Texture>;
  77464. protected _isBlocking: boolean;
  77465. /**
  77466. * Is the texture preventing material to render while loading.
  77467. * If false, a default texture will be used instead of the loading one during the preparation step.
  77468. */
  77469. isBlocking: boolean;
  77470. /**
  77471. * Get the current sampling mode associated with the texture.
  77472. */
  77473. readonly samplingMode: number;
  77474. /**
  77475. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  77476. */
  77477. readonly invertY: boolean;
  77478. /**
  77479. * Instantiates a new texture.
  77480. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  77481. * @see http://doc.babylonjs.com/babylon101/materials#texture
  77482. * @param url define the url of the picture to load as a texture
  77483. * @param scene define the scene the texture will belong to
  77484. * @param noMipmap define if the texture will require mip maps or not
  77485. * @param invertY define if the texture needs to be inverted on the y axis during loading
  77486. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  77487. * @param onLoad define a callback triggered when the texture has been loaded
  77488. * @param onError define a callback triggered when an error occurred during the loading session
  77489. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  77490. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  77491. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  77492. */
  77493. 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);
  77494. /**
  77495. * Update the url (and optional buffer) of this texture if url was null during construction.
  77496. * @param url the url of the texture
  77497. * @param buffer the buffer of the texture (defaults to null)
  77498. * @param onLoad callback called when the texture is loaded (defaults to null)
  77499. */
  77500. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  77501. /**
  77502. * Finish the loading sequence of a texture flagged as delayed load.
  77503. * @hidden
  77504. */
  77505. delayLoad(): void;
  77506. private _prepareRowForTextureGeneration;
  77507. /**
  77508. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  77509. * @returns the transform matrix of the texture.
  77510. */
  77511. getTextureMatrix(): Matrix;
  77512. /**
  77513. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  77514. * @returns The reflection texture transform
  77515. */
  77516. getReflectionTextureMatrix(): Matrix;
  77517. /**
  77518. * Clones the texture.
  77519. * @returns the cloned texture
  77520. */
  77521. clone(): Texture;
  77522. /**
  77523. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  77524. * @returns The JSON representation of the texture
  77525. */
  77526. serialize(): any;
  77527. /**
  77528. * Get the current class name of the texture useful for serialization or dynamic coding.
  77529. * @returns "Texture"
  77530. */
  77531. getClassName(): string;
  77532. /**
  77533. * Dispose the texture and release its associated resources.
  77534. */
  77535. dispose(): void;
  77536. /**
  77537. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  77538. * @param parsedTexture Define the JSON representation of the texture
  77539. * @param scene Define the scene the parsed texture should be instantiated in
  77540. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  77541. * @returns The parsed texture if successful
  77542. */
  77543. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  77544. /**
  77545. * Creates a texture from its base 64 representation.
  77546. * @param data Define the base64 payload without the data: prefix
  77547. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  77548. * @param scene Define the scene the texture should belong to
  77549. * @param noMipmap Forces the texture to not create mip map information if true
  77550. * @param invertY define if the texture needs to be inverted on the y axis during loading
  77551. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  77552. * @param onLoad define a callback triggered when the texture has been loaded
  77553. * @param onError define a callback triggered when an error occurred during the loading session
  77554. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  77555. * @returns the created texture
  77556. */
  77557. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  77558. /**
  77559. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  77560. * @param data Define the base64 payload without the data: prefix
  77561. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  77562. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  77563. * @param scene Define the scene the texture should belong to
  77564. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  77565. * @param noMipmap Forces the texture to not create mip map information if true
  77566. * @param invertY define if the texture needs to be inverted on the y axis during loading
  77567. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  77568. * @param onLoad define a callback triggered when the texture has been loaded
  77569. * @param onError define a callback triggered when an error occurred during the loading session
  77570. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  77571. * @returns the created texture
  77572. */
  77573. 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;
  77574. }
  77575. }
  77576. declare module BABYLON {
  77577. /**
  77578. * Raw texture can help creating a texture directly from an array of data.
  77579. * This can be super useful if you either get the data from an uncompressed source or
  77580. * if you wish to create your texture pixel by pixel.
  77581. */
  77582. export class RawTexture extends Texture {
  77583. /**
  77584. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77585. */
  77586. format: number;
  77587. private _engine;
  77588. /**
  77589. * Instantiates a new RawTexture.
  77590. * Raw texture can help creating a texture directly from an array of data.
  77591. * This can be super useful if you either get the data from an uncompressed source or
  77592. * if you wish to create your texture pixel by pixel.
  77593. * @param data define the array of data to use to create the texture
  77594. * @param width define the width of the texture
  77595. * @param height define the height of the texture
  77596. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77597. * @param scene define the scene the texture belongs to
  77598. * @param generateMipMaps define whether mip maps should be generated or not
  77599. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77600. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77601. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77602. */
  77603. constructor(data: ArrayBufferView, width: number, height: number,
  77604. /**
  77605. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77606. */
  77607. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  77608. /**
  77609. * Updates the texture underlying data.
  77610. * @param data Define the new data of the texture
  77611. */
  77612. update(data: ArrayBufferView): void;
  77613. /**
  77614. * Creates a luminance texture from some data.
  77615. * @param data Define the texture data
  77616. * @param width Define the width of the texture
  77617. * @param height Define the height of the texture
  77618. * @param scene Define the scene the texture belongs to
  77619. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77620. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77621. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77622. * @returns the luminance texture
  77623. */
  77624. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77625. /**
  77626. * Creates a luminance alpha texture from some data.
  77627. * @param data Define the texture data
  77628. * @param width Define the width of the texture
  77629. * @param height Define the height of the texture
  77630. * @param scene Define the scene the texture belongs to
  77631. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77632. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77633. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77634. * @returns the luminance alpha texture
  77635. */
  77636. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77637. /**
  77638. * Creates an alpha texture from some data.
  77639. * @param data Define the texture data
  77640. * @param width Define the width of the texture
  77641. * @param height Define the height of the texture
  77642. * @param scene Define the scene the texture belongs to
  77643. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77644. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77645. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77646. * @returns the alpha texture
  77647. */
  77648. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77649. /**
  77650. * Creates a RGB texture from some data.
  77651. * @param data Define the texture data
  77652. * @param width Define the width of the texture
  77653. * @param height Define the height of the texture
  77654. * @param scene Define the scene the texture belongs to
  77655. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77656. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77657. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77658. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77659. * @returns the RGB alpha texture
  77660. */
  77661. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77662. /**
  77663. * Creates a RGBA texture from some data.
  77664. * @param data Define the texture data
  77665. * @param width Define the width of the texture
  77666. * @param height Define the height of the texture
  77667. * @param scene Define the scene the texture belongs to
  77668. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77669. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77670. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77671. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77672. * @returns the RGBA texture
  77673. */
  77674. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77675. /**
  77676. * Creates a R texture from some data.
  77677. * @param data Define the texture data
  77678. * @param width Define the width of the texture
  77679. * @param height Define the height of the texture
  77680. * @param scene Define the scene the texture belongs to
  77681. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77682. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77683. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77684. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77685. * @returns the R texture
  77686. */
  77687. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77688. }
  77689. }
  77690. declare module BABYLON {
  77691. /**
  77692. * Defines a runtime animation
  77693. */
  77694. export class RuntimeAnimation {
  77695. private _events;
  77696. /**
  77697. * The current frame of the runtime animation
  77698. */
  77699. private _currentFrame;
  77700. /**
  77701. * The animation used by the runtime animation
  77702. */
  77703. private _animation;
  77704. /**
  77705. * The target of the runtime animation
  77706. */
  77707. private _target;
  77708. /**
  77709. * The initiating animatable
  77710. */
  77711. private _host;
  77712. /**
  77713. * The original value of the runtime animation
  77714. */
  77715. private _originalValue;
  77716. /**
  77717. * The original blend value of the runtime animation
  77718. */
  77719. private _originalBlendValue;
  77720. /**
  77721. * The offsets cache of the runtime animation
  77722. */
  77723. private _offsetsCache;
  77724. /**
  77725. * The high limits cache of the runtime animation
  77726. */
  77727. private _highLimitsCache;
  77728. /**
  77729. * Specifies if the runtime animation has been stopped
  77730. */
  77731. private _stopped;
  77732. /**
  77733. * The blending factor of the runtime animation
  77734. */
  77735. private _blendingFactor;
  77736. /**
  77737. * The BabylonJS scene
  77738. */
  77739. private _scene;
  77740. /**
  77741. * The current value of the runtime animation
  77742. */
  77743. private _currentValue;
  77744. /** @hidden */
  77745. _workValue: any;
  77746. /**
  77747. * The active target of the runtime animation
  77748. */
  77749. private _activeTargets;
  77750. private _currentActiveTarget;
  77751. private _directTarget;
  77752. /**
  77753. * The target path of the runtime animation
  77754. */
  77755. private _targetPath;
  77756. /**
  77757. * The weight of the runtime animation
  77758. */
  77759. private _weight;
  77760. /**
  77761. * The ratio offset of the runtime animation
  77762. */
  77763. private _ratioOffset;
  77764. /**
  77765. * The previous delay of the runtime animation
  77766. */
  77767. private _previousDelay;
  77768. /**
  77769. * The previous ratio of the runtime animation
  77770. */
  77771. private _previousRatio;
  77772. private _enableBlending;
  77773. private _correctLoopMode;
  77774. private _keys;
  77775. private _minFrame;
  77776. private _maxFrame;
  77777. private _minValue;
  77778. private _maxValue;
  77779. /**
  77780. * Gets the current frame of the runtime animation
  77781. */
  77782. readonly currentFrame: number;
  77783. /**
  77784. * Gets the weight of the runtime animation
  77785. */
  77786. readonly weight: number;
  77787. /**
  77788. * Gets the current value of the runtime animation
  77789. */
  77790. readonly currentValue: any;
  77791. /**
  77792. * Gets the target path of the runtime animation
  77793. */
  77794. readonly targetPath: string;
  77795. /**
  77796. * Gets the actual target of the runtime animation
  77797. */
  77798. readonly target: any;
  77799. /**
  77800. * Create a new RuntimeAnimation object
  77801. * @param target defines the target of the animation
  77802. * @param animation defines the source animation object
  77803. * @param scene defines the hosting scene
  77804. * @param host defines the initiating Animatable
  77805. */
  77806. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  77807. private _normalizationProcessor;
  77808. private _defaultNormalizationProcessor;
  77809. private _preparePath;
  77810. /**
  77811. * Gets the animation from the runtime animation
  77812. */
  77813. readonly animation: Animation;
  77814. /**
  77815. * Resets the runtime animation to the beginning
  77816. * @param restoreOriginal defines whether to restore the target property to the original value
  77817. */
  77818. reset(restoreOriginal?: boolean): void;
  77819. /**
  77820. * Specifies if the runtime animation is stopped
  77821. * @returns Boolean specifying if the runtime animation is stopped
  77822. */
  77823. isStopped(): boolean;
  77824. /**
  77825. * Disposes of the runtime animation
  77826. */
  77827. dispose(): void;
  77828. /**
  77829. * Interpolates the animation from the current frame
  77830. * @param currentFrame The frame to interpolate the animation to
  77831. * @param repeatCount The number of times that the animation should loop
  77832. * @param loopMode The type of looping mode to use
  77833. * @param offsetValue Animation offset value
  77834. * @param highLimitValue The high limit value
  77835. * @returns The interpolated value
  77836. */
  77837. private _interpolate;
  77838. /**
  77839. * Apply the interpolated value to the target
  77840. */
  77841. setValue: (currentValue: any, weight: number) => void;
  77842. private _setValueForArray;
  77843. private _setValueForDirect;
  77844. private _getOriginalValues;
  77845. private _activeBlendingProcessor;
  77846. private _noBlendingProcessor;
  77847. private _blendingProcessor;
  77848. private _setValue;
  77849. /**
  77850. * Gets the loop pmode of the runtime animation
  77851. * @returns Loop Mode
  77852. */
  77853. private _getCorrectLoopMode;
  77854. /**
  77855. * Move the current animation to a given frame
  77856. * @param frame defines the frame to move to
  77857. */
  77858. goToFrame(frame: number): void;
  77859. /**
  77860. * @hidden Internal use only
  77861. */
  77862. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  77863. /**
  77864. * Execute the current animation
  77865. * @param delay defines the delay to add to the current frame
  77866. * @param from defines the lower bound of the animation range
  77867. * @param to defines the upper bound of the animation range
  77868. * @param loop defines if the current animation must loop
  77869. * @param speedRatio defines the current speed ratio
  77870. * @param weight defines the weight of the animation (default is -1 so no weight)
  77871. * @param onLoop optional callback called when animation loops
  77872. * @returns a boolean indicating if the animation is running
  77873. */
  77874. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  77875. }
  77876. }
  77877. declare module BABYLON {
  77878. /**
  77879. * Class used to store an actual running animation
  77880. */
  77881. export class Animatable {
  77882. /** defines the target object */
  77883. target: any;
  77884. /** defines the starting frame number (default is 0) */
  77885. fromFrame: number;
  77886. /** defines the ending frame number (default is 100) */
  77887. toFrame: number;
  77888. /** defines if the animation must loop (default is false) */
  77889. loopAnimation: boolean;
  77890. /** defines a callback to call when animation ends if it is not looping */
  77891. onAnimationEnd?: (() => void) | null | undefined;
  77892. /** defines a callback to call when animation loops */
  77893. onAnimationLoop?: (() => void) | null | undefined;
  77894. private _localDelayOffset;
  77895. private _pausedDelay;
  77896. private _runtimeAnimations;
  77897. private _paused;
  77898. private _scene;
  77899. private _speedRatio;
  77900. private _weight;
  77901. private _syncRoot;
  77902. /**
  77903. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  77904. * This will only apply for non looping animation (default is true)
  77905. */
  77906. disposeOnEnd: boolean;
  77907. /**
  77908. * Gets a boolean indicating if the animation has started
  77909. */
  77910. animationStarted: boolean;
  77911. /**
  77912. * Observer raised when the animation ends
  77913. */
  77914. onAnimationEndObservable: Observable<Animatable>;
  77915. /**
  77916. * Observer raised when the animation loops
  77917. */
  77918. onAnimationLoopObservable: Observable<Animatable>;
  77919. /**
  77920. * Gets the root Animatable used to synchronize and normalize animations
  77921. */
  77922. readonly syncRoot: Animatable;
  77923. /**
  77924. * Gets the current frame of the first RuntimeAnimation
  77925. * Used to synchronize Animatables
  77926. */
  77927. readonly masterFrame: number;
  77928. /**
  77929. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  77930. */
  77931. weight: number;
  77932. /**
  77933. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  77934. */
  77935. speedRatio: number;
  77936. /**
  77937. * Creates a new Animatable
  77938. * @param scene defines the hosting scene
  77939. * @param target defines the target object
  77940. * @param fromFrame defines the starting frame number (default is 0)
  77941. * @param toFrame defines the ending frame number (default is 100)
  77942. * @param loopAnimation defines if the animation must loop (default is false)
  77943. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  77944. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  77945. * @param animations defines a group of animation to add to the new Animatable
  77946. * @param onAnimationLoop defines a callback to call when animation loops
  77947. */
  77948. constructor(scene: Scene,
  77949. /** defines the target object */
  77950. target: any,
  77951. /** defines the starting frame number (default is 0) */
  77952. fromFrame?: number,
  77953. /** defines the ending frame number (default is 100) */
  77954. toFrame?: number,
  77955. /** defines if the animation must loop (default is false) */
  77956. loopAnimation?: boolean, speedRatio?: number,
  77957. /** defines a callback to call when animation ends if it is not looping */
  77958. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  77959. /** defines a callback to call when animation loops */
  77960. onAnimationLoop?: (() => void) | null | undefined);
  77961. /**
  77962. * Synchronize and normalize current Animatable with a source Animatable
  77963. * This is useful when using animation weights and when animations are not of the same length
  77964. * @param root defines the root Animatable to synchronize with
  77965. * @returns the current Animatable
  77966. */
  77967. syncWith(root: Animatable): Animatable;
  77968. /**
  77969. * Gets the list of runtime animations
  77970. * @returns an array of RuntimeAnimation
  77971. */
  77972. getAnimations(): RuntimeAnimation[];
  77973. /**
  77974. * Adds more animations to the current animatable
  77975. * @param target defines the target of the animations
  77976. * @param animations defines the new animations to add
  77977. */
  77978. appendAnimations(target: any, animations: Animation[]): void;
  77979. /**
  77980. * Gets the source animation for a specific property
  77981. * @param property defines the propertyu to look for
  77982. * @returns null or the source animation for the given property
  77983. */
  77984. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  77985. /**
  77986. * Gets the runtime animation for a specific property
  77987. * @param property defines the propertyu to look for
  77988. * @returns null or the runtime animation for the given property
  77989. */
  77990. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  77991. /**
  77992. * Resets the animatable to its original state
  77993. */
  77994. reset(): void;
  77995. /**
  77996. * Allows the animatable to blend with current running animations
  77997. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77998. * @param blendingSpeed defines the blending speed to use
  77999. */
  78000. enableBlending(blendingSpeed: number): void;
  78001. /**
  78002. * Disable animation blending
  78003. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78004. */
  78005. disableBlending(): void;
  78006. /**
  78007. * Jump directly to a given frame
  78008. * @param frame defines the frame to jump to
  78009. */
  78010. goToFrame(frame: number): void;
  78011. /**
  78012. * Pause the animation
  78013. */
  78014. pause(): void;
  78015. /**
  78016. * Restart the animation
  78017. */
  78018. restart(): void;
  78019. private _raiseOnAnimationEnd;
  78020. /**
  78021. * Stop and delete the current animation
  78022. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  78023. * @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)
  78024. */
  78025. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  78026. /**
  78027. * Wait asynchronously for the animation to end
  78028. * @returns a promise which will be fullfilled when the animation ends
  78029. */
  78030. waitAsync(): Promise<Animatable>;
  78031. /** @hidden */
  78032. _animate(delay: number): boolean;
  78033. }
  78034. interface Scene {
  78035. /** @hidden */
  78036. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  78037. /** @hidden */
  78038. _processLateAnimationBindingsForMatrices(holder: {
  78039. totalWeight: number;
  78040. animations: RuntimeAnimation[];
  78041. originalValue: Matrix;
  78042. }): any;
  78043. /** @hidden */
  78044. _processLateAnimationBindingsForQuaternions(holder: {
  78045. totalWeight: number;
  78046. animations: RuntimeAnimation[];
  78047. originalValue: Quaternion;
  78048. }, refQuaternion: Quaternion): Quaternion;
  78049. /** @hidden */
  78050. _processLateAnimationBindings(): void;
  78051. /**
  78052. * Will start the animation sequence of a given target
  78053. * @param target defines the target
  78054. * @param from defines from which frame should animation start
  78055. * @param to defines until which frame should animation run.
  78056. * @param weight defines the weight to apply to the animation (1.0 by default)
  78057. * @param loop defines if the animation loops
  78058. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78059. * @param onAnimationEnd defines the function to be executed when the animation ends
  78060. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78061. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78062. * @param onAnimationLoop defines the callback to call when an animation loops
  78063. * @returns the animatable object created for this animation
  78064. */
  78065. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78066. /**
  78067. * Will start the animation sequence of a given target
  78068. * @param target defines the target
  78069. * @param from defines from which frame should animation start
  78070. * @param to defines until which frame should animation run.
  78071. * @param loop defines if the animation loops
  78072. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78073. * @param onAnimationEnd defines the function to be executed when the animation ends
  78074. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78075. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78076. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  78077. * @param onAnimationLoop defines the callback to call when an animation loops
  78078. * @returns the animatable object created for this animation
  78079. */
  78080. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78081. /**
  78082. * Will start the animation sequence of a given target and its hierarchy
  78083. * @param target defines the target
  78084. * @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.
  78085. * @param from defines from which frame should animation start
  78086. * @param to defines until which frame should animation run.
  78087. * @param loop defines if the animation loops
  78088. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78089. * @param onAnimationEnd defines the function to be executed when the animation ends
  78090. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78091. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78092. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78093. * @param onAnimationLoop defines the callback to call when an animation loops
  78094. * @returns the list of created animatables
  78095. */
  78096. 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[];
  78097. /**
  78098. * Begin a new animation on a given node
  78099. * @param target defines the target where the animation will take place
  78100. * @param animations defines the list of animations to start
  78101. * @param from defines the initial value
  78102. * @param to defines the final value
  78103. * @param loop defines if you want animation to loop (off by default)
  78104. * @param speedRatio defines the speed ratio to apply to all animations
  78105. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  78106. * @param onAnimationLoop defines the callback to call when an animation loops
  78107. * @returns the list of created animatables
  78108. */
  78109. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  78110. /**
  78111. * Begin a new animation on a given node and its hierarchy
  78112. * @param target defines the root node where the animation will take place
  78113. * @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.
  78114. * @param animations defines the list of animations to start
  78115. * @param from defines the initial value
  78116. * @param to defines the final value
  78117. * @param loop defines if you want animation to loop (off by default)
  78118. * @param speedRatio defines the speed ratio to apply to all animations
  78119. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  78120. * @param onAnimationLoop defines the callback to call when an animation loops
  78121. * @returns the list of animatables created for all nodes
  78122. */
  78123. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  78124. /**
  78125. * Gets the animatable associated with a specific target
  78126. * @param target defines the target of the animatable
  78127. * @returns the required animatable if found
  78128. */
  78129. getAnimatableByTarget(target: any): Nullable<Animatable>;
  78130. /**
  78131. * Gets all animatables associated with a given target
  78132. * @param target defines the target to look animatables for
  78133. * @returns an array of Animatables
  78134. */
  78135. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  78136. /**
  78137. * Will stop the animation of the given target
  78138. * @param target - the target
  78139. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  78140. * @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)
  78141. */
  78142. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  78143. /**
  78144. * Stops and removes all animations that have been applied to the scene
  78145. */
  78146. stopAllAnimations(): void;
  78147. }
  78148. interface Bone {
  78149. /**
  78150. * Copy an animation range from another bone
  78151. * @param source defines the source bone
  78152. * @param rangeName defines the range name to copy
  78153. * @param frameOffset defines the frame offset
  78154. * @param rescaleAsRequired defines if rescaling must be applied if required
  78155. * @param skelDimensionsRatio defines the scaling ratio
  78156. * @returns true if operation was successful
  78157. */
  78158. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  78159. }
  78160. }
  78161. declare module BABYLON {
  78162. /**
  78163. * Class used to handle skinning animations
  78164. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  78165. */
  78166. export class Skeleton implements IAnimatable {
  78167. /** defines the skeleton name */
  78168. name: string;
  78169. /** defines the skeleton Id */
  78170. id: string;
  78171. /**
  78172. * Defines the list of child bones
  78173. */
  78174. bones: Bone[];
  78175. /**
  78176. * Defines an estimate of the dimension of the skeleton at rest
  78177. */
  78178. dimensionsAtRest: Vector3;
  78179. /**
  78180. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  78181. */
  78182. needInitialSkinMatrix: boolean;
  78183. /**
  78184. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  78185. */
  78186. overrideMesh: Nullable<AbstractMesh>;
  78187. /**
  78188. * Gets the list of animations attached to this skeleton
  78189. */
  78190. animations: Array<Animation>;
  78191. private _scene;
  78192. private _isDirty;
  78193. private _transformMatrices;
  78194. private _transformMatrixTexture;
  78195. private _meshesWithPoseMatrix;
  78196. private _animatables;
  78197. private _identity;
  78198. private _synchronizedWithMesh;
  78199. private _ranges;
  78200. private _lastAbsoluteTransformsUpdateId;
  78201. private _canUseTextureForBones;
  78202. private _uniqueId;
  78203. /** @hidden */
  78204. _numBonesWithLinkedTransformNode: number;
  78205. /**
  78206. * Specifies if the skeleton should be serialized
  78207. */
  78208. doNotSerialize: boolean;
  78209. private _useTextureToStoreBoneMatrices;
  78210. /**
  78211. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  78212. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  78213. */
  78214. useTextureToStoreBoneMatrices: boolean;
  78215. private _animationPropertiesOverride;
  78216. /**
  78217. * Gets or sets the animation properties override
  78218. */
  78219. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  78220. /**
  78221. * List of inspectable custom properties (used by the Inspector)
  78222. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78223. */
  78224. inspectableCustomProperties: IInspectable[];
  78225. /**
  78226. * An observable triggered before computing the skeleton's matrices
  78227. */
  78228. onBeforeComputeObservable: Observable<Skeleton>;
  78229. /**
  78230. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  78231. */
  78232. readonly isUsingTextureForMatrices: boolean;
  78233. /**
  78234. * Gets the unique ID of this skeleton
  78235. */
  78236. readonly uniqueId: number;
  78237. /**
  78238. * Creates a new skeleton
  78239. * @param name defines the skeleton name
  78240. * @param id defines the skeleton Id
  78241. * @param scene defines the hosting scene
  78242. */
  78243. constructor(
  78244. /** defines the skeleton name */
  78245. name: string,
  78246. /** defines the skeleton Id */
  78247. id: string, scene: Scene);
  78248. /**
  78249. * Gets the current object class name.
  78250. * @return the class name
  78251. */
  78252. getClassName(): string;
  78253. /**
  78254. * Returns an array containing the root bones
  78255. * @returns an array containing the root bones
  78256. */
  78257. getChildren(): Array<Bone>;
  78258. /**
  78259. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  78260. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  78261. * @returns a Float32Array containing matrices data
  78262. */
  78263. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  78264. /**
  78265. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  78266. * @returns a raw texture containing the data
  78267. */
  78268. getTransformMatrixTexture(): Nullable<RawTexture>;
  78269. /**
  78270. * Gets the current hosting scene
  78271. * @returns a scene object
  78272. */
  78273. getScene(): Scene;
  78274. /**
  78275. * Gets a string representing the current skeleton data
  78276. * @param fullDetails defines a boolean indicating if we want a verbose version
  78277. * @returns a string representing the current skeleton data
  78278. */
  78279. toString(fullDetails?: boolean): string;
  78280. /**
  78281. * Get bone's index searching by name
  78282. * @param name defines bone's name to search for
  78283. * @return the indice of the bone. Returns -1 if not found
  78284. */
  78285. getBoneIndexByName(name: string): number;
  78286. /**
  78287. * Creater a new animation range
  78288. * @param name defines the name of the range
  78289. * @param from defines the start key
  78290. * @param to defines the end key
  78291. */
  78292. createAnimationRange(name: string, from: number, to: number): void;
  78293. /**
  78294. * Delete a specific animation range
  78295. * @param name defines the name of the range
  78296. * @param deleteFrames defines if frames must be removed as well
  78297. */
  78298. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  78299. /**
  78300. * Gets a specific animation range
  78301. * @param name defines the name of the range to look for
  78302. * @returns the requested animation range or null if not found
  78303. */
  78304. getAnimationRange(name: string): Nullable<AnimationRange>;
  78305. /**
  78306. * Gets the list of all animation ranges defined on this skeleton
  78307. * @returns an array
  78308. */
  78309. getAnimationRanges(): Nullable<AnimationRange>[];
  78310. /**
  78311. * Copy animation range from a source skeleton.
  78312. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  78313. * @param source defines the source skeleton
  78314. * @param name defines the name of the range to copy
  78315. * @param rescaleAsRequired defines if rescaling must be applied if required
  78316. * @returns true if operation was successful
  78317. */
  78318. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  78319. /**
  78320. * Forces the skeleton to go to rest pose
  78321. */
  78322. returnToRest(): void;
  78323. private _getHighestAnimationFrame;
  78324. /**
  78325. * Begin a specific animation range
  78326. * @param name defines the name of the range to start
  78327. * @param loop defines if looping must be turned on (false by default)
  78328. * @param speedRatio defines the speed ratio to apply (1 by default)
  78329. * @param onAnimationEnd defines a callback which will be called when animation will end
  78330. * @returns a new animatable
  78331. */
  78332. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  78333. /** @hidden */
  78334. _markAsDirty(): void;
  78335. /** @hidden */
  78336. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  78337. /** @hidden */
  78338. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  78339. private _computeTransformMatrices;
  78340. /**
  78341. * Build all resources required to render a skeleton
  78342. */
  78343. prepare(): void;
  78344. /**
  78345. * Gets the list of animatables currently running for this skeleton
  78346. * @returns an array of animatables
  78347. */
  78348. getAnimatables(): IAnimatable[];
  78349. /**
  78350. * Clone the current skeleton
  78351. * @param name defines the name of the new skeleton
  78352. * @param id defines the id of the enw skeleton
  78353. * @returns the new skeleton
  78354. */
  78355. clone(name: string, id: string): Skeleton;
  78356. /**
  78357. * Enable animation blending for this skeleton
  78358. * @param blendingSpeed defines the blending speed to apply
  78359. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78360. */
  78361. enableBlending(blendingSpeed?: number): void;
  78362. /**
  78363. * Releases all resources associated with the current skeleton
  78364. */
  78365. dispose(): void;
  78366. /**
  78367. * Serialize the skeleton in a JSON object
  78368. * @returns a JSON object
  78369. */
  78370. serialize(): any;
  78371. /**
  78372. * Creates a new skeleton from serialized data
  78373. * @param parsedSkeleton defines the serialized data
  78374. * @param scene defines the hosting scene
  78375. * @returns a new skeleton
  78376. */
  78377. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  78378. /**
  78379. * Compute all node absolute transforms
  78380. * @param forceUpdate defines if computation must be done even if cache is up to date
  78381. */
  78382. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  78383. /**
  78384. * Gets the root pose matrix
  78385. * @returns a matrix
  78386. */
  78387. getPoseMatrix(): Nullable<Matrix>;
  78388. /**
  78389. * Sorts bones per internal index
  78390. */
  78391. sortBones(): void;
  78392. private _sortBones;
  78393. }
  78394. }
  78395. declare module BABYLON {
  78396. /**
  78397. * Defines a target to use with MorphTargetManager
  78398. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  78399. */
  78400. export class MorphTarget implements IAnimatable {
  78401. /** defines the name of the target */
  78402. name: string;
  78403. /**
  78404. * Gets or sets the list of animations
  78405. */
  78406. animations: Animation[];
  78407. private _scene;
  78408. private _positions;
  78409. private _normals;
  78410. private _tangents;
  78411. private _influence;
  78412. /**
  78413. * Observable raised when the influence changes
  78414. */
  78415. onInfluenceChanged: Observable<boolean>;
  78416. /** @hidden */
  78417. _onDataLayoutChanged: Observable<void>;
  78418. /**
  78419. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  78420. */
  78421. influence: number;
  78422. /**
  78423. * Gets or sets the id of the morph Target
  78424. */
  78425. id: string;
  78426. private _animationPropertiesOverride;
  78427. /**
  78428. * Gets or sets the animation properties override
  78429. */
  78430. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  78431. /**
  78432. * Creates a new MorphTarget
  78433. * @param name defines the name of the target
  78434. * @param influence defines the influence to use
  78435. * @param scene defines the scene the morphtarget belongs to
  78436. */
  78437. constructor(
  78438. /** defines the name of the target */
  78439. name: string, influence?: number, scene?: Nullable<Scene>);
  78440. /**
  78441. * Gets a boolean defining if the target contains position data
  78442. */
  78443. readonly hasPositions: boolean;
  78444. /**
  78445. * Gets a boolean defining if the target contains normal data
  78446. */
  78447. readonly hasNormals: boolean;
  78448. /**
  78449. * Gets a boolean defining if the target contains tangent data
  78450. */
  78451. readonly hasTangents: boolean;
  78452. /**
  78453. * Affects position data to this target
  78454. * @param data defines the position data to use
  78455. */
  78456. setPositions(data: Nullable<FloatArray>): void;
  78457. /**
  78458. * Gets the position data stored in this target
  78459. * @returns a FloatArray containing the position data (or null if not present)
  78460. */
  78461. getPositions(): Nullable<FloatArray>;
  78462. /**
  78463. * Affects normal data to this target
  78464. * @param data defines the normal data to use
  78465. */
  78466. setNormals(data: Nullable<FloatArray>): void;
  78467. /**
  78468. * Gets the normal data stored in this target
  78469. * @returns a FloatArray containing the normal data (or null if not present)
  78470. */
  78471. getNormals(): Nullable<FloatArray>;
  78472. /**
  78473. * Affects tangent data to this target
  78474. * @param data defines the tangent data to use
  78475. */
  78476. setTangents(data: Nullable<FloatArray>): void;
  78477. /**
  78478. * Gets the tangent data stored in this target
  78479. * @returns a FloatArray containing the tangent data (or null if not present)
  78480. */
  78481. getTangents(): Nullable<FloatArray>;
  78482. /**
  78483. * Serializes the current target into a Serialization object
  78484. * @returns the serialized object
  78485. */
  78486. serialize(): any;
  78487. /**
  78488. * Returns the string "MorphTarget"
  78489. * @returns "MorphTarget"
  78490. */
  78491. getClassName(): string;
  78492. /**
  78493. * Creates a new target from serialized data
  78494. * @param serializationObject defines the serialized data to use
  78495. * @returns a new MorphTarget
  78496. */
  78497. static Parse(serializationObject: any): MorphTarget;
  78498. /**
  78499. * Creates a MorphTarget from mesh data
  78500. * @param mesh defines the source mesh
  78501. * @param name defines the name to use for the new target
  78502. * @param influence defines the influence to attach to the target
  78503. * @returns a new MorphTarget
  78504. */
  78505. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  78506. }
  78507. }
  78508. declare module BABYLON {
  78509. /**
  78510. * This class is used to deform meshes using morphing between different targets
  78511. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  78512. */
  78513. export class MorphTargetManager {
  78514. private _targets;
  78515. private _targetInfluenceChangedObservers;
  78516. private _targetDataLayoutChangedObservers;
  78517. private _activeTargets;
  78518. private _scene;
  78519. private _influences;
  78520. private _supportsNormals;
  78521. private _supportsTangents;
  78522. private _vertexCount;
  78523. private _uniqueId;
  78524. private _tempInfluences;
  78525. /**
  78526. * Creates a new MorphTargetManager
  78527. * @param scene defines the current scene
  78528. */
  78529. constructor(scene?: Nullable<Scene>);
  78530. /**
  78531. * Gets the unique ID of this manager
  78532. */
  78533. readonly uniqueId: number;
  78534. /**
  78535. * Gets the number of vertices handled by this manager
  78536. */
  78537. readonly vertexCount: number;
  78538. /**
  78539. * Gets a boolean indicating if this manager supports morphing of normals
  78540. */
  78541. readonly supportsNormals: boolean;
  78542. /**
  78543. * Gets a boolean indicating if this manager supports morphing of tangents
  78544. */
  78545. readonly supportsTangents: boolean;
  78546. /**
  78547. * Gets the number of targets stored in this manager
  78548. */
  78549. readonly numTargets: number;
  78550. /**
  78551. * Gets the number of influencers (ie. the number of targets with influences > 0)
  78552. */
  78553. readonly numInfluencers: number;
  78554. /**
  78555. * Gets the list of influences (one per target)
  78556. */
  78557. readonly influences: Float32Array;
  78558. /**
  78559. * Gets the active target at specified index. An active target is a target with an influence > 0
  78560. * @param index defines the index to check
  78561. * @returns the requested target
  78562. */
  78563. getActiveTarget(index: number): MorphTarget;
  78564. /**
  78565. * Gets the target at specified index
  78566. * @param index defines the index to check
  78567. * @returns the requested target
  78568. */
  78569. getTarget(index: number): MorphTarget;
  78570. /**
  78571. * Add a new target to this manager
  78572. * @param target defines the target to add
  78573. */
  78574. addTarget(target: MorphTarget): void;
  78575. /**
  78576. * Removes a target from the manager
  78577. * @param target defines the target to remove
  78578. */
  78579. removeTarget(target: MorphTarget): void;
  78580. /**
  78581. * Serializes the current manager into a Serialization object
  78582. * @returns the serialized object
  78583. */
  78584. serialize(): any;
  78585. private _syncActiveTargets;
  78586. /**
  78587. * Syncrhonize the targets with all the meshes using this morph target manager
  78588. */
  78589. synchronize(): void;
  78590. /**
  78591. * Creates a new MorphTargetManager from serialized data
  78592. * @param serializationObject defines the serialized data
  78593. * @param scene defines the hosting scene
  78594. * @returns the new MorphTargetManager
  78595. */
  78596. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  78597. }
  78598. }
  78599. declare module BABYLON {
  78600. /**
  78601. * Mesh representing the gorund
  78602. */
  78603. export class GroundMesh extends Mesh {
  78604. /** If octree should be generated */
  78605. generateOctree: boolean;
  78606. private _heightQuads;
  78607. /** @hidden */
  78608. _subdivisionsX: number;
  78609. /** @hidden */
  78610. _subdivisionsY: number;
  78611. /** @hidden */
  78612. _width: number;
  78613. /** @hidden */
  78614. _height: number;
  78615. /** @hidden */
  78616. _minX: number;
  78617. /** @hidden */
  78618. _maxX: number;
  78619. /** @hidden */
  78620. _minZ: number;
  78621. /** @hidden */
  78622. _maxZ: number;
  78623. constructor(name: string, scene: Scene);
  78624. /**
  78625. * "GroundMesh"
  78626. * @returns "GroundMesh"
  78627. */
  78628. getClassName(): string;
  78629. /**
  78630. * The minimum of x and y subdivisions
  78631. */
  78632. readonly subdivisions: number;
  78633. /**
  78634. * X subdivisions
  78635. */
  78636. readonly subdivisionsX: number;
  78637. /**
  78638. * Y subdivisions
  78639. */
  78640. readonly subdivisionsY: number;
  78641. /**
  78642. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  78643. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  78644. * @param chunksCount the number of subdivisions for x and y
  78645. * @param octreeBlocksSize (Default: 32)
  78646. */
  78647. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  78648. /**
  78649. * Returns a height (y) value in the Worl system :
  78650. * the ground altitude at the coordinates (x, z) expressed in the World system.
  78651. * @param x x coordinate
  78652. * @param z z coordinate
  78653. * @returns the ground y position if (x, z) are outside the ground surface.
  78654. */
  78655. getHeightAtCoordinates(x: number, z: number): number;
  78656. /**
  78657. * Returns a normalized vector (Vector3) orthogonal to the ground
  78658. * at the ground coordinates (x, z) expressed in the World system.
  78659. * @param x x coordinate
  78660. * @param z z coordinate
  78661. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  78662. */
  78663. getNormalAtCoordinates(x: number, z: number): Vector3;
  78664. /**
  78665. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  78666. * at the ground coordinates (x, z) expressed in the World system.
  78667. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  78668. * @param x x coordinate
  78669. * @param z z coordinate
  78670. * @param ref vector to store the result
  78671. * @returns the GroundMesh.
  78672. */
  78673. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  78674. /**
  78675. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  78676. * if the ground has been updated.
  78677. * This can be used in the render loop.
  78678. * @returns the GroundMesh.
  78679. */
  78680. updateCoordinateHeights(): GroundMesh;
  78681. private _getFacetAt;
  78682. private _initHeightQuads;
  78683. private _computeHeightQuads;
  78684. /**
  78685. * Serializes this ground mesh
  78686. * @param serializationObject object to write serialization to
  78687. */
  78688. serialize(serializationObject: any): void;
  78689. /**
  78690. * Parses a serialized ground mesh
  78691. * @param parsedMesh the serialized mesh
  78692. * @param scene the scene to create the ground mesh in
  78693. * @returns the created ground mesh
  78694. */
  78695. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  78696. }
  78697. }
  78698. declare module BABYLON {
  78699. /**
  78700. * Interface for Physics-Joint data
  78701. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78702. */
  78703. export interface PhysicsJointData {
  78704. /**
  78705. * The main pivot of the joint
  78706. */
  78707. mainPivot?: Vector3;
  78708. /**
  78709. * The connected pivot of the joint
  78710. */
  78711. connectedPivot?: Vector3;
  78712. /**
  78713. * The main axis of the joint
  78714. */
  78715. mainAxis?: Vector3;
  78716. /**
  78717. * The connected axis of the joint
  78718. */
  78719. connectedAxis?: Vector3;
  78720. /**
  78721. * The collision of the joint
  78722. */
  78723. collision?: boolean;
  78724. /**
  78725. * Native Oimo/Cannon/Energy data
  78726. */
  78727. nativeParams?: any;
  78728. }
  78729. /**
  78730. * This is a holder class for the physics joint created by the physics plugin
  78731. * It holds a set of functions to control the underlying joint
  78732. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78733. */
  78734. export class PhysicsJoint {
  78735. /**
  78736. * The type of the physics joint
  78737. */
  78738. type: number;
  78739. /**
  78740. * The data for the physics joint
  78741. */
  78742. jointData: PhysicsJointData;
  78743. private _physicsJoint;
  78744. protected _physicsPlugin: IPhysicsEnginePlugin;
  78745. /**
  78746. * Initializes the physics joint
  78747. * @param type The type of the physics joint
  78748. * @param jointData The data for the physics joint
  78749. */
  78750. constructor(
  78751. /**
  78752. * The type of the physics joint
  78753. */
  78754. type: number,
  78755. /**
  78756. * The data for the physics joint
  78757. */
  78758. jointData: PhysicsJointData);
  78759. /**
  78760. * Gets the physics joint
  78761. */
  78762. /**
  78763. * Sets the physics joint
  78764. */
  78765. physicsJoint: any;
  78766. /**
  78767. * Sets the physics plugin
  78768. */
  78769. physicsPlugin: IPhysicsEnginePlugin;
  78770. /**
  78771. * Execute a function that is physics-plugin specific.
  78772. * @param {Function} func the function that will be executed.
  78773. * It accepts two parameters: the physics world and the physics joint
  78774. */
  78775. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  78776. /**
  78777. * Distance-Joint type
  78778. */
  78779. static DistanceJoint: number;
  78780. /**
  78781. * Hinge-Joint type
  78782. */
  78783. static HingeJoint: number;
  78784. /**
  78785. * Ball-and-Socket joint type
  78786. */
  78787. static BallAndSocketJoint: number;
  78788. /**
  78789. * Wheel-Joint type
  78790. */
  78791. static WheelJoint: number;
  78792. /**
  78793. * Slider-Joint type
  78794. */
  78795. static SliderJoint: number;
  78796. /**
  78797. * Prismatic-Joint type
  78798. */
  78799. static PrismaticJoint: number;
  78800. /**
  78801. * Universal-Joint type
  78802. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  78803. */
  78804. static UniversalJoint: number;
  78805. /**
  78806. * Hinge-Joint 2 type
  78807. */
  78808. static Hinge2Joint: number;
  78809. /**
  78810. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  78811. */
  78812. static PointToPointJoint: number;
  78813. /**
  78814. * Spring-Joint type
  78815. */
  78816. static SpringJoint: number;
  78817. /**
  78818. * Lock-Joint type
  78819. */
  78820. static LockJoint: number;
  78821. }
  78822. /**
  78823. * A class representing a physics distance joint
  78824. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78825. */
  78826. export class DistanceJoint extends PhysicsJoint {
  78827. /**
  78828. *
  78829. * @param jointData The data for the Distance-Joint
  78830. */
  78831. constructor(jointData: DistanceJointData);
  78832. /**
  78833. * Update the predefined distance.
  78834. * @param maxDistance The maximum preferred distance
  78835. * @param minDistance The minimum preferred distance
  78836. */
  78837. updateDistance(maxDistance: number, minDistance?: number): void;
  78838. }
  78839. /**
  78840. * Represents a Motor-Enabled Joint
  78841. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78842. */
  78843. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  78844. /**
  78845. * Initializes the Motor-Enabled Joint
  78846. * @param type The type of the joint
  78847. * @param jointData The physica joint data for the joint
  78848. */
  78849. constructor(type: number, jointData: PhysicsJointData);
  78850. /**
  78851. * Set the motor values.
  78852. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78853. * @param force the force to apply
  78854. * @param maxForce max force for this motor.
  78855. */
  78856. setMotor(force?: number, maxForce?: number): void;
  78857. /**
  78858. * Set the motor's limits.
  78859. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78860. * @param upperLimit The upper limit of the motor
  78861. * @param lowerLimit The lower limit of the motor
  78862. */
  78863. setLimit(upperLimit: number, lowerLimit?: number): void;
  78864. }
  78865. /**
  78866. * This class represents a single physics Hinge-Joint
  78867. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78868. */
  78869. export class HingeJoint extends MotorEnabledJoint {
  78870. /**
  78871. * Initializes the Hinge-Joint
  78872. * @param jointData The joint data for the Hinge-Joint
  78873. */
  78874. constructor(jointData: PhysicsJointData);
  78875. /**
  78876. * Set the motor values.
  78877. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78878. * @param {number} force the force to apply
  78879. * @param {number} maxForce max force for this motor.
  78880. */
  78881. setMotor(force?: number, maxForce?: number): void;
  78882. /**
  78883. * Set the motor's limits.
  78884. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78885. * @param upperLimit The upper limit of the motor
  78886. * @param lowerLimit The lower limit of the motor
  78887. */
  78888. setLimit(upperLimit: number, lowerLimit?: number): void;
  78889. }
  78890. /**
  78891. * This class represents a dual hinge physics joint (same as wheel joint)
  78892. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78893. */
  78894. export class Hinge2Joint extends MotorEnabledJoint {
  78895. /**
  78896. * Initializes the Hinge2-Joint
  78897. * @param jointData The joint data for the Hinge2-Joint
  78898. */
  78899. constructor(jointData: PhysicsJointData);
  78900. /**
  78901. * Set the motor values.
  78902. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78903. * @param {number} targetSpeed the speed the motor is to reach
  78904. * @param {number} maxForce max force for this motor.
  78905. * @param {motorIndex} the motor's index, 0 or 1.
  78906. */
  78907. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  78908. /**
  78909. * Set the motor limits.
  78910. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78911. * @param {number} upperLimit the upper limit
  78912. * @param {number} lowerLimit lower limit
  78913. * @param {motorIndex} the motor's index, 0 or 1.
  78914. */
  78915. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  78916. }
  78917. /**
  78918. * Interface for a motor enabled joint
  78919. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78920. */
  78921. export interface IMotorEnabledJoint {
  78922. /**
  78923. * Physics joint
  78924. */
  78925. physicsJoint: any;
  78926. /**
  78927. * Sets the motor of the motor-enabled joint
  78928. * @param force The force of the motor
  78929. * @param maxForce The maximum force of the motor
  78930. * @param motorIndex The index of the motor
  78931. */
  78932. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  78933. /**
  78934. * Sets the limit of the motor
  78935. * @param upperLimit The upper limit of the motor
  78936. * @param lowerLimit The lower limit of the motor
  78937. * @param motorIndex The index of the motor
  78938. */
  78939. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  78940. }
  78941. /**
  78942. * Joint data for a Distance-Joint
  78943. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78944. */
  78945. export interface DistanceJointData extends PhysicsJointData {
  78946. /**
  78947. * Max distance the 2 joint objects can be apart
  78948. */
  78949. maxDistance: number;
  78950. }
  78951. /**
  78952. * Joint data from a spring joint
  78953. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78954. */
  78955. export interface SpringJointData extends PhysicsJointData {
  78956. /**
  78957. * Length of the spring
  78958. */
  78959. length: number;
  78960. /**
  78961. * Stiffness of the spring
  78962. */
  78963. stiffness: number;
  78964. /**
  78965. * Damping of the spring
  78966. */
  78967. damping: number;
  78968. /** this callback will be called when applying the force to the impostors. */
  78969. forceApplicationCallback: () => void;
  78970. }
  78971. }
  78972. declare module BABYLON {
  78973. /**
  78974. * Holds the data for the raycast result
  78975. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78976. */
  78977. export class PhysicsRaycastResult {
  78978. private _hasHit;
  78979. private _hitDistance;
  78980. private _hitNormalWorld;
  78981. private _hitPointWorld;
  78982. private _rayFromWorld;
  78983. private _rayToWorld;
  78984. /**
  78985. * Gets if there was a hit
  78986. */
  78987. readonly hasHit: boolean;
  78988. /**
  78989. * Gets the distance from the hit
  78990. */
  78991. readonly hitDistance: number;
  78992. /**
  78993. * Gets the hit normal/direction in the world
  78994. */
  78995. readonly hitNormalWorld: Vector3;
  78996. /**
  78997. * Gets the hit point in the world
  78998. */
  78999. readonly hitPointWorld: Vector3;
  79000. /**
  79001. * Gets the ray "start point" of the ray in the world
  79002. */
  79003. readonly rayFromWorld: Vector3;
  79004. /**
  79005. * Gets the ray "end point" of the ray in the world
  79006. */
  79007. readonly rayToWorld: Vector3;
  79008. /**
  79009. * Sets the hit data (normal & point in world space)
  79010. * @param hitNormalWorld defines the normal in world space
  79011. * @param hitPointWorld defines the point in world space
  79012. */
  79013. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  79014. /**
  79015. * Sets the distance from the start point to the hit point
  79016. * @param distance
  79017. */
  79018. setHitDistance(distance: number): void;
  79019. /**
  79020. * Calculates the distance manually
  79021. */
  79022. calculateHitDistance(): void;
  79023. /**
  79024. * Resets all the values to default
  79025. * @param from The from point on world space
  79026. * @param to The to point on world space
  79027. */
  79028. reset(from?: Vector3, to?: Vector3): void;
  79029. }
  79030. /**
  79031. * Interface for the size containing width and height
  79032. */
  79033. interface IXYZ {
  79034. /**
  79035. * X
  79036. */
  79037. x: number;
  79038. /**
  79039. * Y
  79040. */
  79041. y: number;
  79042. /**
  79043. * Z
  79044. */
  79045. z: number;
  79046. }
  79047. }
  79048. declare module BABYLON {
  79049. /**
  79050. * Interface used to describe a physics joint
  79051. */
  79052. export interface PhysicsImpostorJoint {
  79053. /** Defines the main impostor to which the joint is linked */
  79054. mainImpostor: PhysicsImpostor;
  79055. /** Defines the impostor that is connected to the main impostor using this joint */
  79056. connectedImpostor: PhysicsImpostor;
  79057. /** Defines the joint itself */
  79058. joint: PhysicsJoint;
  79059. }
  79060. /** @hidden */
  79061. export interface IPhysicsEnginePlugin {
  79062. world: any;
  79063. name: string;
  79064. setGravity(gravity: Vector3): void;
  79065. setTimeStep(timeStep: number): void;
  79066. getTimeStep(): number;
  79067. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  79068. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  79069. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  79070. generatePhysicsBody(impostor: PhysicsImpostor): void;
  79071. removePhysicsBody(impostor: PhysicsImpostor): void;
  79072. generateJoint(joint: PhysicsImpostorJoint): void;
  79073. removeJoint(joint: PhysicsImpostorJoint): void;
  79074. isSupported(): boolean;
  79075. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  79076. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  79077. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  79078. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  79079. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  79080. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  79081. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  79082. getBodyMass(impostor: PhysicsImpostor): number;
  79083. getBodyFriction(impostor: PhysicsImpostor): number;
  79084. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  79085. getBodyRestitution(impostor: PhysicsImpostor): number;
  79086. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  79087. getBodyPressure?(impostor: PhysicsImpostor): number;
  79088. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  79089. getBodyStiffness?(impostor: PhysicsImpostor): number;
  79090. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  79091. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  79092. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  79093. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  79094. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  79095. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  79096. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  79097. sleepBody(impostor: PhysicsImpostor): void;
  79098. wakeUpBody(impostor: PhysicsImpostor): void;
  79099. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  79100. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  79101. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  79102. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  79103. getRadius(impostor: PhysicsImpostor): number;
  79104. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  79105. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  79106. dispose(): void;
  79107. }
  79108. /**
  79109. * Interface used to define a physics engine
  79110. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  79111. */
  79112. export interface IPhysicsEngine {
  79113. /**
  79114. * Gets the gravity vector used by the simulation
  79115. */
  79116. gravity: Vector3;
  79117. /**
  79118. * Sets the gravity vector used by the simulation
  79119. * @param gravity defines the gravity vector to use
  79120. */
  79121. setGravity(gravity: Vector3): void;
  79122. /**
  79123. * Set the time step of the physics engine.
  79124. * Default is 1/60.
  79125. * To slow it down, enter 1/600 for example.
  79126. * To speed it up, 1/30
  79127. * @param newTimeStep the new timestep to apply to this world.
  79128. */
  79129. setTimeStep(newTimeStep: number): void;
  79130. /**
  79131. * Get the time step of the physics engine.
  79132. * @returns the current time step
  79133. */
  79134. getTimeStep(): number;
  79135. /**
  79136. * Release all resources
  79137. */
  79138. dispose(): void;
  79139. /**
  79140. * Gets the name of the current physics plugin
  79141. * @returns the name of the plugin
  79142. */
  79143. getPhysicsPluginName(): string;
  79144. /**
  79145. * Adding a new impostor for the impostor tracking.
  79146. * This will be done by the impostor itself.
  79147. * @param impostor the impostor to add
  79148. */
  79149. addImpostor(impostor: PhysicsImpostor): void;
  79150. /**
  79151. * Remove an impostor from the engine.
  79152. * This impostor and its mesh will not longer be updated by the physics engine.
  79153. * @param impostor the impostor to remove
  79154. */
  79155. removeImpostor(impostor: PhysicsImpostor): void;
  79156. /**
  79157. * Add a joint to the physics engine
  79158. * @param mainImpostor defines the main impostor to which the joint is added.
  79159. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  79160. * @param joint defines the joint that will connect both impostors.
  79161. */
  79162. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  79163. /**
  79164. * Removes a joint from the simulation
  79165. * @param mainImpostor defines the impostor used with the joint
  79166. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  79167. * @param joint defines the joint to remove
  79168. */
  79169. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  79170. /**
  79171. * Gets the current plugin used to run the simulation
  79172. * @returns current plugin
  79173. */
  79174. getPhysicsPlugin(): IPhysicsEnginePlugin;
  79175. /**
  79176. * Gets the list of physic impostors
  79177. * @returns an array of PhysicsImpostor
  79178. */
  79179. getImpostors(): Array<PhysicsImpostor>;
  79180. /**
  79181. * Gets the impostor for a physics enabled object
  79182. * @param object defines the object impersonated by the impostor
  79183. * @returns the PhysicsImpostor or null if not found
  79184. */
  79185. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  79186. /**
  79187. * Gets the impostor for a physics body object
  79188. * @param body defines physics body used by the impostor
  79189. * @returns the PhysicsImpostor or null if not found
  79190. */
  79191. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  79192. /**
  79193. * Does a raycast in the physics world
  79194. * @param from when should the ray start?
  79195. * @param to when should the ray end?
  79196. * @returns PhysicsRaycastResult
  79197. */
  79198. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  79199. /**
  79200. * Called by the scene. No need to call it.
  79201. * @param delta defines the timespam between frames
  79202. */
  79203. _step(delta: number): void;
  79204. }
  79205. }
  79206. declare module BABYLON {
  79207. /**
  79208. * The interface for the physics imposter parameters
  79209. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79210. */
  79211. export interface PhysicsImpostorParameters {
  79212. /**
  79213. * The mass of the physics imposter
  79214. */
  79215. mass: number;
  79216. /**
  79217. * The friction of the physics imposter
  79218. */
  79219. friction?: number;
  79220. /**
  79221. * The coefficient of restitution of the physics imposter
  79222. */
  79223. restitution?: number;
  79224. /**
  79225. * The native options of the physics imposter
  79226. */
  79227. nativeOptions?: any;
  79228. /**
  79229. * Specifies if the parent should be ignored
  79230. */
  79231. ignoreParent?: boolean;
  79232. /**
  79233. * Specifies if bi-directional transformations should be disabled
  79234. */
  79235. disableBidirectionalTransformation?: boolean;
  79236. /**
  79237. * The pressure inside the physics imposter, soft object only
  79238. */
  79239. pressure?: number;
  79240. /**
  79241. * The stiffness the physics imposter, soft object only
  79242. */
  79243. stiffness?: number;
  79244. /**
  79245. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  79246. */
  79247. velocityIterations?: number;
  79248. /**
  79249. * The number of iterations used in maintaining consistent vertex positions, soft object only
  79250. */
  79251. positionIterations?: number;
  79252. /**
  79253. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  79254. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  79255. * Add to fix multiple points
  79256. */
  79257. fixedPoints?: number;
  79258. /**
  79259. * The collision margin around a soft object
  79260. */
  79261. margin?: number;
  79262. /**
  79263. * The collision margin around a soft object
  79264. */
  79265. damping?: number;
  79266. /**
  79267. * The path for a rope based on an extrusion
  79268. */
  79269. path?: any;
  79270. /**
  79271. * The shape of an extrusion used for a rope based on an extrusion
  79272. */
  79273. shape?: any;
  79274. }
  79275. /**
  79276. * Interface for a physics-enabled object
  79277. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79278. */
  79279. export interface IPhysicsEnabledObject {
  79280. /**
  79281. * The position of the physics-enabled object
  79282. */
  79283. position: Vector3;
  79284. /**
  79285. * The rotation of the physics-enabled object
  79286. */
  79287. rotationQuaternion: Nullable<Quaternion>;
  79288. /**
  79289. * The scale of the physics-enabled object
  79290. */
  79291. scaling: Vector3;
  79292. /**
  79293. * The rotation of the physics-enabled object
  79294. */
  79295. rotation?: Vector3;
  79296. /**
  79297. * The parent of the physics-enabled object
  79298. */
  79299. parent?: any;
  79300. /**
  79301. * The bounding info of the physics-enabled object
  79302. * @returns The bounding info of the physics-enabled object
  79303. */
  79304. getBoundingInfo(): BoundingInfo;
  79305. /**
  79306. * Computes the world matrix
  79307. * @param force Specifies if the world matrix should be computed by force
  79308. * @returns A world matrix
  79309. */
  79310. computeWorldMatrix(force: boolean): Matrix;
  79311. /**
  79312. * Gets the world matrix
  79313. * @returns A world matrix
  79314. */
  79315. getWorldMatrix?(): Matrix;
  79316. /**
  79317. * Gets the child meshes
  79318. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  79319. * @returns An array of abstract meshes
  79320. */
  79321. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  79322. /**
  79323. * Gets the vertex data
  79324. * @param kind The type of vertex data
  79325. * @returns A nullable array of numbers, or a float32 array
  79326. */
  79327. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  79328. /**
  79329. * Gets the indices from the mesh
  79330. * @returns A nullable array of index arrays
  79331. */
  79332. getIndices?(): Nullable<IndicesArray>;
  79333. /**
  79334. * Gets the scene from the mesh
  79335. * @returns the indices array or null
  79336. */
  79337. getScene?(): Scene;
  79338. /**
  79339. * Gets the absolute position from the mesh
  79340. * @returns the absolute position
  79341. */
  79342. getAbsolutePosition(): Vector3;
  79343. /**
  79344. * Gets the absolute pivot point from the mesh
  79345. * @returns the absolute pivot point
  79346. */
  79347. getAbsolutePivotPoint(): Vector3;
  79348. /**
  79349. * Rotates the mesh
  79350. * @param axis The axis of rotation
  79351. * @param amount The amount of rotation
  79352. * @param space The space of the rotation
  79353. * @returns The rotation transform node
  79354. */
  79355. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  79356. /**
  79357. * Translates the mesh
  79358. * @param axis The axis of translation
  79359. * @param distance The distance of translation
  79360. * @param space The space of the translation
  79361. * @returns The transform node
  79362. */
  79363. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  79364. /**
  79365. * Sets the absolute position of the mesh
  79366. * @param absolutePosition The absolute position of the mesh
  79367. * @returns The transform node
  79368. */
  79369. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  79370. /**
  79371. * Gets the class name of the mesh
  79372. * @returns The class name
  79373. */
  79374. getClassName(): string;
  79375. }
  79376. /**
  79377. * Represents a physics imposter
  79378. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79379. */
  79380. export class PhysicsImpostor {
  79381. /**
  79382. * The physics-enabled object used as the physics imposter
  79383. */
  79384. object: IPhysicsEnabledObject;
  79385. /**
  79386. * The type of the physics imposter
  79387. */
  79388. type: number;
  79389. private _options;
  79390. private _scene?;
  79391. /**
  79392. * The default object size of the imposter
  79393. */
  79394. static DEFAULT_OBJECT_SIZE: Vector3;
  79395. /**
  79396. * The identity quaternion of the imposter
  79397. */
  79398. static IDENTITY_QUATERNION: Quaternion;
  79399. /** @hidden */
  79400. _pluginData: any;
  79401. private _physicsEngine;
  79402. private _physicsBody;
  79403. private _bodyUpdateRequired;
  79404. private _onBeforePhysicsStepCallbacks;
  79405. private _onAfterPhysicsStepCallbacks;
  79406. /** @hidden */
  79407. _onPhysicsCollideCallbacks: Array<{
  79408. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  79409. otherImpostors: Array<PhysicsImpostor>;
  79410. }>;
  79411. private _deltaPosition;
  79412. private _deltaRotation;
  79413. private _deltaRotationConjugated;
  79414. /** hidden */
  79415. _isFromLine: boolean;
  79416. private _parent;
  79417. private _isDisposed;
  79418. private static _tmpVecs;
  79419. private static _tmpQuat;
  79420. /**
  79421. * Specifies if the physics imposter is disposed
  79422. */
  79423. readonly isDisposed: boolean;
  79424. /**
  79425. * Gets the mass of the physics imposter
  79426. */
  79427. mass: number;
  79428. /**
  79429. * Gets the coefficient of friction
  79430. */
  79431. /**
  79432. * Sets the coefficient of friction
  79433. */
  79434. friction: number;
  79435. /**
  79436. * Gets the coefficient of restitution
  79437. */
  79438. /**
  79439. * Sets the coefficient of restitution
  79440. */
  79441. restitution: number;
  79442. /**
  79443. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  79444. */
  79445. /**
  79446. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  79447. */
  79448. pressure: number;
  79449. /**
  79450. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  79451. */
  79452. /**
  79453. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  79454. */
  79455. stiffness: number;
  79456. /**
  79457. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  79458. */
  79459. /**
  79460. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  79461. */
  79462. velocityIterations: number;
  79463. /**
  79464. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  79465. */
  79466. /**
  79467. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  79468. */
  79469. positionIterations: number;
  79470. /**
  79471. * The unique id of the physics imposter
  79472. * set by the physics engine when adding this impostor to the array
  79473. */
  79474. uniqueId: number;
  79475. /**
  79476. * @hidden
  79477. */
  79478. soft: boolean;
  79479. /**
  79480. * @hidden
  79481. */
  79482. segments: number;
  79483. private _joints;
  79484. /**
  79485. * Initializes the physics imposter
  79486. * @param object The physics-enabled object used as the physics imposter
  79487. * @param type The type of the physics imposter
  79488. * @param _options The options for the physics imposter
  79489. * @param _scene The Babylon scene
  79490. */
  79491. constructor(
  79492. /**
  79493. * The physics-enabled object used as the physics imposter
  79494. */
  79495. object: IPhysicsEnabledObject,
  79496. /**
  79497. * The type of the physics imposter
  79498. */
  79499. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  79500. /**
  79501. * This function will completly initialize this impostor.
  79502. * It will create a new body - but only if this mesh has no parent.
  79503. * If it has, this impostor will not be used other than to define the impostor
  79504. * of the child mesh.
  79505. * @hidden
  79506. */
  79507. _init(): void;
  79508. private _getPhysicsParent;
  79509. /**
  79510. * Should a new body be generated.
  79511. * @returns boolean specifying if body initialization is required
  79512. */
  79513. isBodyInitRequired(): boolean;
  79514. /**
  79515. * Sets the updated scaling
  79516. * @param updated Specifies if the scaling is updated
  79517. */
  79518. setScalingUpdated(): void;
  79519. /**
  79520. * Force a regeneration of this or the parent's impostor's body.
  79521. * Use under cautious - This will remove all joints already implemented.
  79522. */
  79523. forceUpdate(): void;
  79524. /**
  79525. * Gets the body that holds this impostor. Either its own, or its parent.
  79526. */
  79527. /**
  79528. * Set the physics body. Used mainly by the physics engine/plugin
  79529. */
  79530. physicsBody: any;
  79531. /**
  79532. * Get the parent of the physics imposter
  79533. * @returns Physics imposter or null
  79534. */
  79535. /**
  79536. * Sets the parent of the physics imposter
  79537. */
  79538. parent: Nullable<PhysicsImpostor>;
  79539. /**
  79540. * Resets the update flags
  79541. */
  79542. resetUpdateFlags(): void;
  79543. /**
  79544. * Gets the object extend size
  79545. * @returns the object extend size
  79546. */
  79547. getObjectExtendSize(): Vector3;
  79548. /**
  79549. * Gets the object center
  79550. * @returns The object center
  79551. */
  79552. getObjectCenter(): Vector3;
  79553. /**
  79554. * Get a specific parametes from the options parameter
  79555. * @param paramName The object parameter name
  79556. * @returns The object parameter
  79557. */
  79558. getParam(paramName: string): any;
  79559. /**
  79560. * Sets a specific parameter in the options given to the physics plugin
  79561. * @param paramName The parameter name
  79562. * @param value The value of the parameter
  79563. */
  79564. setParam(paramName: string, value: number): void;
  79565. /**
  79566. * Specifically change the body's mass option. Won't recreate the physics body object
  79567. * @param mass The mass of the physics imposter
  79568. */
  79569. setMass(mass: number): void;
  79570. /**
  79571. * Gets the linear velocity
  79572. * @returns linear velocity or null
  79573. */
  79574. getLinearVelocity(): Nullable<Vector3>;
  79575. /**
  79576. * Sets the linear velocity
  79577. * @param velocity linear velocity or null
  79578. */
  79579. setLinearVelocity(velocity: Nullable<Vector3>): void;
  79580. /**
  79581. * Gets the angular velocity
  79582. * @returns angular velocity or null
  79583. */
  79584. getAngularVelocity(): Nullable<Vector3>;
  79585. /**
  79586. * Sets the angular velocity
  79587. * @param velocity The velocity or null
  79588. */
  79589. setAngularVelocity(velocity: Nullable<Vector3>): void;
  79590. /**
  79591. * Execute a function with the physics plugin native code
  79592. * Provide a function the will have two variables - the world object and the physics body object
  79593. * @param func The function to execute with the physics plugin native code
  79594. */
  79595. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  79596. /**
  79597. * Register a function that will be executed before the physics world is stepping forward
  79598. * @param func The function to execute before the physics world is stepped forward
  79599. */
  79600. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  79601. /**
  79602. * Unregister a function that will be executed before the physics world is stepping forward
  79603. * @param func The function to execute before the physics world is stepped forward
  79604. */
  79605. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  79606. /**
  79607. * Register a function that will be executed after the physics step
  79608. * @param func The function to execute after physics step
  79609. */
  79610. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  79611. /**
  79612. * Unregisters a function that will be executed after the physics step
  79613. * @param func The function to execute after physics step
  79614. */
  79615. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  79616. /**
  79617. * register a function that will be executed when this impostor collides against a different body
  79618. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  79619. * @param func Callback that is executed on collision
  79620. */
  79621. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  79622. /**
  79623. * Unregisters the physics imposter on contact
  79624. * @param collideAgainst The physics object to collide against
  79625. * @param func Callback to execute on collision
  79626. */
  79627. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  79628. private _tmpQuat;
  79629. private _tmpQuat2;
  79630. /**
  79631. * Get the parent rotation
  79632. * @returns The parent rotation
  79633. */
  79634. getParentsRotation(): Quaternion;
  79635. /**
  79636. * this function is executed by the physics engine.
  79637. */
  79638. beforeStep: () => void;
  79639. /**
  79640. * this function is executed by the physics engine
  79641. */
  79642. afterStep: () => void;
  79643. /**
  79644. * Legacy collision detection event support
  79645. */
  79646. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  79647. /**
  79648. * event and body object due to cannon's event-based architecture.
  79649. */
  79650. onCollide: (e: {
  79651. body: any;
  79652. }) => void;
  79653. /**
  79654. * Apply a force
  79655. * @param force The force to apply
  79656. * @param contactPoint The contact point for the force
  79657. * @returns The physics imposter
  79658. */
  79659. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  79660. /**
  79661. * Apply an impulse
  79662. * @param force The impulse force
  79663. * @param contactPoint The contact point for the impulse force
  79664. * @returns The physics imposter
  79665. */
  79666. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  79667. /**
  79668. * A help function to create a joint
  79669. * @param otherImpostor A physics imposter used to create a joint
  79670. * @param jointType The type of joint
  79671. * @param jointData The data for the joint
  79672. * @returns The physics imposter
  79673. */
  79674. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  79675. /**
  79676. * Add a joint to this impostor with a different impostor
  79677. * @param otherImpostor A physics imposter used to add a joint
  79678. * @param joint The joint to add
  79679. * @returns The physics imposter
  79680. */
  79681. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  79682. /**
  79683. * Add an anchor to a cloth impostor
  79684. * @param otherImpostor rigid impostor to anchor to
  79685. * @param width ratio across width from 0 to 1
  79686. * @param height ratio up height from 0 to 1
  79687. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  79688. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  79689. * @returns impostor the soft imposter
  79690. */
  79691. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  79692. /**
  79693. * Add a hook to a rope impostor
  79694. * @param otherImpostor rigid impostor to anchor to
  79695. * @param length ratio across rope from 0 to 1
  79696. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  79697. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  79698. * @returns impostor the rope imposter
  79699. */
  79700. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  79701. /**
  79702. * Will keep this body still, in a sleep mode.
  79703. * @returns the physics imposter
  79704. */
  79705. sleep(): PhysicsImpostor;
  79706. /**
  79707. * Wake the body up.
  79708. * @returns The physics imposter
  79709. */
  79710. wakeUp(): PhysicsImpostor;
  79711. /**
  79712. * Clones the physics imposter
  79713. * @param newObject The physics imposter clones to this physics-enabled object
  79714. * @returns A nullable physics imposter
  79715. */
  79716. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  79717. /**
  79718. * Disposes the physics imposter
  79719. */
  79720. dispose(): void;
  79721. /**
  79722. * Sets the delta position
  79723. * @param position The delta position amount
  79724. */
  79725. setDeltaPosition(position: Vector3): void;
  79726. /**
  79727. * Sets the delta rotation
  79728. * @param rotation The delta rotation amount
  79729. */
  79730. setDeltaRotation(rotation: Quaternion): void;
  79731. /**
  79732. * Gets the box size of the physics imposter and stores the result in the input parameter
  79733. * @param result Stores the box size
  79734. * @returns The physics imposter
  79735. */
  79736. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  79737. /**
  79738. * Gets the radius of the physics imposter
  79739. * @returns Radius of the physics imposter
  79740. */
  79741. getRadius(): number;
  79742. /**
  79743. * Sync a bone with this impostor
  79744. * @param bone The bone to sync to the impostor.
  79745. * @param boneMesh The mesh that the bone is influencing.
  79746. * @param jointPivot The pivot of the joint / bone in local space.
  79747. * @param distToJoint Optional distance from the impostor to the joint.
  79748. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  79749. */
  79750. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  79751. /**
  79752. * Sync impostor to a bone
  79753. * @param bone The bone that the impostor will be synced to.
  79754. * @param boneMesh The mesh that the bone is influencing.
  79755. * @param jointPivot The pivot of the joint / bone in local space.
  79756. * @param distToJoint Optional distance from the impostor to the joint.
  79757. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  79758. * @param boneAxis Optional vector3 axis the bone is aligned with
  79759. */
  79760. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  79761. /**
  79762. * No-Imposter type
  79763. */
  79764. static NoImpostor: number;
  79765. /**
  79766. * Sphere-Imposter type
  79767. */
  79768. static SphereImpostor: number;
  79769. /**
  79770. * Box-Imposter type
  79771. */
  79772. static BoxImpostor: number;
  79773. /**
  79774. * Plane-Imposter type
  79775. */
  79776. static PlaneImpostor: number;
  79777. /**
  79778. * Mesh-imposter type
  79779. */
  79780. static MeshImpostor: number;
  79781. /**
  79782. * Cylinder-Imposter type
  79783. */
  79784. static CylinderImpostor: number;
  79785. /**
  79786. * Particle-Imposter type
  79787. */
  79788. static ParticleImpostor: number;
  79789. /**
  79790. * Heightmap-Imposter type
  79791. */
  79792. static HeightmapImpostor: number;
  79793. /**
  79794. * ConvexHull-Impostor type (Ammo.js plugin only)
  79795. */
  79796. static ConvexHullImpostor: number;
  79797. /**
  79798. * Rope-Imposter type
  79799. */
  79800. static RopeImpostor: number;
  79801. /**
  79802. * Cloth-Imposter type
  79803. */
  79804. static ClothImpostor: number;
  79805. /**
  79806. * Softbody-Imposter type
  79807. */
  79808. static SoftbodyImpostor: number;
  79809. }
  79810. }
  79811. declare module BABYLON {
  79812. /**
  79813. * Class used to represent a specific level of detail of a mesh
  79814. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  79815. */
  79816. export class MeshLODLevel {
  79817. /** Defines the distance where this level should star being displayed */
  79818. distance: number;
  79819. /** Defines the mesh to use to render this level */
  79820. mesh: Nullable<Mesh>;
  79821. /**
  79822. * Creates a new LOD level
  79823. * @param distance defines the distance where this level should star being displayed
  79824. * @param mesh defines the mesh to use to render this level
  79825. */
  79826. constructor(
  79827. /** Defines the distance where this level should star being displayed */
  79828. distance: number,
  79829. /** Defines the mesh to use to render this level */
  79830. mesh: Nullable<Mesh>);
  79831. }
  79832. /**
  79833. * @hidden
  79834. **/
  79835. export class _CreationDataStorage {
  79836. closePath?: boolean;
  79837. closeArray?: boolean;
  79838. idx: number[];
  79839. dashSize: number;
  79840. gapSize: number;
  79841. path3D: Path3D;
  79842. pathArray: Vector3[][];
  79843. arc: number;
  79844. radius: number;
  79845. cap: number;
  79846. tessellation: number;
  79847. }
  79848. /**
  79849. * @hidden
  79850. **/
  79851. class _InstanceDataStorage {
  79852. visibleInstances: any;
  79853. batchCache: _InstancesBatch;
  79854. instancesBufferSize: number;
  79855. instancesBuffer: Nullable<Buffer>;
  79856. instancesData: Float32Array;
  79857. overridenInstanceCount: number;
  79858. isFrozen: boolean;
  79859. _previousBatch: _InstancesBatch;
  79860. hardwareInstancedRendering: boolean;
  79861. }
  79862. /**
  79863. * @hidden
  79864. **/
  79865. export class _InstancesBatch {
  79866. mustReturn: boolean;
  79867. visibleInstances: Nullable<InstancedMesh[]>[];
  79868. renderSelf: boolean[];
  79869. hardwareInstancedRendering: boolean[];
  79870. }
  79871. /**
  79872. * Class used to represent renderable models
  79873. */
  79874. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  79875. /**
  79876. * Mesh side orientation : usually the external or front surface
  79877. */
  79878. static readonly FRONTSIDE: number;
  79879. /**
  79880. * Mesh side orientation : usually the internal or back surface
  79881. */
  79882. static readonly BACKSIDE: number;
  79883. /**
  79884. * Mesh side orientation : both internal and external or front and back surfaces
  79885. */
  79886. static readonly DOUBLESIDE: number;
  79887. /**
  79888. * Mesh side orientation : by default, `FRONTSIDE`
  79889. */
  79890. static readonly DEFAULTSIDE: number;
  79891. /**
  79892. * Mesh cap setting : no cap
  79893. */
  79894. static readonly NO_CAP: number;
  79895. /**
  79896. * Mesh cap setting : one cap at the beginning of the mesh
  79897. */
  79898. static readonly CAP_START: number;
  79899. /**
  79900. * Mesh cap setting : one cap at the end of the mesh
  79901. */
  79902. static readonly CAP_END: number;
  79903. /**
  79904. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  79905. */
  79906. static readonly CAP_ALL: number;
  79907. /**
  79908. * Gets the default side orientation.
  79909. * @param orientation the orientation to value to attempt to get
  79910. * @returns the default orientation
  79911. * @hidden
  79912. */
  79913. static _GetDefaultSideOrientation(orientation?: number): number;
  79914. private _onBeforeRenderObservable;
  79915. private _onBeforeBindObservable;
  79916. private _onAfterRenderObservable;
  79917. private _onBeforeDrawObservable;
  79918. /**
  79919. * An event triggered before rendering the mesh
  79920. */
  79921. readonly onBeforeRenderObservable: Observable<Mesh>;
  79922. /**
  79923. * An event triggered before binding the mesh
  79924. */
  79925. readonly onBeforeBindObservable: Observable<Mesh>;
  79926. /**
  79927. * An event triggered after rendering the mesh
  79928. */
  79929. readonly onAfterRenderObservable: Observable<Mesh>;
  79930. /**
  79931. * An event triggered before drawing the mesh
  79932. */
  79933. readonly onBeforeDrawObservable: Observable<Mesh>;
  79934. private _onBeforeDrawObserver;
  79935. /**
  79936. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  79937. */
  79938. onBeforeDraw: () => void;
  79939. /**
  79940. * Gets the delay loading state of the mesh (when delay loading is turned on)
  79941. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  79942. */
  79943. delayLoadState: number;
  79944. /**
  79945. * Gets the list of instances created from this mesh
  79946. * it is not supposed to be modified manually.
  79947. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  79948. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  79949. */
  79950. instances: InstancedMesh[];
  79951. /**
  79952. * Gets the file containing delay loading data for this mesh
  79953. */
  79954. delayLoadingFile: string;
  79955. /** @hidden */
  79956. _binaryInfo: any;
  79957. private _LODLevels;
  79958. /**
  79959. * User defined function used to change how LOD level selection is done
  79960. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  79961. */
  79962. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  79963. private _morphTargetManager;
  79964. /**
  79965. * Gets or sets the morph target manager
  79966. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  79967. */
  79968. morphTargetManager: Nullable<MorphTargetManager>;
  79969. /** @hidden */
  79970. _creationDataStorage: Nullable<_CreationDataStorage>;
  79971. /** @hidden */
  79972. _geometry: Nullable<Geometry>;
  79973. /** @hidden */
  79974. _delayInfo: Array<string>;
  79975. /** @hidden */
  79976. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  79977. /** @hidden */
  79978. _instanceDataStorage: _InstanceDataStorage;
  79979. private _effectiveMaterial;
  79980. /** @hidden */
  79981. _shouldGenerateFlatShading: boolean;
  79982. private _preActivateId;
  79983. /** @hidden */
  79984. _originalBuilderSideOrientation: number;
  79985. /**
  79986. * Use this property to change the original side orientation defined at construction time
  79987. */
  79988. overrideMaterialSideOrientation: Nullable<number>;
  79989. private _areNormalsFrozen;
  79990. private _sourcePositions;
  79991. private _sourceNormals;
  79992. private _source;
  79993. private meshMap;
  79994. /**
  79995. * Gets the source mesh (the one used to clone this one from)
  79996. */
  79997. readonly source: Nullable<Mesh>;
  79998. /**
  79999. * Gets or sets a boolean indicating that this mesh does not use index buffer
  80000. */
  80001. isUnIndexed: boolean;
  80002. /**
  80003. * @constructor
  80004. * @param name The value used by scene.getMeshByName() to do a lookup.
  80005. * @param scene The scene to add this mesh to.
  80006. * @param parent The parent of this mesh, if it has one
  80007. * @param source An optional Mesh from which geometry is shared, cloned.
  80008. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  80009. * When false, achieved by calling a clone(), also passing False.
  80010. * This will make creation of children, recursive.
  80011. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  80012. */
  80013. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  80014. /**
  80015. * Gets the class name
  80016. * @returns the string "Mesh".
  80017. */
  80018. getClassName(): string;
  80019. /** @hidden */
  80020. readonly _isMesh: boolean;
  80021. /**
  80022. * Returns a description of this mesh
  80023. * @param fullDetails define if full details about this mesh must be used
  80024. * @returns a descriptive string representing this mesh
  80025. */
  80026. toString(fullDetails?: boolean): string;
  80027. /** @hidden */
  80028. _unBindEffect(): void;
  80029. /**
  80030. * Gets a boolean indicating if this mesh has LOD
  80031. */
  80032. readonly hasLODLevels: boolean;
  80033. /**
  80034. * Gets the list of MeshLODLevel associated with the current mesh
  80035. * @returns an array of MeshLODLevel
  80036. */
  80037. getLODLevels(): MeshLODLevel[];
  80038. private _sortLODLevels;
  80039. /**
  80040. * Add a mesh as LOD level triggered at the given distance.
  80041. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80042. * @param distance The distance from the center of the object to show this level
  80043. * @param mesh The mesh to be added as LOD level (can be null)
  80044. * @return This mesh (for chaining)
  80045. */
  80046. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  80047. /**
  80048. * Returns the LOD level mesh at the passed distance or null if not found.
  80049. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80050. * @param distance The distance from the center of the object to show this level
  80051. * @returns a Mesh or `null`
  80052. */
  80053. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  80054. /**
  80055. * Remove a mesh from the LOD array
  80056. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80057. * @param mesh defines the mesh to be removed
  80058. * @return This mesh (for chaining)
  80059. */
  80060. removeLODLevel(mesh: Mesh): Mesh;
  80061. /**
  80062. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  80063. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80064. * @param camera defines the camera to use to compute distance
  80065. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  80066. * @return This mesh (for chaining)
  80067. */
  80068. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  80069. /**
  80070. * Gets the mesh internal Geometry object
  80071. */
  80072. readonly geometry: Nullable<Geometry>;
  80073. /**
  80074. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  80075. * @returns the total number of vertices
  80076. */
  80077. getTotalVertices(): number;
  80078. /**
  80079. * Returns the content of an associated vertex buffer
  80080. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  80081. * - VertexBuffer.PositionKind
  80082. * - VertexBuffer.UVKind
  80083. * - VertexBuffer.UV2Kind
  80084. * - VertexBuffer.UV3Kind
  80085. * - VertexBuffer.UV4Kind
  80086. * - VertexBuffer.UV5Kind
  80087. * - VertexBuffer.UV6Kind
  80088. * - VertexBuffer.ColorKind
  80089. * - VertexBuffer.MatricesIndicesKind
  80090. * - VertexBuffer.MatricesIndicesExtraKind
  80091. * - VertexBuffer.MatricesWeightsKind
  80092. * - VertexBuffer.MatricesWeightsExtraKind
  80093. * @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
  80094. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  80095. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  80096. */
  80097. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  80098. /**
  80099. * Returns the mesh VertexBuffer object from the requested `kind`
  80100. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  80101. * - VertexBuffer.PositionKind
  80102. * - VertexBuffer.UVKind
  80103. * - VertexBuffer.UV2Kind
  80104. * - VertexBuffer.UV3Kind
  80105. * - VertexBuffer.UV4Kind
  80106. * - VertexBuffer.UV5Kind
  80107. * - VertexBuffer.UV6Kind
  80108. * - VertexBuffer.ColorKind
  80109. * - VertexBuffer.MatricesIndicesKind
  80110. * - VertexBuffer.MatricesIndicesExtraKind
  80111. * - VertexBuffer.MatricesWeightsKind
  80112. * - VertexBuffer.MatricesWeightsExtraKind
  80113. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  80114. */
  80115. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  80116. /**
  80117. * Tests if a specific vertex buffer is associated with this mesh
  80118. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  80119. * - VertexBuffer.PositionKind
  80120. * - VertexBuffer.UVKind
  80121. * - VertexBuffer.UV2Kind
  80122. * - VertexBuffer.UV3Kind
  80123. * - VertexBuffer.UV4Kind
  80124. * - VertexBuffer.UV5Kind
  80125. * - VertexBuffer.UV6Kind
  80126. * - VertexBuffer.ColorKind
  80127. * - VertexBuffer.MatricesIndicesKind
  80128. * - VertexBuffer.MatricesIndicesExtraKind
  80129. * - VertexBuffer.MatricesWeightsKind
  80130. * - VertexBuffer.MatricesWeightsExtraKind
  80131. * @returns a boolean
  80132. */
  80133. isVerticesDataPresent(kind: string): boolean;
  80134. /**
  80135. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  80136. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  80137. * - VertexBuffer.PositionKind
  80138. * - VertexBuffer.UVKind
  80139. * - VertexBuffer.UV2Kind
  80140. * - VertexBuffer.UV3Kind
  80141. * - VertexBuffer.UV4Kind
  80142. * - VertexBuffer.UV5Kind
  80143. * - VertexBuffer.UV6Kind
  80144. * - VertexBuffer.ColorKind
  80145. * - VertexBuffer.MatricesIndicesKind
  80146. * - VertexBuffer.MatricesIndicesExtraKind
  80147. * - VertexBuffer.MatricesWeightsKind
  80148. * - VertexBuffer.MatricesWeightsExtraKind
  80149. * @returns a boolean
  80150. */
  80151. isVertexBufferUpdatable(kind: string): boolean;
  80152. /**
  80153. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  80154. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  80155. * - VertexBuffer.PositionKind
  80156. * - VertexBuffer.UVKind
  80157. * - VertexBuffer.UV2Kind
  80158. * - VertexBuffer.UV3Kind
  80159. * - VertexBuffer.UV4Kind
  80160. * - VertexBuffer.UV5Kind
  80161. * - VertexBuffer.UV6Kind
  80162. * - VertexBuffer.ColorKind
  80163. * - VertexBuffer.MatricesIndicesKind
  80164. * - VertexBuffer.MatricesIndicesExtraKind
  80165. * - VertexBuffer.MatricesWeightsKind
  80166. * - VertexBuffer.MatricesWeightsExtraKind
  80167. * @returns an array of strings
  80168. */
  80169. getVerticesDataKinds(): string[];
  80170. /**
  80171. * Returns a positive integer : the total number of indices in this mesh geometry.
  80172. * @returns the numner of indices or zero if the mesh has no geometry.
  80173. */
  80174. getTotalIndices(): number;
  80175. /**
  80176. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  80177. * @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.
  80178. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  80179. * @returns the indices array or an empty array if the mesh has no geometry
  80180. */
  80181. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  80182. readonly isBlocked: boolean;
  80183. /**
  80184. * Determine if the current mesh is ready to be rendered
  80185. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  80186. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  80187. * @returns true if all associated assets are ready (material, textures, shaders)
  80188. */
  80189. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  80190. /**
  80191. * 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.
  80192. */
  80193. readonly areNormalsFrozen: boolean;
  80194. /**
  80195. * 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.
  80196. * @returns the current mesh
  80197. */
  80198. freezeNormals(): Mesh;
  80199. /**
  80200. * 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
  80201. * @returns the current mesh
  80202. */
  80203. unfreezeNormals(): Mesh;
  80204. /**
  80205. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  80206. */
  80207. overridenInstanceCount: number;
  80208. /** @hidden */
  80209. _preActivate(): Mesh;
  80210. /** @hidden */
  80211. _preActivateForIntermediateRendering(renderId: number): Mesh;
  80212. /** @hidden */
  80213. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  80214. /**
  80215. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  80216. * This means the mesh underlying bounding box and sphere are recomputed.
  80217. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  80218. * @returns the current mesh
  80219. */
  80220. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  80221. /** @hidden */
  80222. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  80223. /**
  80224. * This function will subdivide the mesh into multiple submeshes
  80225. * @param count defines the expected number of submeshes
  80226. */
  80227. subdivide(count: number): void;
  80228. /**
  80229. * Copy a FloatArray into a specific associated vertex buffer
  80230. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  80231. * - VertexBuffer.PositionKind
  80232. * - VertexBuffer.UVKind
  80233. * - VertexBuffer.UV2Kind
  80234. * - VertexBuffer.UV3Kind
  80235. * - VertexBuffer.UV4Kind
  80236. * - VertexBuffer.UV5Kind
  80237. * - VertexBuffer.UV6Kind
  80238. * - VertexBuffer.ColorKind
  80239. * - VertexBuffer.MatricesIndicesKind
  80240. * - VertexBuffer.MatricesIndicesExtraKind
  80241. * - VertexBuffer.MatricesWeightsKind
  80242. * - VertexBuffer.MatricesWeightsExtraKind
  80243. * @param data defines the data source
  80244. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  80245. * @param stride defines the data stride size (can be null)
  80246. * @returns the current mesh
  80247. */
  80248. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  80249. /**
  80250. * Flags an associated vertex buffer as updatable
  80251. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  80252. * - VertexBuffer.PositionKind
  80253. * - VertexBuffer.UVKind
  80254. * - VertexBuffer.UV2Kind
  80255. * - VertexBuffer.UV3Kind
  80256. * - VertexBuffer.UV4Kind
  80257. * - VertexBuffer.UV5Kind
  80258. * - VertexBuffer.UV6Kind
  80259. * - VertexBuffer.ColorKind
  80260. * - VertexBuffer.MatricesIndicesKind
  80261. * - VertexBuffer.MatricesIndicesExtraKind
  80262. * - VertexBuffer.MatricesWeightsKind
  80263. * - VertexBuffer.MatricesWeightsExtraKind
  80264. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  80265. */
  80266. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  80267. /**
  80268. * Sets the mesh global Vertex Buffer
  80269. * @param buffer defines the buffer to use
  80270. * @returns the current mesh
  80271. */
  80272. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  80273. /**
  80274. * Update a specific associated vertex buffer
  80275. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  80276. * - VertexBuffer.PositionKind
  80277. * - VertexBuffer.UVKind
  80278. * - VertexBuffer.UV2Kind
  80279. * - VertexBuffer.UV3Kind
  80280. * - VertexBuffer.UV4Kind
  80281. * - VertexBuffer.UV5Kind
  80282. * - VertexBuffer.UV6Kind
  80283. * - VertexBuffer.ColorKind
  80284. * - VertexBuffer.MatricesIndicesKind
  80285. * - VertexBuffer.MatricesIndicesExtraKind
  80286. * - VertexBuffer.MatricesWeightsKind
  80287. * - VertexBuffer.MatricesWeightsExtraKind
  80288. * @param data defines the data source
  80289. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  80290. * @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)
  80291. * @returns the current mesh
  80292. */
  80293. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  80294. /**
  80295. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  80296. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  80297. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  80298. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  80299. * @returns the current mesh
  80300. */
  80301. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  80302. /**
  80303. * Creates a un-shared specific occurence of the geometry for the mesh.
  80304. * @returns the current mesh
  80305. */
  80306. makeGeometryUnique(): Mesh;
  80307. /**
  80308. * Set the index buffer of this mesh
  80309. * @param indices defines the source data
  80310. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  80311. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  80312. * @returns the current mesh
  80313. */
  80314. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  80315. /**
  80316. * Update the current index buffer
  80317. * @param indices defines the source data
  80318. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  80319. * @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)
  80320. * @returns the current mesh
  80321. */
  80322. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  80323. /**
  80324. * Invert the geometry to move from a right handed system to a left handed one.
  80325. * @returns the current mesh
  80326. */
  80327. toLeftHanded(): Mesh;
  80328. /** @hidden */
  80329. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  80330. /** @hidden */
  80331. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  80332. /**
  80333. * Registers for this mesh a javascript function called just before the rendering process
  80334. * @param func defines the function to call before rendering this mesh
  80335. * @returns the current mesh
  80336. */
  80337. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  80338. /**
  80339. * Disposes a previously registered javascript function called before the rendering
  80340. * @param func defines the function to remove
  80341. * @returns the current mesh
  80342. */
  80343. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  80344. /**
  80345. * Registers for this mesh a javascript function called just after the rendering is complete
  80346. * @param func defines the function to call after rendering this mesh
  80347. * @returns the current mesh
  80348. */
  80349. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  80350. /**
  80351. * Disposes a previously registered javascript function called after the rendering.
  80352. * @param func defines the function to remove
  80353. * @returns the current mesh
  80354. */
  80355. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  80356. /** @hidden */
  80357. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  80358. /** @hidden */
  80359. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  80360. /** @hidden */
  80361. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  80362. /** @hidden */
  80363. _freeze(): void;
  80364. /** @hidden */
  80365. _unFreeze(): void;
  80366. /**
  80367. * 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
  80368. * @param subMesh defines the subMesh to render
  80369. * @param enableAlphaMode defines if alpha mode can be changed
  80370. * @returns the current mesh
  80371. */
  80372. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  80373. private _onBeforeDraw;
  80374. /**
  80375. * Renormalize the mesh and patch it up if there are no weights
  80376. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  80377. * However in the case of zero weights then we set just a single influence to 1.
  80378. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  80379. */
  80380. cleanMatrixWeights(): void;
  80381. private normalizeSkinFourWeights;
  80382. private normalizeSkinWeightsAndExtra;
  80383. /**
  80384. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  80385. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  80386. * the user know there was an issue with importing the mesh
  80387. * @returns a validation object with skinned, valid and report string
  80388. */
  80389. validateSkinning(): {
  80390. skinned: boolean;
  80391. valid: boolean;
  80392. report: string;
  80393. };
  80394. /** @hidden */
  80395. _checkDelayState(): Mesh;
  80396. private _queueLoad;
  80397. /**
  80398. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  80399. * A mesh is in the frustum if its bounding box intersects the frustum
  80400. * @param frustumPlanes defines the frustum to test
  80401. * @returns true if the mesh is in the frustum planes
  80402. */
  80403. isInFrustum(frustumPlanes: Plane[]): boolean;
  80404. /**
  80405. * Sets the mesh material by the material or multiMaterial `id` property
  80406. * @param id is a string identifying the material or the multiMaterial
  80407. * @returns the current mesh
  80408. */
  80409. setMaterialByID(id: string): Mesh;
  80410. /**
  80411. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  80412. * @returns an array of IAnimatable
  80413. */
  80414. getAnimatables(): IAnimatable[];
  80415. /**
  80416. * Modifies the mesh geometry according to the passed transformation matrix.
  80417. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  80418. * The mesh normals are modified using the same transformation.
  80419. * Note that, under the hood, this method sets a new VertexBuffer each call.
  80420. * @param transform defines the transform matrix to use
  80421. * @see http://doc.babylonjs.com/resources/baking_transformations
  80422. * @returns the current mesh
  80423. */
  80424. bakeTransformIntoVertices(transform: Matrix): Mesh;
  80425. /**
  80426. * Modifies the mesh geometry according to its own current World Matrix.
  80427. * The mesh World Matrix is then reset.
  80428. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  80429. * Note that, under the hood, this method sets a new VertexBuffer each call.
  80430. * @see http://doc.babylonjs.com/resources/baking_transformations
  80431. * @returns the current mesh
  80432. */
  80433. bakeCurrentTransformIntoVertices(): Mesh;
  80434. /** @hidden */
  80435. readonly _positions: Nullable<Vector3[]>;
  80436. /** @hidden */
  80437. _resetPointsArrayCache(): Mesh;
  80438. /** @hidden */
  80439. _generatePointsArray(): boolean;
  80440. /**
  80441. * Returns a new Mesh object generated from the current mesh properties.
  80442. * This method must not get confused with createInstance()
  80443. * @param name is a string, the name given to the new mesh
  80444. * @param newParent can be any Node object (default `null`)
  80445. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  80446. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  80447. * @returns a new mesh
  80448. */
  80449. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  80450. /**
  80451. * Releases resources associated with this mesh.
  80452. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  80453. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  80454. */
  80455. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  80456. /**
  80457. * Modifies the mesh geometry according to a displacement map.
  80458. * 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.
  80459. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  80460. * @param url is a string, the URL from the image file is to be downloaded.
  80461. * @param minHeight is the lower limit of the displacement.
  80462. * @param maxHeight is the upper limit of the displacement.
  80463. * @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.
  80464. * @param uvOffset is an optional vector2 used to offset UV.
  80465. * @param uvScale is an optional vector2 used to scale UV.
  80466. * @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.
  80467. * @returns the Mesh.
  80468. */
  80469. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  80470. /**
  80471. * Modifies the mesh geometry according to a displacementMap buffer.
  80472. * 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.
  80473. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  80474. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  80475. * @param heightMapWidth is the width of the buffer image.
  80476. * @param heightMapHeight is the height of the buffer image.
  80477. * @param minHeight is the lower limit of the displacement.
  80478. * @param maxHeight is the upper limit of the displacement.
  80479. * @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.
  80480. * @param uvOffset is an optional vector2 used to offset UV.
  80481. * @param uvScale is an optional vector2 used to scale UV.
  80482. * @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.
  80483. * @returns the Mesh.
  80484. */
  80485. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  80486. /**
  80487. * Modify the mesh to get a flat shading rendering.
  80488. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  80489. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  80490. * @returns current mesh
  80491. */
  80492. convertToFlatShadedMesh(): Mesh;
  80493. /**
  80494. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  80495. * In other words, more vertices, no more indices and a single bigger VBO.
  80496. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  80497. * @returns current mesh
  80498. */
  80499. convertToUnIndexedMesh(): Mesh;
  80500. /**
  80501. * Inverses facet orientations.
  80502. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  80503. * @param flipNormals will also inverts the normals
  80504. * @returns current mesh
  80505. */
  80506. flipFaces(flipNormals?: boolean): Mesh;
  80507. /**
  80508. * Increase the number of facets and hence vertices in a mesh
  80509. * Vertex normals are interpolated from existing vertex normals
  80510. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  80511. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  80512. */
  80513. increaseVertices(numberPerEdge: number): void;
  80514. /**
  80515. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  80516. * This will undo any application of covertToFlatShadedMesh
  80517. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  80518. */
  80519. forceSharedVertices(): void;
  80520. /** @hidden */
  80521. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  80522. /** @hidden */
  80523. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  80524. /**
  80525. * Creates a new InstancedMesh object from the mesh model.
  80526. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  80527. * @param name defines the name of the new instance
  80528. * @returns a new InstancedMesh
  80529. */
  80530. createInstance(name: string): InstancedMesh;
  80531. /**
  80532. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  80533. * After this call, all the mesh instances have the same submeshes than the current mesh.
  80534. * @returns the current mesh
  80535. */
  80536. synchronizeInstances(): Mesh;
  80537. /**
  80538. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  80539. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  80540. * This should be used together with the simplification to avoid disappearing triangles.
  80541. * @param successCallback an optional success callback to be called after the optimization finished.
  80542. * @returns the current mesh
  80543. */
  80544. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  80545. /**
  80546. * Serialize current mesh
  80547. * @param serializationObject defines the object which will receive the serialization data
  80548. */
  80549. serialize(serializationObject: any): void;
  80550. /** @hidden */
  80551. _syncGeometryWithMorphTargetManager(): void;
  80552. /** @hidden */
  80553. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  80554. /**
  80555. * Returns a new Mesh object parsed from the source provided.
  80556. * @param parsedMesh is the source
  80557. * @param scene defines the hosting scene
  80558. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  80559. * @returns a new Mesh
  80560. */
  80561. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  80562. /**
  80563. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  80564. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  80565. * @param name defines the name of the mesh to create
  80566. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  80567. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  80568. * @param closePath creates a seam between the first and the last points of each path of the path array
  80569. * @param offset is taken in account only if the `pathArray` is containing a single path
  80570. * @param scene defines the hosting scene
  80571. * @param updatable defines if the mesh must be flagged as updatable
  80572. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80573. * @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)
  80574. * @returns a new Mesh
  80575. */
  80576. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  80577. /**
  80578. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  80579. * @param name defines the name of the mesh to create
  80580. * @param radius sets the radius size (float) of the polygon (default 0.5)
  80581. * @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
  80582. * @param scene defines the hosting scene
  80583. * @param updatable defines if the mesh must be flagged as updatable
  80584. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80585. * @returns a new Mesh
  80586. */
  80587. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  80588. /**
  80589. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  80590. * @param name defines the name of the mesh to create
  80591. * @param size sets the size (float) of each box side (default 1)
  80592. * @param scene defines the hosting scene
  80593. * @param updatable defines if the mesh must be flagged as updatable
  80594. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80595. * @returns a new Mesh
  80596. */
  80597. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  80598. /**
  80599. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  80600. * @param name defines the name of the mesh to create
  80601. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  80602. * @param diameter sets the diameter size (float) of the sphere (default 1)
  80603. * @param scene defines the hosting scene
  80604. * @param updatable defines if the mesh must be flagged as updatable
  80605. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80606. * @returns a new Mesh
  80607. */
  80608. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80609. /**
  80610. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  80611. * @param name defines the name of the mesh to create
  80612. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  80613. * @param diameter sets the diameter size (float) of the sphere (default 1)
  80614. * @param scene defines the hosting scene
  80615. * @returns a new Mesh
  80616. */
  80617. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  80618. /**
  80619. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  80620. * @param name defines the name of the mesh to create
  80621. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  80622. * @param diameterTop set the top cap diameter (floats, default 1)
  80623. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  80624. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  80625. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  80626. * @param scene defines the hosting scene
  80627. * @param updatable defines if the mesh must be flagged as updatable
  80628. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80629. * @returns a new Mesh
  80630. */
  80631. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  80632. /**
  80633. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  80634. * @param name defines the name of the mesh to create
  80635. * @param diameter sets the diameter size (float) of the torus (default 1)
  80636. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  80637. * @param tessellation sets the number of torus sides (postive integer, default 16)
  80638. * @param scene defines the hosting scene
  80639. * @param updatable defines if the mesh must be flagged as updatable
  80640. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80641. * @returns a new Mesh
  80642. */
  80643. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80644. /**
  80645. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  80646. * @param name defines the name of the mesh to create
  80647. * @param radius sets the global radius size (float) of the torus knot (default 2)
  80648. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  80649. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  80650. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  80651. * @param p the number of windings on X axis (positive integers, default 2)
  80652. * @param q the number of windings on Y axis (positive integers, default 3)
  80653. * @param scene defines the hosting scene
  80654. * @param updatable defines if the mesh must be flagged as updatable
  80655. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80656. * @returns a new Mesh
  80657. */
  80658. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80659. /**
  80660. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  80661. * @param name defines the name of the mesh to create
  80662. * @param points is an array successive Vector3
  80663. * @param scene defines the hosting scene
  80664. * @param updatable defines if the mesh must be flagged as updatable
  80665. * @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).
  80666. * @returns a new Mesh
  80667. */
  80668. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  80669. /**
  80670. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  80671. * @param name defines the name of the mesh to create
  80672. * @param points is an array successive Vector3
  80673. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  80674. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  80675. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  80676. * @param scene defines the hosting scene
  80677. * @param updatable defines if the mesh must be flagged as updatable
  80678. * @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)
  80679. * @returns a new Mesh
  80680. */
  80681. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  80682. /**
  80683. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  80684. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  80685. * 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.
  80686. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80687. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  80688. * Remember you can only change the shape positions, not their number when updating a polygon.
  80689. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  80690. * @param name defines the name of the mesh to create
  80691. * @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
  80692. * @param scene defines the hosting scene
  80693. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  80694. * @param updatable defines if the mesh must be flagged as updatable
  80695. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80696. * @param earcutInjection can be used to inject your own earcut reference
  80697. * @returns a new Mesh
  80698. */
  80699. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  80700. /**
  80701. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  80702. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  80703. * @param name defines the name of the mesh to create
  80704. * @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
  80705. * @param depth defines the height of extrusion
  80706. * @param scene defines the hosting scene
  80707. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  80708. * @param updatable defines if the mesh must be flagged as updatable
  80709. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80710. * @param earcutInjection can be used to inject your own earcut reference
  80711. * @returns a new Mesh
  80712. */
  80713. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  80714. /**
  80715. * Creates an extruded shape mesh.
  80716. * 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
  80717. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  80718. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  80719. * @param name defines the name of the mesh to create
  80720. * @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
  80721. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  80722. * @param scale is the value to scale the shape
  80723. * @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
  80724. * @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
  80725. * @param scene defines the hosting scene
  80726. * @param updatable defines if the mesh must be flagged as updatable
  80727. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80728. * @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)
  80729. * @returns a new Mesh
  80730. */
  80731. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  80732. /**
  80733. * Creates an custom extruded shape mesh.
  80734. * The custom extrusion is a parametric shape.
  80735. * It has no predefined shape. Its final shape will depend on the input parameters.
  80736. * Please consider using the same method from the MeshBuilder class instead
  80737. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  80738. * @param name defines the name of the mesh to create
  80739. * @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
  80740. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  80741. * @param scaleFunction is a custom Javascript function called on each path point
  80742. * @param rotationFunction is a custom Javascript function called on each path point
  80743. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  80744. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  80745. * @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
  80746. * @param scene defines the hosting scene
  80747. * @param updatable defines if the mesh must be flagged as updatable
  80748. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80749. * @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)
  80750. * @returns a new Mesh
  80751. */
  80752. 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;
  80753. /**
  80754. * Creates lathe mesh.
  80755. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  80756. * Please consider using the same method from the MeshBuilder class instead
  80757. * @param name defines the name of the mesh to create
  80758. * @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
  80759. * @param radius is the radius value of the lathe
  80760. * @param tessellation is the side number of the lathe.
  80761. * @param scene defines the hosting scene
  80762. * @param updatable defines if the mesh must be flagged as updatable
  80763. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80764. * @returns a new Mesh
  80765. */
  80766. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80767. /**
  80768. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  80769. * @param name defines the name of the mesh to create
  80770. * @param size sets the size (float) of both sides of the plane at once (default 1)
  80771. * @param scene defines the hosting scene
  80772. * @param updatable defines if the mesh must be flagged as updatable
  80773. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80774. * @returns a new Mesh
  80775. */
  80776. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80777. /**
  80778. * Creates a ground mesh.
  80779. * Please consider using the same method from the MeshBuilder class instead
  80780. * @param name defines the name of the mesh to create
  80781. * @param width set the width of the ground
  80782. * @param height set the height of the ground
  80783. * @param subdivisions sets the number of subdivisions per side
  80784. * @param scene defines the hosting scene
  80785. * @param updatable defines if the mesh must be flagged as updatable
  80786. * @returns a new Mesh
  80787. */
  80788. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  80789. /**
  80790. * Creates a tiled ground mesh.
  80791. * Please consider using the same method from the MeshBuilder class instead
  80792. * @param name defines the name of the mesh to create
  80793. * @param xmin set the ground minimum X coordinate
  80794. * @param zmin set the ground minimum Y coordinate
  80795. * @param xmax set the ground maximum X coordinate
  80796. * @param zmax set the ground maximum Z coordinate
  80797. * @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
  80798. * @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
  80799. * @param scene defines the hosting scene
  80800. * @param updatable defines if the mesh must be flagged as updatable
  80801. * @returns a new Mesh
  80802. */
  80803. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  80804. w: number;
  80805. h: number;
  80806. }, precision: {
  80807. w: number;
  80808. h: number;
  80809. }, scene: Scene, updatable?: boolean): Mesh;
  80810. /**
  80811. * Creates a ground mesh from a height map.
  80812. * Please consider using the same method from the MeshBuilder class instead
  80813. * @see http://doc.babylonjs.com/babylon101/height_map
  80814. * @param name defines the name of the mesh to create
  80815. * @param url sets the URL of the height map image resource
  80816. * @param width set the ground width size
  80817. * @param height set the ground height size
  80818. * @param subdivisions sets the number of subdivision per side
  80819. * @param minHeight is the minimum altitude on the ground
  80820. * @param maxHeight is the maximum altitude on the ground
  80821. * @param scene defines the hosting scene
  80822. * @param updatable defines if the mesh must be flagged as updatable
  80823. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  80824. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  80825. * @returns a new Mesh
  80826. */
  80827. 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;
  80828. /**
  80829. * Creates a tube mesh.
  80830. * The tube is a parametric shape.
  80831. * It has no predefined shape. Its final shape will depend on the input parameters.
  80832. * Please consider using the same method from the MeshBuilder class instead
  80833. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  80834. * @param name defines the name of the mesh to create
  80835. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  80836. * @param radius sets the tube radius size
  80837. * @param tessellation is the number of sides on the tubular surface
  80838. * @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
  80839. * @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
  80840. * @param scene defines the hosting scene
  80841. * @param updatable defines if the mesh must be flagged as updatable
  80842. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80843. * @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)
  80844. * @returns a new Mesh
  80845. */
  80846. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  80847. (i: number, distance: number): number;
  80848. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  80849. /**
  80850. * Creates a polyhedron mesh.
  80851. * Please consider using the same method from the MeshBuilder class instead.
  80852. * * 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
  80853. * * The parameter `size` (positive float, default 1) sets the polygon size
  80854. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  80855. * * 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`
  80856. * * 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
  80857. * * 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)`)
  80858. * * 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
  80859. * * 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
  80860. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80861. * * If you create a double-sided mesh, you can choose what parts of 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
  80862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80863. * @param name defines the name of the mesh to create
  80864. * @param options defines the options used to create the mesh
  80865. * @param scene defines the hosting scene
  80866. * @returns a new Mesh
  80867. */
  80868. static CreatePolyhedron(name: string, options: {
  80869. type?: number;
  80870. size?: number;
  80871. sizeX?: number;
  80872. sizeY?: number;
  80873. sizeZ?: number;
  80874. custom?: any;
  80875. faceUV?: Vector4[];
  80876. faceColors?: Color4[];
  80877. updatable?: boolean;
  80878. sideOrientation?: number;
  80879. }, scene: Scene): Mesh;
  80880. /**
  80881. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  80882. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  80883. * * 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`)
  80884. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  80885. * * 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
  80886. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80887. * * If you create a double-sided mesh, you can choose what parts of 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
  80888. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80889. * @param name defines the name of the mesh
  80890. * @param options defines the options used to create the mesh
  80891. * @param scene defines the hosting scene
  80892. * @returns a new Mesh
  80893. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  80894. */
  80895. static CreateIcoSphere(name: string, options: {
  80896. radius?: number;
  80897. flat?: boolean;
  80898. subdivisions?: number;
  80899. sideOrientation?: number;
  80900. updatable?: boolean;
  80901. }, scene: Scene): Mesh;
  80902. /**
  80903. * Creates a decal mesh.
  80904. * Please consider using the same method from the MeshBuilder class instead.
  80905. * A decal is a mesh usually applied as a model onto the surface of another mesh
  80906. * @param name defines the name of the mesh
  80907. * @param sourceMesh defines the mesh receiving the decal
  80908. * @param position sets the position of the decal in world coordinates
  80909. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  80910. * @param size sets the decal scaling
  80911. * @param angle sets the angle to rotate the decal
  80912. * @returns a new Mesh
  80913. */
  80914. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  80915. /**
  80916. * Prepare internal position array for software CPU skinning
  80917. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  80918. */
  80919. setPositionsForCPUSkinning(): Float32Array;
  80920. /**
  80921. * Prepare internal normal array for software CPU skinning
  80922. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  80923. */
  80924. setNormalsForCPUSkinning(): Float32Array;
  80925. /**
  80926. * Updates the vertex buffer by applying transformation from the bones
  80927. * @param skeleton defines the skeleton to apply to current mesh
  80928. * @returns the current mesh
  80929. */
  80930. applySkeleton(skeleton: Skeleton): Mesh;
  80931. /**
  80932. * 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
  80933. * @param meshes defines the list of meshes to scan
  80934. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  80935. */
  80936. static MinMax(meshes: AbstractMesh[]): {
  80937. min: Vector3;
  80938. max: Vector3;
  80939. };
  80940. /**
  80941. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  80942. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  80943. * @returns a vector3
  80944. */
  80945. static Center(meshesOrMinMaxVector: {
  80946. min: Vector3;
  80947. max: Vector3;
  80948. } | AbstractMesh[]): Vector3;
  80949. /**
  80950. * Merge the array of meshes into a single mesh for performance reasons.
  80951. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  80952. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  80953. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  80954. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  80955. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  80956. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  80957. * @returns a new mesh
  80958. */
  80959. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  80960. /** @hidden */
  80961. addInstance(instance: InstancedMesh): void;
  80962. /** @hidden */
  80963. removeInstance(instance: InstancedMesh): void;
  80964. }
  80965. }
  80966. declare module BABYLON {
  80967. /**
  80968. * Base class for the main features of a material in Babylon.js
  80969. */
  80970. export class Material implements IAnimatable {
  80971. /**
  80972. * Returns the triangle fill mode
  80973. */
  80974. static readonly TriangleFillMode: number;
  80975. /**
  80976. * Returns the wireframe mode
  80977. */
  80978. static readonly WireFrameFillMode: number;
  80979. /**
  80980. * Returns the point fill mode
  80981. */
  80982. static readonly PointFillMode: number;
  80983. /**
  80984. * Returns the point list draw mode
  80985. */
  80986. static readonly PointListDrawMode: number;
  80987. /**
  80988. * Returns the line list draw mode
  80989. */
  80990. static readonly LineListDrawMode: number;
  80991. /**
  80992. * Returns the line loop draw mode
  80993. */
  80994. static readonly LineLoopDrawMode: number;
  80995. /**
  80996. * Returns the line strip draw mode
  80997. */
  80998. static readonly LineStripDrawMode: number;
  80999. /**
  81000. * Returns the triangle strip draw mode
  81001. */
  81002. static readonly TriangleStripDrawMode: number;
  81003. /**
  81004. * Returns the triangle fan draw mode
  81005. */
  81006. static readonly TriangleFanDrawMode: number;
  81007. /**
  81008. * Stores the clock-wise side orientation
  81009. */
  81010. static readonly ClockWiseSideOrientation: number;
  81011. /**
  81012. * Stores the counter clock-wise side orientation
  81013. */
  81014. static readonly CounterClockWiseSideOrientation: number;
  81015. /**
  81016. * The dirty texture flag value
  81017. */
  81018. static readonly TextureDirtyFlag: number;
  81019. /**
  81020. * The dirty light flag value
  81021. */
  81022. static readonly LightDirtyFlag: number;
  81023. /**
  81024. * The dirty fresnel flag value
  81025. */
  81026. static readonly FresnelDirtyFlag: number;
  81027. /**
  81028. * The dirty attribute flag value
  81029. */
  81030. static readonly AttributesDirtyFlag: number;
  81031. /**
  81032. * The dirty misc flag value
  81033. */
  81034. static readonly MiscDirtyFlag: number;
  81035. /**
  81036. * The all dirty flag value
  81037. */
  81038. static readonly AllDirtyFlag: number;
  81039. /**
  81040. * The ID of the material
  81041. */
  81042. id: string;
  81043. /**
  81044. * Gets or sets the unique id of the material
  81045. */
  81046. uniqueId: number;
  81047. /**
  81048. * The name of the material
  81049. */
  81050. name: string;
  81051. /**
  81052. * Gets or sets user defined metadata
  81053. */
  81054. metadata: any;
  81055. /**
  81056. * For internal use only. Please do not use.
  81057. */
  81058. reservedDataStore: any;
  81059. /**
  81060. * Specifies if the ready state should be checked on each call
  81061. */
  81062. checkReadyOnEveryCall: boolean;
  81063. /**
  81064. * Specifies if the ready state should be checked once
  81065. */
  81066. checkReadyOnlyOnce: boolean;
  81067. /**
  81068. * The state of the material
  81069. */
  81070. state: string;
  81071. /**
  81072. * The alpha value of the material
  81073. */
  81074. protected _alpha: number;
  81075. /**
  81076. * List of inspectable custom properties (used by the Inspector)
  81077. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81078. */
  81079. inspectableCustomProperties: IInspectable[];
  81080. /**
  81081. * Sets the alpha value of the material
  81082. */
  81083. /**
  81084. * Gets the alpha value of the material
  81085. */
  81086. alpha: number;
  81087. /**
  81088. * Specifies if back face culling is enabled
  81089. */
  81090. protected _backFaceCulling: boolean;
  81091. /**
  81092. * Sets the back-face culling state
  81093. */
  81094. /**
  81095. * Gets the back-face culling state
  81096. */
  81097. backFaceCulling: boolean;
  81098. /**
  81099. * Stores the value for side orientation
  81100. */
  81101. sideOrientation: number;
  81102. /**
  81103. * Callback triggered when the material is compiled
  81104. */
  81105. onCompiled: (effect: Effect) => void;
  81106. /**
  81107. * Callback triggered when an error occurs
  81108. */
  81109. onError: (effect: Effect, errors: string) => void;
  81110. /**
  81111. * Callback triggered to get the render target textures
  81112. */
  81113. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  81114. /**
  81115. * Gets a boolean indicating that current material needs to register RTT
  81116. */
  81117. readonly hasRenderTargetTextures: boolean;
  81118. /**
  81119. * Specifies if the material should be serialized
  81120. */
  81121. doNotSerialize: boolean;
  81122. /**
  81123. * @hidden
  81124. */
  81125. _storeEffectOnSubMeshes: boolean;
  81126. /**
  81127. * Stores the animations for the material
  81128. */
  81129. animations: Array<Animation>;
  81130. /**
  81131. * An event triggered when the material is disposed
  81132. */
  81133. onDisposeObservable: Observable<Material>;
  81134. /**
  81135. * An observer which watches for dispose events
  81136. */
  81137. private _onDisposeObserver;
  81138. private _onUnBindObservable;
  81139. /**
  81140. * Called during a dispose event
  81141. */
  81142. onDispose: () => void;
  81143. private _onBindObservable;
  81144. /**
  81145. * An event triggered when the material is bound
  81146. */
  81147. readonly onBindObservable: Observable<AbstractMesh>;
  81148. /**
  81149. * An observer which watches for bind events
  81150. */
  81151. private _onBindObserver;
  81152. /**
  81153. * Called during a bind event
  81154. */
  81155. onBind: (Mesh: AbstractMesh) => void;
  81156. /**
  81157. * An event triggered when the material is unbound
  81158. */
  81159. readonly onUnBindObservable: Observable<Material>;
  81160. /**
  81161. * Stores the value of the alpha mode
  81162. */
  81163. private _alphaMode;
  81164. /**
  81165. * Sets the value of the alpha mode.
  81166. *
  81167. * | Value | Type | Description |
  81168. * | --- | --- | --- |
  81169. * | 0 | ALPHA_DISABLE | |
  81170. * | 1 | ALPHA_ADD | |
  81171. * | 2 | ALPHA_COMBINE | |
  81172. * | 3 | ALPHA_SUBTRACT | |
  81173. * | 4 | ALPHA_MULTIPLY | |
  81174. * | 5 | ALPHA_MAXIMIZED | |
  81175. * | 6 | ALPHA_ONEONE | |
  81176. * | 7 | ALPHA_PREMULTIPLIED | |
  81177. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  81178. * | 9 | ALPHA_INTERPOLATE | |
  81179. * | 10 | ALPHA_SCREENMODE | |
  81180. *
  81181. */
  81182. /**
  81183. * Gets the value of the alpha mode
  81184. */
  81185. alphaMode: number;
  81186. /**
  81187. * Stores the state of the need depth pre-pass value
  81188. */
  81189. private _needDepthPrePass;
  81190. /**
  81191. * Sets the need depth pre-pass value
  81192. */
  81193. /**
  81194. * Gets the depth pre-pass value
  81195. */
  81196. needDepthPrePass: boolean;
  81197. /**
  81198. * Specifies if depth writing should be disabled
  81199. */
  81200. disableDepthWrite: boolean;
  81201. /**
  81202. * Specifies if depth writing should be forced
  81203. */
  81204. forceDepthWrite: boolean;
  81205. /**
  81206. * Specifies if there should be a separate pass for culling
  81207. */
  81208. separateCullingPass: boolean;
  81209. /**
  81210. * Stores the state specifing if fog should be enabled
  81211. */
  81212. private _fogEnabled;
  81213. /**
  81214. * Sets the state for enabling fog
  81215. */
  81216. /**
  81217. * Gets the value of the fog enabled state
  81218. */
  81219. fogEnabled: boolean;
  81220. /**
  81221. * Stores the size of points
  81222. */
  81223. pointSize: number;
  81224. /**
  81225. * Stores the z offset value
  81226. */
  81227. zOffset: number;
  81228. /**
  81229. * Gets a value specifying if wireframe mode is enabled
  81230. */
  81231. /**
  81232. * Sets the state of wireframe mode
  81233. */
  81234. wireframe: boolean;
  81235. /**
  81236. * Gets the value specifying if point clouds are enabled
  81237. */
  81238. /**
  81239. * Sets the state of point cloud mode
  81240. */
  81241. pointsCloud: boolean;
  81242. /**
  81243. * Gets the material fill mode
  81244. */
  81245. /**
  81246. * Sets the material fill mode
  81247. */
  81248. fillMode: number;
  81249. /**
  81250. * @hidden
  81251. * Stores the effects for the material
  81252. */
  81253. _effect: Nullable<Effect>;
  81254. /**
  81255. * @hidden
  81256. * Specifies if the material was previously ready
  81257. */
  81258. _wasPreviouslyReady: boolean;
  81259. /**
  81260. * Specifies if uniform buffers should be used
  81261. */
  81262. private _useUBO;
  81263. /**
  81264. * Stores a reference to the scene
  81265. */
  81266. private _scene;
  81267. /**
  81268. * Stores the fill mode state
  81269. */
  81270. private _fillMode;
  81271. /**
  81272. * Specifies if the depth write state should be cached
  81273. */
  81274. private _cachedDepthWriteState;
  81275. /**
  81276. * Stores the uniform buffer
  81277. */
  81278. protected _uniformBuffer: UniformBuffer;
  81279. /** @hidden */
  81280. _indexInSceneMaterialArray: number;
  81281. /** @hidden */
  81282. meshMap: Nullable<{
  81283. [id: string]: AbstractMesh | undefined;
  81284. }>;
  81285. /**
  81286. * Creates a material instance
  81287. * @param name defines the name of the material
  81288. * @param scene defines the scene to reference
  81289. * @param doNotAdd specifies if the material should be added to the scene
  81290. */
  81291. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  81292. /**
  81293. * Returns a string representation of the current material
  81294. * @param fullDetails defines a boolean indicating which levels of logging is desired
  81295. * @returns a string with material information
  81296. */
  81297. toString(fullDetails?: boolean): string;
  81298. /**
  81299. * Gets the class name of the material
  81300. * @returns a string with the class name of the material
  81301. */
  81302. getClassName(): string;
  81303. /**
  81304. * Specifies if updates for the material been locked
  81305. */
  81306. readonly isFrozen: boolean;
  81307. /**
  81308. * Locks updates for the material
  81309. */
  81310. freeze(): void;
  81311. /**
  81312. * Unlocks updates for the material
  81313. */
  81314. unfreeze(): void;
  81315. /**
  81316. * Specifies if the material is ready to be used
  81317. * @param mesh defines the mesh to check
  81318. * @param useInstances specifies if instances should be used
  81319. * @returns a boolean indicating if the material is ready to be used
  81320. */
  81321. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  81322. /**
  81323. * Specifies that the submesh is ready to be used
  81324. * @param mesh defines the mesh to check
  81325. * @param subMesh defines which submesh to check
  81326. * @param useInstances specifies that instances should be used
  81327. * @returns a boolean indicating that the submesh is ready or not
  81328. */
  81329. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  81330. /**
  81331. * Returns the material effect
  81332. * @returns the effect associated with the material
  81333. */
  81334. getEffect(): Nullable<Effect>;
  81335. /**
  81336. * Returns the current scene
  81337. * @returns a Scene
  81338. */
  81339. getScene(): Scene;
  81340. /**
  81341. * Specifies if the material will require alpha blending
  81342. * @returns a boolean specifying if alpha blending is needed
  81343. */
  81344. needAlphaBlending(): boolean;
  81345. /**
  81346. * Specifies if the mesh will require alpha blending
  81347. * @param mesh defines the mesh to check
  81348. * @returns a boolean specifying if alpha blending is needed for the mesh
  81349. */
  81350. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  81351. /**
  81352. * Specifies if this material should be rendered in alpha test mode
  81353. * @returns a boolean specifying if an alpha test is needed.
  81354. */
  81355. needAlphaTesting(): boolean;
  81356. /**
  81357. * Gets the texture used for the alpha test
  81358. * @returns the texture to use for alpha testing
  81359. */
  81360. getAlphaTestTexture(): Nullable<BaseTexture>;
  81361. /**
  81362. * Marks the material to indicate that it needs to be re-calculated
  81363. */
  81364. markDirty(): void;
  81365. /** @hidden */
  81366. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  81367. /**
  81368. * Binds the material to the mesh
  81369. * @param world defines the world transformation matrix
  81370. * @param mesh defines the mesh to bind the material to
  81371. */
  81372. bind(world: Matrix, mesh?: Mesh): void;
  81373. /**
  81374. * Binds the submesh to the material
  81375. * @param world defines the world transformation matrix
  81376. * @param mesh defines the mesh containing the submesh
  81377. * @param subMesh defines the submesh to bind the material to
  81378. */
  81379. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  81380. /**
  81381. * Binds the world matrix to the material
  81382. * @param world defines the world transformation matrix
  81383. */
  81384. bindOnlyWorldMatrix(world: Matrix): void;
  81385. /**
  81386. * Binds the scene's uniform buffer to the effect.
  81387. * @param effect defines the effect to bind to the scene uniform buffer
  81388. * @param sceneUbo defines the uniform buffer storing scene data
  81389. */
  81390. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  81391. /**
  81392. * Binds the view matrix to the effect
  81393. * @param effect defines the effect to bind the view matrix to
  81394. */
  81395. bindView(effect: Effect): void;
  81396. /**
  81397. * Binds the view projection matrix to the effect
  81398. * @param effect defines the effect to bind the view projection matrix to
  81399. */
  81400. bindViewProjection(effect: Effect): void;
  81401. /**
  81402. * Specifies if material alpha testing should be turned on for the mesh
  81403. * @param mesh defines the mesh to check
  81404. */
  81405. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  81406. /**
  81407. * Processes to execute after binding the material to a mesh
  81408. * @param mesh defines the rendered mesh
  81409. */
  81410. protected _afterBind(mesh?: Mesh): void;
  81411. /**
  81412. * Unbinds the material from the mesh
  81413. */
  81414. unbind(): void;
  81415. /**
  81416. * Gets the active textures from the material
  81417. * @returns an array of textures
  81418. */
  81419. getActiveTextures(): BaseTexture[];
  81420. /**
  81421. * Specifies if the material uses a texture
  81422. * @param texture defines the texture to check against the material
  81423. * @returns a boolean specifying if the material uses the texture
  81424. */
  81425. hasTexture(texture: BaseTexture): boolean;
  81426. /**
  81427. * Makes a duplicate of the material, and gives it a new name
  81428. * @param name defines the new name for the duplicated material
  81429. * @returns the cloned material
  81430. */
  81431. clone(name: string): Nullable<Material>;
  81432. /**
  81433. * Gets the meshes bound to the material
  81434. * @returns an array of meshes bound to the material
  81435. */
  81436. getBindedMeshes(): AbstractMesh[];
  81437. /**
  81438. * Force shader compilation
  81439. * @param mesh defines the mesh associated with this material
  81440. * @param onCompiled defines a function to execute once the material is compiled
  81441. * @param options defines the options to configure the compilation
  81442. */
  81443. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  81444. clipPlane: boolean;
  81445. }>): void;
  81446. /**
  81447. * Force shader compilation
  81448. * @param mesh defines the mesh that will use this material
  81449. * @param options defines additional options for compiling the shaders
  81450. * @returns a promise that resolves when the compilation completes
  81451. */
  81452. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  81453. clipPlane: boolean;
  81454. }>): Promise<void>;
  81455. private static readonly _ImageProcessingDirtyCallBack;
  81456. private static readonly _TextureDirtyCallBack;
  81457. private static readonly _FresnelDirtyCallBack;
  81458. private static readonly _MiscDirtyCallBack;
  81459. private static readonly _LightsDirtyCallBack;
  81460. private static readonly _AttributeDirtyCallBack;
  81461. private static _FresnelAndMiscDirtyCallBack;
  81462. private static _TextureAndMiscDirtyCallBack;
  81463. private static readonly _DirtyCallbackArray;
  81464. private static readonly _RunDirtyCallBacks;
  81465. /**
  81466. * Marks a define in the material to indicate that it needs to be re-computed
  81467. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  81468. */
  81469. markAsDirty(flag: number): void;
  81470. /**
  81471. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  81472. * @param func defines a function which checks material defines against the submeshes
  81473. */
  81474. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  81475. /**
  81476. * Indicates that image processing needs to be re-calculated for all submeshes
  81477. */
  81478. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  81479. /**
  81480. * Indicates that textures need to be re-calculated for all submeshes
  81481. */
  81482. protected _markAllSubMeshesAsTexturesDirty(): void;
  81483. /**
  81484. * Indicates that fresnel needs to be re-calculated for all submeshes
  81485. */
  81486. protected _markAllSubMeshesAsFresnelDirty(): void;
  81487. /**
  81488. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  81489. */
  81490. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  81491. /**
  81492. * Indicates that lights need to be re-calculated for all submeshes
  81493. */
  81494. protected _markAllSubMeshesAsLightsDirty(): void;
  81495. /**
  81496. * Indicates that attributes need to be re-calculated for all submeshes
  81497. */
  81498. protected _markAllSubMeshesAsAttributesDirty(): void;
  81499. /**
  81500. * Indicates that misc needs to be re-calculated for all submeshes
  81501. */
  81502. protected _markAllSubMeshesAsMiscDirty(): void;
  81503. /**
  81504. * Indicates that textures and misc need to be re-calculated for all submeshes
  81505. */
  81506. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  81507. /**
  81508. * Disposes the material
  81509. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  81510. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  81511. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  81512. */
  81513. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  81514. /** @hidden */
  81515. private releaseVertexArrayObject;
  81516. /**
  81517. * Serializes this material
  81518. * @returns the serialized material object
  81519. */
  81520. serialize(): any;
  81521. /**
  81522. * Creates a material from parsed material data
  81523. * @param parsedMaterial defines parsed material data
  81524. * @param scene defines the hosting scene
  81525. * @param rootUrl defines the root URL to use to load textures
  81526. * @returns a new material
  81527. */
  81528. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  81529. }
  81530. }
  81531. declare module BABYLON {
  81532. /**
  81533. * Base class for submeshes
  81534. */
  81535. export class BaseSubMesh {
  81536. /** @hidden */
  81537. _materialDefines: Nullable<MaterialDefines>;
  81538. /** @hidden */
  81539. _materialEffect: Nullable<Effect>;
  81540. /**
  81541. * Gets associated effect
  81542. */
  81543. readonly effect: Nullable<Effect>;
  81544. /**
  81545. * Sets associated effect (effect used to render this submesh)
  81546. * @param effect defines the effect to associate with
  81547. * @param defines defines the set of defines used to compile this effect
  81548. */
  81549. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  81550. }
  81551. /**
  81552. * Defines a subdivision inside a mesh
  81553. */
  81554. export class SubMesh extends BaseSubMesh implements ICullable {
  81555. /** the material index to use */
  81556. materialIndex: number;
  81557. /** vertex index start */
  81558. verticesStart: number;
  81559. /** vertices count */
  81560. verticesCount: number;
  81561. /** index start */
  81562. indexStart: number;
  81563. /** indices count */
  81564. indexCount: number;
  81565. /** @hidden */
  81566. _linesIndexCount: number;
  81567. private _mesh;
  81568. private _renderingMesh;
  81569. private _boundingInfo;
  81570. private _linesIndexBuffer;
  81571. /** @hidden */
  81572. _lastColliderWorldVertices: Nullable<Vector3[]>;
  81573. /** @hidden */
  81574. _trianglePlanes: Plane[];
  81575. /** @hidden */
  81576. _lastColliderTransformMatrix: Matrix;
  81577. /** @hidden */
  81578. _renderId: number;
  81579. /** @hidden */
  81580. _alphaIndex: number;
  81581. /** @hidden */
  81582. _distanceToCamera: number;
  81583. /** @hidden */
  81584. _id: number;
  81585. private _currentMaterial;
  81586. /**
  81587. * Add a new submesh to a mesh
  81588. * @param materialIndex defines the material index to use
  81589. * @param verticesStart defines vertex index start
  81590. * @param verticesCount defines vertices count
  81591. * @param indexStart defines index start
  81592. * @param indexCount defines indices count
  81593. * @param mesh defines the parent mesh
  81594. * @param renderingMesh defines an optional rendering mesh
  81595. * @param createBoundingBox defines if bounding box should be created for this submesh
  81596. * @returns the new submesh
  81597. */
  81598. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  81599. /**
  81600. * Creates a new submesh
  81601. * @param materialIndex defines the material index to use
  81602. * @param verticesStart defines vertex index start
  81603. * @param verticesCount defines vertices count
  81604. * @param indexStart defines index start
  81605. * @param indexCount defines indices count
  81606. * @param mesh defines the parent mesh
  81607. * @param renderingMesh defines an optional rendering mesh
  81608. * @param createBoundingBox defines if bounding box should be created for this submesh
  81609. */
  81610. constructor(
  81611. /** the material index to use */
  81612. materialIndex: number,
  81613. /** vertex index start */
  81614. verticesStart: number,
  81615. /** vertices count */
  81616. verticesCount: number,
  81617. /** index start */
  81618. indexStart: number,
  81619. /** indices count */
  81620. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  81621. /**
  81622. * Returns true if this submesh covers the entire parent mesh
  81623. * @ignorenaming
  81624. */
  81625. readonly IsGlobal: boolean;
  81626. /**
  81627. * Returns the submesh BoudingInfo object
  81628. * @returns current bounding info (or mesh's one if the submesh is global)
  81629. */
  81630. getBoundingInfo(): BoundingInfo;
  81631. /**
  81632. * Sets the submesh BoundingInfo
  81633. * @param boundingInfo defines the new bounding info to use
  81634. * @returns the SubMesh
  81635. */
  81636. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  81637. /**
  81638. * Returns the mesh of the current submesh
  81639. * @return the parent mesh
  81640. */
  81641. getMesh(): AbstractMesh;
  81642. /**
  81643. * Returns the rendering mesh of the submesh
  81644. * @returns the rendering mesh (could be different from parent mesh)
  81645. */
  81646. getRenderingMesh(): Mesh;
  81647. /**
  81648. * Returns the submesh material
  81649. * @returns null or the current material
  81650. */
  81651. getMaterial(): Nullable<Material>;
  81652. /**
  81653. * Sets a new updated BoundingInfo object to the submesh
  81654. * @returns the SubMesh
  81655. */
  81656. refreshBoundingInfo(): SubMesh;
  81657. /** @hidden */
  81658. _checkCollision(collider: Collider): boolean;
  81659. /**
  81660. * Updates the submesh BoundingInfo
  81661. * @param world defines the world matrix to use to update the bounding info
  81662. * @returns the submesh
  81663. */
  81664. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  81665. /**
  81666. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  81667. * @param frustumPlanes defines the frustum planes
  81668. * @returns true if the submesh is intersecting with the frustum
  81669. */
  81670. isInFrustum(frustumPlanes: Plane[]): boolean;
  81671. /**
  81672. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  81673. * @param frustumPlanes defines the frustum planes
  81674. * @returns true if the submesh is inside the frustum
  81675. */
  81676. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  81677. /**
  81678. * Renders the submesh
  81679. * @param enableAlphaMode defines if alpha needs to be used
  81680. * @returns the submesh
  81681. */
  81682. render(enableAlphaMode: boolean): SubMesh;
  81683. /**
  81684. * @hidden
  81685. */
  81686. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  81687. /**
  81688. * Checks if the submesh intersects with a ray
  81689. * @param ray defines the ray to test
  81690. * @returns true is the passed ray intersects the submesh bounding box
  81691. */
  81692. canIntersects(ray: Ray): boolean;
  81693. /**
  81694. * Intersects current submesh with a ray
  81695. * @param ray defines the ray to test
  81696. * @param positions defines mesh's positions array
  81697. * @param indices defines mesh's indices array
  81698. * @param fastCheck defines if only bounding info should be used
  81699. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  81700. * @returns intersection info or null if no intersection
  81701. */
  81702. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  81703. /** @hidden */
  81704. private _intersectLines;
  81705. /** @hidden */
  81706. private _intersectTriangles;
  81707. /** @hidden */
  81708. _rebuild(): void;
  81709. /**
  81710. * Creates a new submesh from the passed mesh
  81711. * @param newMesh defines the new hosting mesh
  81712. * @param newRenderingMesh defines an optional rendering mesh
  81713. * @returns the new submesh
  81714. */
  81715. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  81716. /**
  81717. * Release associated resources
  81718. */
  81719. dispose(): void;
  81720. /**
  81721. * Gets the class name
  81722. * @returns the string "SubMesh".
  81723. */
  81724. getClassName(): string;
  81725. /**
  81726. * Creates a new submesh from indices data
  81727. * @param materialIndex the index of the main mesh material
  81728. * @param startIndex the index where to start the copy in the mesh indices array
  81729. * @param indexCount the number of indices to copy then from the startIndex
  81730. * @param mesh the main mesh to create the submesh from
  81731. * @param renderingMesh the optional rendering mesh
  81732. * @returns a new submesh
  81733. */
  81734. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  81735. }
  81736. }
  81737. declare module BABYLON {
  81738. /**
  81739. * Class used to store geometry data (vertex buffers + index buffer)
  81740. */
  81741. export class Geometry implements IGetSetVerticesData {
  81742. /**
  81743. * Gets or sets the ID of the geometry
  81744. */
  81745. id: string;
  81746. /**
  81747. * Gets or sets the unique ID of the geometry
  81748. */
  81749. uniqueId: number;
  81750. /**
  81751. * Gets the delay loading state of the geometry (none by default which means not delayed)
  81752. */
  81753. delayLoadState: number;
  81754. /**
  81755. * Gets the file containing the data to load when running in delay load state
  81756. */
  81757. delayLoadingFile: Nullable<string>;
  81758. /**
  81759. * Callback called when the geometry is updated
  81760. */
  81761. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  81762. private _scene;
  81763. private _engine;
  81764. private _meshes;
  81765. private _totalVertices;
  81766. /** @hidden */
  81767. _indices: IndicesArray;
  81768. /** @hidden */
  81769. _vertexBuffers: {
  81770. [key: string]: VertexBuffer;
  81771. };
  81772. private _isDisposed;
  81773. private _extend;
  81774. private _boundingBias;
  81775. /** @hidden */
  81776. _delayInfo: Array<string>;
  81777. private _indexBuffer;
  81778. private _indexBufferIsUpdatable;
  81779. /** @hidden */
  81780. _boundingInfo: Nullable<BoundingInfo>;
  81781. /** @hidden */
  81782. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  81783. /** @hidden */
  81784. _softwareSkinningFrameId: number;
  81785. private _vertexArrayObjects;
  81786. private _updatable;
  81787. /** @hidden */
  81788. _positions: Nullable<Vector3[]>;
  81789. /**
  81790. * 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
  81791. */
  81792. /**
  81793. * 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
  81794. */
  81795. boundingBias: Vector2;
  81796. /**
  81797. * Static function used to attach a new empty geometry to a mesh
  81798. * @param mesh defines the mesh to attach the geometry to
  81799. * @returns the new Geometry
  81800. */
  81801. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  81802. /**
  81803. * Creates a new geometry
  81804. * @param id defines the unique ID
  81805. * @param scene defines the hosting scene
  81806. * @param vertexData defines the VertexData used to get geometry data
  81807. * @param updatable defines if geometry must be updatable (false by default)
  81808. * @param mesh defines the mesh that will be associated with the geometry
  81809. */
  81810. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  81811. /**
  81812. * Gets the current extend of the geometry
  81813. */
  81814. readonly extend: {
  81815. minimum: Vector3;
  81816. maximum: Vector3;
  81817. };
  81818. /**
  81819. * Gets the hosting scene
  81820. * @returns the hosting Scene
  81821. */
  81822. getScene(): Scene;
  81823. /**
  81824. * Gets the hosting engine
  81825. * @returns the hosting Engine
  81826. */
  81827. getEngine(): Engine;
  81828. /**
  81829. * Defines if the geometry is ready to use
  81830. * @returns true if the geometry is ready to be used
  81831. */
  81832. isReady(): boolean;
  81833. /**
  81834. * Gets a value indicating that the geometry should not be serialized
  81835. */
  81836. readonly doNotSerialize: boolean;
  81837. /** @hidden */
  81838. _rebuild(): void;
  81839. /**
  81840. * Affects all geometry data in one call
  81841. * @param vertexData defines the geometry data
  81842. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  81843. */
  81844. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  81845. /**
  81846. * Set specific vertex data
  81847. * @param kind defines the data kind (Position, normal, etc...)
  81848. * @param data defines the vertex data to use
  81849. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  81850. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  81851. */
  81852. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  81853. /**
  81854. * Removes a specific vertex data
  81855. * @param kind defines the data kind (Position, normal, etc...)
  81856. */
  81857. removeVerticesData(kind: string): void;
  81858. /**
  81859. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  81860. * @param buffer defines the vertex buffer to use
  81861. * @param totalVertices defines the total number of vertices for position kind (could be null)
  81862. */
  81863. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  81864. /**
  81865. * Update a specific vertex buffer
  81866. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  81867. * It will do nothing if the buffer is not updatable
  81868. * @param kind defines the data kind (Position, normal, etc...)
  81869. * @param data defines the data to use
  81870. * @param offset defines the offset in the target buffer where to store the data
  81871. * @param useBytes set to true if the offset is in bytes
  81872. */
  81873. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  81874. /**
  81875. * Update a specific vertex buffer
  81876. * This function will create a new buffer if the current one is not updatable
  81877. * @param kind defines the data kind (Position, normal, etc...)
  81878. * @param data defines the data to use
  81879. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  81880. */
  81881. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  81882. private _updateBoundingInfo;
  81883. /** @hidden */
  81884. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  81885. /**
  81886. * Gets total number of vertices
  81887. * @returns the total number of vertices
  81888. */
  81889. getTotalVertices(): number;
  81890. /**
  81891. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  81892. * @param kind defines the data kind (Position, normal, etc...)
  81893. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  81894. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81895. * @returns a float array containing vertex data
  81896. */
  81897. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  81898. /**
  81899. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  81900. * @param kind defines the data kind (Position, normal, etc...)
  81901. * @returns true if the vertex buffer with the specified kind is updatable
  81902. */
  81903. isVertexBufferUpdatable(kind: string): boolean;
  81904. /**
  81905. * Gets a specific vertex buffer
  81906. * @param kind defines the data kind (Position, normal, etc...)
  81907. * @returns a VertexBuffer
  81908. */
  81909. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  81910. /**
  81911. * Returns all vertex buffers
  81912. * @return an object holding all vertex buffers indexed by kind
  81913. */
  81914. getVertexBuffers(): Nullable<{
  81915. [key: string]: VertexBuffer;
  81916. }>;
  81917. /**
  81918. * Gets a boolean indicating if specific vertex buffer is present
  81919. * @param kind defines the data kind (Position, normal, etc...)
  81920. * @returns true if data is present
  81921. */
  81922. isVerticesDataPresent(kind: string): boolean;
  81923. /**
  81924. * Gets a list of all attached data kinds (Position, normal, etc...)
  81925. * @returns a list of string containing all kinds
  81926. */
  81927. getVerticesDataKinds(): string[];
  81928. /**
  81929. * Update index buffer
  81930. * @param indices defines the indices to store in the index buffer
  81931. * @param offset defines the offset in the target buffer where to store the data
  81932. * @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)
  81933. */
  81934. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  81935. /**
  81936. * Creates a new index buffer
  81937. * @param indices defines the indices to store in the index buffer
  81938. * @param totalVertices defines the total number of vertices (could be null)
  81939. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  81940. */
  81941. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  81942. /**
  81943. * Return the total number of indices
  81944. * @returns the total number of indices
  81945. */
  81946. getTotalIndices(): number;
  81947. /**
  81948. * Gets the index buffer array
  81949. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  81950. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81951. * @returns the index buffer array
  81952. */
  81953. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  81954. /**
  81955. * Gets the index buffer
  81956. * @return the index buffer
  81957. */
  81958. getIndexBuffer(): Nullable<WebGLBuffer>;
  81959. /** @hidden */
  81960. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  81961. /**
  81962. * Release the associated resources for a specific mesh
  81963. * @param mesh defines the source mesh
  81964. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  81965. */
  81966. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  81967. /**
  81968. * Apply current geometry to a given mesh
  81969. * @param mesh defines the mesh to apply geometry to
  81970. */
  81971. applyToMesh(mesh: Mesh): void;
  81972. private _updateExtend;
  81973. private _applyToMesh;
  81974. private notifyUpdate;
  81975. /**
  81976. * Load the geometry if it was flagged as delay loaded
  81977. * @param scene defines the hosting scene
  81978. * @param onLoaded defines a callback called when the geometry is loaded
  81979. */
  81980. load(scene: Scene, onLoaded?: () => void): void;
  81981. private _queueLoad;
  81982. /**
  81983. * Invert the geometry to move from a right handed system to a left handed one.
  81984. */
  81985. toLeftHanded(): void;
  81986. /** @hidden */
  81987. _resetPointsArrayCache(): void;
  81988. /** @hidden */
  81989. _generatePointsArray(): boolean;
  81990. /**
  81991. * Gets a value indicating if the geometry is disposed
  81992. * @returns true if the geometry was disposed
  81993. */
  81994. isDisposed(): boolean;
  81995. private _disposeVertexArrayObjects;
  81996. /**
  81997. * Free all associated resources
  81998. */
  81999. dispose(): void;
  82000. /**
  82001. * Clone the current geometry into a new geometry
  82002. * @param id defines the unique ID of the new geometry
  82003. * @returns a new geometry object
  82004. */
  82005. copy(id: string): Geometry;
  82006. /**
  82007. * Serialize the current geometry info (and not the vertices data) into a JSON object
  82008. * @return a JSON representation of the current geometry data (without the vertices data)
  82009. */
  82010. serialize(): any;
  82011. private toNumberArray;
  82012. /**
  82013. * Serialize all vertices data into a JSON oject
  82014. * @returns a JSON representation of the current geometry data
  82015. */
  82016. serializeVerticeData(): any;
  82017. /**
  82018. * Extracts a clone of a mesh geometry
  82019. * @param mesh defines the source mesh
  82020. * @param id defines the unique ID of the new geometry object
  82021. * @returns the new geometry object
  82022. */
  82023. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  82024. /**
  82025. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  82026. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  82027. * Be aware Math.random() could cause collisions, but:
  82028. * "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"
  82029. * @returns a string containing a new GUID
  82030. */
  82031. static RandomId(): string;
  82032. /** @hidden */
  82033. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  82034. private static _CleanMatricesWeights;
  82035. /**
  82036. * Create a new geometry from persisted data (Using .babylon file format)
  82037. * @param parsedVertexData defines the persisted data
  82038. * @param scene defines the hosting scene
  82039. * @param rootUrl defines the root url to use to load assets (like delayed data)
  82040. * @returns the new geometry object
  82041. */
  82042. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  82043. }
  82044. }
  82045. declare module BABYLON {
  82046. /**
  82047. * Define an interface for all classes that will get and set the data on vertices
  82048. */
  82049. export interface IGetSetVerticesData {
  82050. /**
  82051. * Gets a boolean indicating if specific vertex data is present
  82052. * @param kind defines the vertex data kind to use
  82053. * @returns true is data kind is present
  82054. */
  82055. isVerticesDataPresent(kind: string): boolean;
  82056. /**
  82057. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  82058. * @param kind defines the data kind (Position, normal, etc...)
  82059. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  82060. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82061. * @returns a float array containing vertex data
  82062. */
  82063. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  82064. /**
  82065. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  82066. * @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.
  82067. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82068. * @returns the indices array or an empty array if the mesh has no geometry
  82069. */
  82070. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  82071. /**
  82072. * Set specific vertex data
  82073. * @param kind defines the data kind (Position, normal, etc...)
  82074. * @param data defines the vertex data to use
  82075. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  82076. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  82077. */
  82078. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  82079. /**
  82080. * Update a specific associated vertex buffer
  82081. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  82082. * - VertexBuffer.PositionKind
  82083. * - VertexBuffer.UVKind
  82084. * - VertexBuffer.UV2Kind
  82085. * - VertexBuffer.UV3Kind
  82086. * - VertexBuffer.UV4Kind
  82087. * - VertexBuffer.UV5Kind
  82088. * - VertexBuffer.UV6Kind
  82089. * - VertexBuffer.ColorKind
  82090. * - VertexBuffer.MatricesIndicesKind
  82091. * - VertexBuffer.MatricesIndicesExtraKind
  82092. * - VertexBuffer.MatricesWeightsKind
  82093. * - VertexBuffer.MatricesWeightsExtraKind
  82094. * @param data defines the data source
  82095. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  82096. * @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)
  82097. */
  82098. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  82099. /**
  82100. * Creates a new index buffer
  82101. * @param indices defines the indices to store in the index buffer
  82102. * @param totalVertices defines the total number of vertices (could be null)
  82103. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  82104. */
  82105. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  82106. }
  82107. /**
  82108. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  82109. */
  82110. export class VertexData {
  82111. /**
  82112. * Mesh side orientation : usually the external or front surface
  82113. */
  82114. static readonly FRONTSIDE: number;
  82115. /**
  82116. * Mesh side orientation : usually the internal or back surface
  82117. */
  82118. static readonly BACKSIDE: number;
  82119. /**
  82120. * Mesh side orientation : both internal and external or front and back surfaces
  82121. */
  82122. static readonly DOUBLESIDE: number;
  82123. /**
  82124. * Mesh side orientation : by default, `FRONTSIDE`
  82125. */
  82126. static readonly DEFAULTSIDE: number;
  82127. /**
  82128. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  82129. */
  82130. positions: Nullable<FloatArray>;
  82131. /**
  82132. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  82133. */
  82134. normals: Nullable<FloatArray>;
  82135. /**
  82136. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  82137. */
  82138. tangents: Nullable<FloatArray>;
  82139. /**
  82140. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82141. */
  82142. uvs: Nullable<FloatArray>;
  82143. /**
  82144. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82145. */
  82146. uvs2: Nullable<FloatArray>;
  82147. /**
  82148. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82149. */
  82150. uvs3: Nullable<FloatArray>;
  82151. /**
  82152. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82153. */
  82154. uvs4: Nullable<FloatArray>;
  82155. /**
  82156. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82157. */
  82158. uvs5: Nullable<FloatArray>;
  82159. /**
  82160. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82161. */
  82162. uvs6: Nullable<FloatArray>;
  82163. /**
  82164. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  82165. */
  82166. colors: Nullable<FloatArray>;
  82167. /**
  82168. * 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).
  82169. */
  82170. matricesIndices: Nullable<FloatArray>;
  82171. /**
  82172. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  82173. */
  82174. matricesWeights: Nullable<FloatArray>;
  82175. /**
  82176. * An array extending the number of possible indices
  82177. */
  82178. matricesIndicesExtra: Nullable<FloatArray>;
  82179. /**
  82180. * An array extending the number of possible weights when the number of indices is extended
  82181. */
  82182. matricesWeightsExtra: Nullable<FloatArray>;
  82183. /**
  82184. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  82185. */
  82186. indices: Nullable<IndicesArray>;
  82187. /**
  82188. * Uses the passed data array to set the set the values for the specified kind of data
  82189. * @param data a linear array of floating numbers
  82190. * @param kind the type of data that is being set, eg positions, colors etc
  82191. */
  82192. set(data: FloatArray, kind: string): void;
  82193. /**
  82194. * Associates the vertexData to the passed Mesh.
  82195. * Sets it as updatable or not (default `false`)
  82196. * @param mesh the mesh the vertexData is applied to
  82197. * @param updatable when used and having the value true allows new data to update the vertexData
  82198. * @returns the VertexData
  82199. */
  82200. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  82201. /**
  82202. * Associates the vertexData to the passed Geometry.
  82203. * Sets it as updatable or not (default `false`)
  82204. * @param geometry the geometry the vertexData is applied to
  82205. * @param updatable when used and having the value true allows new data to update the vertexData
  82206. * @returns VertexData
  82207. */
  82208. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  82209. /**
  82210. * Updates the associated mesh
  82211. * @param mesh the mesh to be updated
  82212. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  82213. * @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
  82214. * @returns VertexData
  82215. */
  82216. updateMesh(mesh: Mesh): VertexData;
  82217. /**
  82218. * Updates the associated geometry
  82219. * @param geometry the geometry to be updated
  82220. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  82221. * @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
  82222. * @returns VertexData.
  82223. */
  82224. updateGeometry(geometry: Geometry): VertexData;
  82225. private _applyTo;
  82226. private _update;
  82227. /**
  82228. * Transforms each position and each normal of the vertexData according to the passed Matrix
  82229. * @param matrix the transforming matrix
  82230. * @returns the VertexData
  82231. */
  82232. transform(matrix: Matrix): VertexData;
  82233. /**
  82234. * Merges the passed VertexData into the current one
  82235. * @param other the VertexData to be merged into the current one
  82236. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  82237. * @returns the modified VertexData
  82238. */
  82239. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  82240. private _mergeElement;
  82241. private _validate;
  82242. /**
  82243. * Serializes the VertexData
  82244. * @returns a serialized object
  82245. */
  82246. serialize(): any;
  82247. /**
  82248. * Extracts the vertexData from a mesh
  82249. * @param mesh the mesh from which to extract the VertexData
  82250. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  82251. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  82252. * @returns the object VertexData associated to the passed mesh
  82253. */
  82254. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  82255. /**
  82256. * Extracts the vertexData from the geometry
  82257. * @param geometry the geometry from which to extract the VertexData
  82258. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  82259. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  82260. * @returns the object VertexData associated to the passed mesh
  82261. */
  82262. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  82263. private static _ExtractFrom;
  82264. /**
  82265. * Creates the VertexData for a Ribbon
  82266. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  82267. * * pathArray array of paths, each of which an array of successive Vector3
  82268. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  82269. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  82270. * * 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
  82271. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82272. * * 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)
  82273. * * 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)
  82274. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  82275. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  82276. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  82277. * @returns the VertexData of the ribbon
  82278. */
  82279. static CreateRibbon(options: {
  82280. pathArray: Vector3[][];
  82281. closeArray?: boolean;
  82282. closePath?: boolean;
  82283. offset?: number;
  82284. sideOrientation?: number;
  82285. frontUVs?: Vector4;
  82286. backUVs?: Vector4;
  82287. invertUV?: boolean;
  82288. uvs?: Vector2[];
  82289. colors?: Color4[];
  82290. }): VertexData;
  82291. /**
  82292. * Creates the VertexData for a box
  82293. * @param options an object used to set the following optional parameters for the box, required but can be empty
  82294. * * size sets the width, height and depth of the box to the value of size, optional default 1
  82295. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  82296. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  82297. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  82298. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  82299. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  82300. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82301. * * 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)
  82302. * * 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)
  82303. * @returns the VertexData of the box
  82304. */
  82305. static CreateBox(options: {
  82306. size?: number;
  82307. width?: number;
  82308. height?: number;
  82309. depth?: number;
  82310. faceUV?: Vector4[];
  82311. faceColors?: Color4[];
  82312. sideOrientation?: number;
  82313. frontUVs?: Vector4;
  82314. backUVs?: Vector4;
  82315. }): VertexData;
  82316. /**
  82317. * Creates the VertexData for an ellipsoid, defaults to a sphere
  82318. * @param options an object used to set the following optional parameters for the box, required but can be empty
  82319. * * segments sets the number of horizontal strips optional, default 32
  82320. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  82321. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  82322. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  82323. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  82324. * * 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
  82325. * * 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
  82326. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82327. * * 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)
  82328. * * 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)
  82329. * @returns the VertexData of the ellipsoid
  82330. */
  82331. static CreateSphere(options: {
  82332. segments?: number;
  82333. diameter?: number;
  82334. diameterX?: number;
  82335. diameterY?: number;
  82336. diameterZ?: number;
  82337. arc?: number;
  82338. slice?: number;
  82339. sideOrientation?: number;
  82340. frontUVs?: Vector4;
  82341. backUVs?: Vector4;
  82342. }): VertexData;
  82343. /**
  82344. * Creates the VertexData for a cylinder, cone or prism
  82345. * @param options an object used to set the following optional parameters for the box, required but can be empty
  82346. * * height sets the height (y direction) of the cylinder, optional, default 2
  82347. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  82348. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  82349. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  82350. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  82351. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  82352. * * 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
  82353. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  82354. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  82355. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  82356. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  82357. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82358. * * 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)
  82359. * * 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)
  82360. * @returns the VertexData of the cylinder, cone or prism
  82361. */
  82362. static CreateCylinder(options: {
  82363. height?: number;
  82364. diameterTop?: number;
  82365. diameterBottom?: number;
  82366. diameter?: number;
  82367. tessellation?: number;
  82368. subdivisions?: number;
  82369. arc?: number;
  82370. faceColors?: Color4[];
  82371. faceUV?: Vector4[];
  82372. hasRings?: boolean;
  82373. enclose?: boolean;
  82374. sideOrientation?: number;
  82375. frontUVs?: Vector4;
  82376. backUVs?: Vector4;
  82377. }): VertexData;
  82378. /**
  82379. * Creates the VertexData for a torus
  82380. * @param options an object used to set the following optional parameters for the box, required but can be empty
  82381. * * diameter the diameter of the torus, optional default 1
  82382. * * thickness the diameter of the tube forming the torus, optional default 0.5
  82383. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  82384. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82385. * * 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)
  82386. * * 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)
  82387. * @returns the VertexData of the torus
  82388. */
  82389. static CreateTorus(options: {
  82390. diameter?: number;
  82391. thickness?: number;
  82392. tessellation?: number;
  82393. sideOrientation?: number;
  82394. frontUVs?: Vector4;
  82395. backUVs?: Vector4;
  82396. }): VertexData;
  82397. /**
  82398. * Creates the VertexData of the LineSystem
  82399. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  82400. * - lines an array of lines, each line being an array of successive Vector3
  82401. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  82402. * @returns the VertexData of the LineSystem
  82403. */
  82404. static CreateLineSystem(options: {
  82405. lines: Vector3[][];
  82406. colors?: Nullable<Color4[][]>;
  82407. }): VertexData;
  82408. /**
  82409. * Create the VertexData for a DashedLines
  82410. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  82411. * - points an array successive Vector3
  82412. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  82413. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  82414. * - dashNb the intended total number of dashes, optional, default 200
  82415. * @returns the VertexData for the DashedLines
  82416. */
  82417. static CreateDashedLines(options: {
  82418. points: Vector3[];
  82419. dashSize?: number;
  82420. gapSize?: number;
  82421. dashNb?: number;
  82422. }): VertexData;
  82423. /**
  82424. * Creates the VertexData for a Ground
  82425. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  82426. * - width the width (x direction) of the ground, optional, default 1
  82427. * - height the height (z direction) of the ground, optional, default 1
  82428. * - subdivisions the number of subdivisions per side, optional, default 1
  82429. * @returns the VertexData of the Ground
  82430. */
  82431. static CreateGround(options: {
  82432. width?: number;
  82433. height?: number;
  82434. subdivisions?: number;
  82435. subdivisionsX?: number;
  82436. subdivisionsY?: number;
  82437. }): VertexData;
  82438. /**
  82439. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  82440. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  82441. * * xmin the ground minimum X coordinate, optional, default -1
  82442. * * zmin the ground minimum Z coordinate, optional, default -1
  82443. * * xmax the ground maximum X coordinate, optional, default 1
  82444. * * zmax the ground maximum Z coordinate, optional, default 1
  82445. * * 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}
  82446. * * 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}
  82447. * @returns the VertexData of the TiledGround
  82448. */
  82449. static CreateTiledGround(options: {
  82450. xmin: number;
  82451. zmin: number;
  82452. xmax: number;
  82453. zmax: number;
  82454. subdivisions?: {
  82455. w: number;
  82456. h: number;
  82457. };
  82458. precision?: {
  82459. w: number;
  82460. h: number;
  82461. };
  82462. }): VertexData;
  82463. /**
  82464. * Creates the VertexData of the Ground designed from a heightmap
  82465. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  82466. * * width the width (x direction) of the ground
  82467. * * height the height (z direction) of the ground
  82468. * * subdivisions the number of subdivisions per side
  82469. * * minHeight the minimum altitude on the ground, optional, default 0
  82470. * * maxHeight the maximum altitude on the ground, optional default 1
  82471. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  82472. * * buffer the array holding the image color data
  82473. * * bufferWidth the width of image
  82474. * * bufferHeight the height of image
  82475. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  82476. * @returns the VertexData of the Ground designed from a heightmap
  82477. */
  82478. static CreateGroundFromHeightMap(options: {
  82479. width: number;
  82480. height: number;
  82481. subdivisions: number;
  82482. minHeight: number;
  82483. maxHeight: number;
  82484. colorFilter: Color3;
  82485. buffer: Uint8Array;
  82486. bufferWidth: number;
  82487. bufferHeight: number;
  82488. alphaFilter: number;
  82489. }): VertexData;
  82490. /**
  82491. * Creates the VertexData for a Plane
  82492. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  82493. * * size sets the width and height of the plane to the value of size, optional default 1
  82494. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  82495. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  82496. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82497. * * 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)
  82498. * * 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)
  82499. * @returns the VertexData of the box
  82500. */
  82501. static CreatePlane(options: {
  82502. size?: number;
  82503. width?: number;
  82504. height?: number;
  82505. sideOrientation?: number;
  82506. frontUVs?: Vector4;
  82507. backUVs?: Vector4;
  82508. }): VertexData;
  82509. /**
  82510. * Creates the VertexData of the Disc or regular Polygon
  82511. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  82512. * * radius the radius of the disc, optional default 0.5
  82513. * * tessellation the number of polygon sides, optional, default 64
  82514. * * 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
  82515. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82516. * * 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)
  82517. * * 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)
  82518. * @returns the VertexData of the box
  82519. */
  82520. static CreateDisc(options: {
  82521. radius?: number;
  82522. tessellation?: number;
  82523. arc?: number;
  82524. sideOrientation?: number;
  82525. frontUVs?: Vector4;
  82526. backUVs?: Vector4;
  82527. }): VertexData;
  82528. /**
  82529. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  82530. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  82531. * @param polygon a mesh built from polygonTriangulation.build()
  82532. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82533. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  82534. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  82535. * @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)
  82536. * @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)
  82537. * @returns the VertexData of the Polygon
  82538. */
  82539. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  82540. /**
  82541. * Creates the VertexData of the IcoSphere
  82542. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  82543. * * radius the radius of the IcoSphere, optional default 1
  82544. * * radiusX allows stretching in the x direction, optional, default radius
  82545. * * radiusY allows stretching in the y direction, optional, default radius
  82546. * * radiusZ allows stretching in the z direction, optional, default radius
  82547. * * flat when true creates a flat shaded mesh, optional, default true
  82548. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  82549. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82550. * * 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)
  82551. * * 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)
  82552. * @returns the VertexData of the IcoSphere
  82553. */
  82554. static CreateIcoSphere(options: {
  82555. radius?: number;
  82556. radiusX?: number;
  82557. radiusY?: number;
  82558. radiusZ?: number;
  82559. flat?: boolean;
  82560. subdivisions?: number;
  82561. sideOrientation?: number;
  82562. frontUVs?: Vector4;
  82563. backUVs?: Vector4;
  82564. }): VertexData;
  82565. /**
  82566. * Creates the VertexData for a Polyhedron
  82567. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  82568. * * type provided types are:
  82569. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  82570. * * 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)
  82571. * * size the size of the IcoSphere, optional default 1
  82572. * * sizeX allows stretching in the x direction, optional, default size
  82573. * * sizeY allows stretching in the y direction, optional, default size
  82574. * * sizeZ allows stretching in the z direction, optional, default size
  82575. * * 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
  82576. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  82577. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  82578. * * flat when true creates a flat shaded mesh, optional, default true
  82579. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  82580. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82581. * * 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)
  82582. * * 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)
  82583. * @returns the VertexData of the Polyhedron
  82584. */
  82585. static CreatePolyhedron(options: {
  82586. type?: number;
  82587. size?: number;
  82588. sizeX?: number;
  82589. sizeY?: number;
  82590. sizeZ?: number;
  82591. custom?: any;
  82592. faceUV?: Vector4[];
  82593. faceColors?: Color4[];
  82594. flat?: boolean;
  82595. sideOrientation?: number;
  82596. frontUVs?: Vector4;
  82597. backUVs?: Vector4;
  82598. }): VertexData;
  82599. /**
  82600. * Creates the VertexData for a TorusKnot
  82601. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  82602. * * radius the radius of the torus knot, optional, default 2
  82603. * * tube the thickness of the tube, optional, default 0.5
  82604. * * radialSegments the number of sides on each tube segments, optional, default 32
  82605. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  82606. * * p the number of windings around the z axis, optional, default 2
  82607. * * q the number of windings around the x axis, optional, default 3
  82608. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82609. * * 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)
  82610. * * 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)
  82611. * @returns the VertexData of the Torus Knot
  82612. */
  82613. static CreateTorusKnot(options: {
  82614. radius?: number;
  82615. tube?: number;
  82616. radialSegments?: number;
  82617. tubularSegments?: number;
  82618. p?: number;
  82619. q?: number;
  82620. sideOrientation?: number;
  82621. frontUVs?: Vector4;
  82622. backUVs?: Vector4;
  82623. }): VertexData;
  82624. /**
  82625. * Compute normals for given positions and indices
  82626. * @param positions an array of vertex positions, [...., x, y, z, ......]
  82627. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  82628. * @param normals an array of vertex normals, [...., x, y, z, ......]
  82629. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  82630. * * facetNormals : optional array of facet normals (vector3)
  82631. * * facetPositions : optional array of facet positions (vector3)
  82632. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  82633. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  82634. * * bInfo : optional bounding info, required for facetPartitioning computation
  82635. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  82636. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  82637. * * useRightHandedSystem: optional boolean to for right handed system computation
  82638. * * depthSort : optional boolean to enable the facet depth sort computation
  82639. * * distanceTo : optional Vector3 to compute the facet depth from this location
  82640. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  82641. */
  82642. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  82643. facetNormals?: any;
  82644. facetPositions?: any;
  82645. facetPartitioning?: any;
  82646. ratio?: number;
  82647. bInfo?: any;
  82648. bbSize?: Vector3;
  82649. subDiv?: any;
  82650. useRightHandedSystem?: boolean;
  82651. depthSort?: boolean;
  82652. distanceTo?: Vector3;
  82653. depthSortedFacets?: any;
  82654. }): void;
  82655. /** @hidden */
  82656. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  82657. /**
  82658. * Applies VertexData created from the imported parameters to the geometry
  82659. * @param parsedVertexData the parsed data from an imported file
  82660. * @param geometry the geometry to apply the VertexData to
  82661. */
  82662. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  82663. }
  82664. }
  82665. declare module BABYLON {
  82666. /**
  82667. * Class containing static functions to help procedurally build meshes
  82668. */
  82669. export class DiscBuilder {
  82670. /**
  82671. * Creates a plane polygonal mesh. By default, this is a disc
  82672. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  82673. * * 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
  82674. * * 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
  82675. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  82676. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  82677. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  82678. * @param name defines the name of the mesh
  82679. * @param options defines the options used to create the mesh
  82680. * @param scene defines the hosting scene
  82681. * @returns the plane polygonal mesh
  82682. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  82683. */
  82684. static CreateDisc(name: string, options: {
  82685. radius?: number;
  82686. tessellation?: number;
  82687. arc?: number;
  82688. updatable?: boolean;
  82689. sideOrientation?: number;
  82690. frontUVs?: Vector4;
  82691. backUVs?: Vector4;
  82692. }, scene?: Nullable<Scene>): Mesh;
  82693. }
  82694. }
  82695. declare module BABYLON {
  82696. /**
  82697. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  82698. *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.
  82699. * The SPS is also a particle system. It provides some methods to manage the particles.
  82700. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  82701. *
  82702. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  82703. */
  82704. export class SolidParticleSystem implements IDisposable {
  82705. /**
  82706. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  82707. * Example : var p = SPS.particles[i];
  82708. */
  82709. particles: SolidParticle[];
  82710. /**
  82711. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  82712. */
  82713. nbParticles: number;
  82714. /**
  82715. * If the particles must ever face the camera (default false). Useful for planar particles.
  82716. */
  82717. billboard: boolean;
  82718. /**
  82719. * Recompute normals when adding a shape
  82720. */
  82721. recomputeNormals: boolean;
  82722. /**
  82723. * This a counter ofr your own usage. It's not set by any SPS functions.
  82724. */
  82725. counter: number;
  82726. /**
  82727. * The SPS name. This name is also given to the underlying mesh.
  82728. */
  82729. name: string;
  82730. /**
  82731. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  82732. */
  82733. mesh: Mesh;
  82734. /**
  82735. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  82736. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  82737. */
  82738. vars: any;
  82739. /**
  82740. * This array is populated when the SPS is set as 'pickable'.
  82741. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  82742. * Each element of this array is an object `{idx: int, faceId: int}`.
  82743. * `idx` is the picked particle index in the `SPS.particles` array
  82744. * `faceId` is the picked face index counted within this particle.
  82745. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  82746. */
  82747. pickedParticles: {
  82748. idx: number;
  82749. faceId: number;
  82750. }[];
  82751. /**
  82752. * This array is populated when `enableDepthSort` is set to true.
  82753. * Each element of this array is an instance of the class DepthSortedParticle.
  82754. */
  82755. depthSortedParticles: DepthSortedParticle[];
  82756. /**
  82757. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  82758. * @hidden
  82759. */
  82760. _bSphereOnly: boolean;
  82761. /**
  82762. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  82763. * @hidden
  82764. */
  82765. _bSphereRadiusFactor: number;
  82766. private _scene;
  82767. private _positions;
  82768. private _indices;
  82769. private _normals;
  82770. private _colors;
  82771. private _uvs;
  82772. private _indices32;
  82773. private _positions32;
  82774. private _normals32;
  82775. private _fixedNormal32;
  82776. private _colors32;
  82777. private _uvs32;
  82778. private _index;
  82779. private _updatable;
  82780. private _pickable;
  82781. private _isVisibilityBoxLocked;
  82782. private _alwaysVisible;
  82783. private _depthSort;
  82784. private _shapeCounter;
  82785. private _copy;
  82786. private _color;
  82787. private _computeParticleColor;
  82788. private _computeParticleTexture;
  82789. private _computeParticleRotation;
  82790. private _computeParticleVertex;
  82791. private _computeBoundingBox;
  82792. private _depthSortParticles;
  82793. private _camera;
  82794. private _mustUnrotateFixedNormals;
  82795. private _particlesIntersect;
  82796. private _needs32Bits;
  82797. /**
  82798. * Creates a SPS (Solid Particle System) object.
  82799. * @param name (String) is the SPS name, this will be the underlying mesh name.
  82800. * @param scene (Scene) is the scene in which the SPS is added.
  82801. * @param options defines the options of the sps e.g.
  82802. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  82803. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  82804. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  82805. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  82806. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  82807. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  82808. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  82809. */
  82810. constructor(name: string, scene: Scene, options?: {
  82811. updatable?: boolean;
  82812. isPickable?: boolean;
  82813. enableDepthSort?: boolean;
  82814. particleIntersection?: boolean;
  82815. boundingSphereOnly?: boolean;
  82816. bSphereRadiusFactor?: number;
  82817. });
  82818. /**
  82819. * Builds the SPS underlying mesh. Returns a standard Mesh.
  82820. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  82821. * @returns the created mesh
  82822. */
  82823. buildMesh(): Mesh;
  82824. /**
  82825. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  82826. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  82827. * Thus the particles generated from `digest()` have their property `position` set yet.
  82828. * @param mesh ( Mesh ) is the mesh to be digested
  82829. * @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
  82830. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  82831. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  82832. * @returns the current SPS
  82833. */
  82834. digest(mesh: Mesh, options?: {
  82835. facetNb?: number;
  82836. number?: number;
  82837. delta?: number;
  82838. }): SolidParticleSystem;
  82839. private _unrotateFixedNormals;
  82840. private _resetCopy;
  82841. private _meshBuilder;
  82842. private _posToShape;
  82843. private _uvsToShapeUV;
  82844. private _addParticle;
  82845. /**
  82846. * Adds some particles to the SPS from the model shape. Returns the shape id.
  82847. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  82848. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  82849. * @param nb (positive integer) the number of particles to be created from this model
  82850. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  82851. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  82852. * @returns the number of shapes in the system
  82853. */
  82854. addShape(mesh: Mesh, nb: number, options?: {
  82855. positionFunction?: any;
  82856. vertexFunction?: any;
  82857. }): number;
  82858. private _rebuildParticle;
  82859. /**
  82860. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  82861. * @returns the SPS.
  82862. */
  82863. rebuildMesh(): SolidParticleSystem;
  82864. /**
  82865. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  82866. * This method calls `updateParticle()` for each particle of the SPS.
  82867. * For an animated SPS, it is usually called within the render loop.
  82868. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  82869. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  82870. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  82871. * @returns the SPS.
  82872. */
  82873. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  82874. /**
  82875. * Disposes the SPS.
  82876. */
  82877. dispose(): void;
  82878. /**
  82879. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  82880. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82881. * @returns the SPS.
  82882. */
  82883. refreshVisibleSize(): SolidParticleSystem;
  82884. /**
  82885. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  82886. * @param size the size (float) of the visibility box
  82887. * note : this doesn't lock the SPS mesh bounding box.
  82888. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82889. */
  82890. setVisibilityBox(size: number): void;
  82891. /**
  82892. * Gets whether the SPS as always visible or not
  82893. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82894. */
  82895. /**
  82896. * Sets the SPS as always visible or not
  82897. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82898. */
  82899. isAlwaysVisible: boolean;
  82900. /**
  82901. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  82902. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82903. */
  82904. /**
  82905. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  82906. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82907. */
  82908. isVisibilityBoxLocked: boolean;
  82909. /**
  82910. * Tells to `setParticles()` to compute the particle rotations or not.
  82911. * Default value : true. The SPS is faster when it's set to false.
  82912. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  82913. */
  82914. /**
  82915. * Gets if `setParticles()` computes the particle rotations or not.
  82916. * Default value : true. The SPS is faster when it's set to false.
  82917. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  82918. */
  82919. computeParticleRotation: boolean;
  82920. /**
  82921. * Tells to `setParticles()` to compute the particle colors or not.
  82922. * Default value : true. The SPS is faster when it's set to false.
  82923. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  82924. */
  82925. /**
  82926. * Gets if `setParticles()` computes the particle colors or not.
  82927. * Default value : true. The SPS is faster when it's set to false.
  82928. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  82929. */
  82930. computeParticleColor: boolean;
  82931. /**
  82932. * Gets if `setParticles()` computes the particle textures or not.
  82933. * Default value : true. The SPS is faster when it's set to false.
  82934. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  82935. */
  82936. computeParticleTexture: boolean;
  82937. /**
  82938. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  82939. * Default value : false. The SPS is faster when it's set to false.
  82940. * Note : the particle custom vertex positions aren't stored values.
  82941. */
  82942. /**
  82943. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  82944. * Default value : false. The SPS is faster when it's set to false.
  82945. * Note : the particle custom vertex positions aren't stored values.
  82946. */
  82947. computeParticleVertex: boolean;
  82948. /**
  82949. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  82950. */
  82951. /**
  82952. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  82953. */
  82954. computeBoundingBox: boolean;
  82955. /**
  82956. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  82957. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  82958. * Default : `true`
  82959. */
  82960. /**
  82961. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  82962. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  82963. * Default : `true`
  82964. */
  82965. depthSortParticles: boolean;
  82966. /**
  82967. * This function does nothing. It may be overwritten to set all the particle first values.
  82968. * The SPS doesn't call this function, you may have to call it by your own.
  82969. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  82970. */
  82971. initParticles(): void;
  82972. /**
  82973. * This function does nothing. It may be overwritten to recycle a particle.
  82974. * The SPS doesn't call this function, you may have to call it by your own.
  82975. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  82976. * @param particle The particle to recycle
  82977. * @returns the recycled particle
  82978. */
  82979. recycleParticle(particle: SolidParticle): SolidParticle;
  82980. /**
  82981. * Updates a particle : this function should be overwritten by the user.
  82982. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  82983. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  82984. * @example : just set a particle position or velocity and recycle conditions
  82985. * @param particle The particle to update
  82986. * @returns the updated particle
  82987. */
  82988. updateParticle(particle: SolidParticle): SolidParticle;
  82989. /**
  82990. * Updates a vertex of a particle : it can be overwritten by the user.
  82991. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  82992. * @param particle the current particle
  82993. * @param vertex the current index of the current particle
  82994. * @param pt the index of the current vertex in the particle shape
  82995. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  82996. * @example : just set a vertex particle position
  82997. * @returns the updated vertex
  82998. */
  82999. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  83000. /**
  83001. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  83002. * This does nothing and may be overwritten by the user.
  83003. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83004. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83005. * @param update the boolean update value actually passed to setParticles()
  83006. */
  83007. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  83008. /**
  83009. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  83010. * This will be passed three parameters.
  83011. * This does nothing and may be overwritten by the user.
  83012. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83013. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83014. * @param update the boolean update value actually passed to setParticles()
  83015. */
  83016. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  83017. }
  83018. }
  83019. declare module BABYLON {
  83020. /**
  83021. * Represents one particle of a solid particle system.
  83022. */
  83023. export class SolidParticle {
  83024. /**
  83025. * particle global index
  83026. */
  83027. idx: number;
  83028. /**
  83029. * The color of the particle
  83030. */
  83031. color: Nullable<Color4>;
  83032. /**
  83033. * The world space position of the particle.
  83034. */
  83035. position: Vector3;
  83036. /**
  83037. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  83038. */
  83039. rotation: Vector3;
  83040. /**
  83041. * The world space rotation quaternion of the particle.
  83042. */
  83043. rotationQuaternion: Nullable<Quaternion>;
  83044. /**
  83045. * The scaling of the particle.
  83046. */
  83047. scaling: Vector3;
  83048. /**
  83049. * The uvs of the particle.
  83050. */
  83051. uvs: Vector4;
  83052. /**
  83053. * The current speed of the particle.
  83054. */
  83055. velocity: Vector3;
  83056. /**
  83057. * The pivot point in the particle local space.
  83058. */
  83059. pivot: Vector3;
  83060. /**
  83061. * Must the particle be translated from its pivot point in its local space ?
  83062. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  83063. * Default : false
  83064. */
  83065. translateFromPivot: boolean;
  83066. /**
  83067. * Is the particle active or not ?
  83068. */
  83069. alive: boolean;
  83070. /**
  83071. * Is the particle visible or not ?
  83072. */
  83073. isVisible: boolean;
  83074. /**
  83075. * Index of this particle in the global "positions" array (Internal use)
  83076. * @hidden
  83077. */
  83078. _pos: number;
  83079. /**
  83080. * @hidden Index of this particle in the global "indices" array (Internal use)
  83081. */
  83082. _ind: number;
  83083. /**
  83084. * @hidden ModelShape of this particle (Internal use)
  83085. */
  83086. _model: ModelShape;
  83087. /**
  83088. * ModelShape id of this particle
  83089. */
  83090. shapeId: number;
  83091. /**
  83092. * Index of the particle in its shape id (Internal use)
  83093. */
  83094. idxInShape: number;
  83095. /**
  83096. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  83097. */
  83098. _modelBoundingInfo: BoundingInfo;
  83099. /**
  83100. * @hidden Particle BoundingInfo object (Internal use)
  83101. */
  83102. _boundingInfo: BoundingInfo;
  83103. /**
  83104. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  83105. */
  83106. _sps: SolidParticleSystem;
  83107. /**
  83108. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  83109. */
  83110. _stillInvisible: boolean;
  83111. /**
  83112. * @hidden Last computed particle rotation matrix
  83113. */
  83114. _rotationMatrix: number[];
  83115. /**
  83116. * Parent particle Id, if any.
  83117. * Default null.
  83118. */
  83119. parentId: Nullable<number>;
  83120. /**
  83121. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  83122. * The possible values are :
  83123. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  83124. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  83125. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  83126. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  83127. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  83128. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  83129. * */
  83130. cullingStrategy: number;
  83131. /**
  83132. * @hidden Internal global position in the SPS.
  83133. */
  83134. _globalPosition: Vector3;
  83135. /**
  83136. * Creates a Solid Particle object.
  83137. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  83138. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  83139. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  83140. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  83141. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  83142. * @param shapeId (integer) is the model shape identifier in the SPS.
  83143. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  83144. * @param sps defines the sps it is associated to
  83145. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  83146. */
  83147. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  83148. /**
  83149. * Legacy support, changed scale to scaling
  83150. */
  83151. /**
  83152. * Legacy support, changed scale to scaling
  83153. */
  83154. scale: Vector3;
  83155. /**
  83156. * Legacy support, changed quaternion to rotationQuaternion
  83157. */
  83158. /**
  83159. * Legacy support, changed quaternion to rotationQuaternion
  83160. */
  83161. quaternion: Nullable<Quaternion>;
  83162. /**
  83163. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  83164. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  83165. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  83166. * @returns true if it intersects
  83167. */
  83168. intersectsMesh(target: Mesh | SolidParticle): boolean;
  83169. /**
  83170. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  83171. * A particle is in the frustum if its bounding box intersects the frustum
  83172. * @param frustumPlanes defines the frustum to test
  83173. * @returns true if the particle is in the frustum planes
  83174. */
  83175. isInFrustum(frustumPlanes: Plane[]): boolean;
  83176. /**
  83177. * get the rotation matrix of the particle
  83178. * @hidden
  83179. */
  83180. getRotationMatrix(m: Matrix): void;
  83181. }
  83182. /**
  83183. * Represents the shape of the model used by one particle of a solid particle system.
  83184. * SPS internal tool, don't use it manually.
  83185. */
  83186. export class ModelShape {
  83187. /**
  83188. * The shape id
  83189. * @hidden
  83190. */
  83191. shapeID: number;
  83192. /**
  83193. * flat array of model positions (internal use)
  83194. * @hidden
  83195. */
  83196. _shape: Vector3[];
  83197. /**
  83198. * flat array of model UVs (internal use)
  83199. * @hidden
  83200. */
  83201. _shapeUV: number[];
  83202. /**
  83203. * length of the shape in the model indices array (internal use)
  83204. * @hidden
  83205. */
  83206. _indicesLength: number;
  83207. /**
  83208. * Custom position function (internal use)
  83209. * @hidden
  83210. */
  83211. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  83212. /**
  83213. * Custom vertex function (internal use)
  83214. * @hidden
  83215. */
  83216. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  83217. /**
  83218. * 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.
  83219. * SPS internal tool, don't use it manually.
  83220. * @hidden
  83221. */
  83222. 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>);
  83223. }
  83224. /**
  83225. * Represents a Depth Sorted Particle in the solid particle system.
  83226. */
  83227. export class DepthSortedParticle {
  83228. /**
  83229. * Index of the particle in the "indices" array
  83230. */
  83231. ind: number;
  83232. /**
  83233. * Length of the particle shape in the "indices" array
  83234. */
  83235. indicesLength: number;
  83236. /**
  83237. * Squared distance from the particle to the camera
  83238. */
  83239. sqDistance: number;
  83240. }
  83241. }
  83242. declare module BABYLON {
  83243. /**
  83244. * Class used to store all common mesh properties
  83245. */
  83246. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  83247. /** No occlusion */
  83248. static OCCLUSION_TYPE_NONE: number;
  83249. /** Occlusion set to optimisitic */
  83250. static OCCLUSION_TYPE_OPTIMISTIC: number;
  83251. /** Occlusion set to strict */
  83252. static OCCLUSION_TYPE_STRICT: number;
  83253. /** Use an accurante occlusion algorithm */
  83254. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  83255. /** Use a conservative occlusion algorithm */
  83256. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  83257. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  83258. * Test order :
  83259. * Is the bounding sphere outside the frustum ?
  83260. * If not, are the bounding box vertices outside the frustum ?
  83261. * It not, then the cullable object is in the frustum.
  83262. */
  83263. static readonly CULLINGSTRATEGY_STANDARD: number;
  83264. /** Culling strategy : Bounding Sphere Only.
  83265. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  83266. * It's also less accurate than the standard because some not visible objects can still be selected.
  83267. * Test : is the bounding sphere outside the frustum ?
  83268. * If not, then the cullable object is in the frustum.
  83269. */
  83270. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  83271. /** Culling strategy : Optimistic Inclusion.
  83272. * This in an inclusion test first, then the standard exclusion test.
  83273. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  83274. * 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.
  83275. * Anyway, it's as accurate as the standard strategy.
  83276. * Test :
  83277. * Is the cullable object bounding sphere center in the frustum ?
  83278. * If not, apply the default culling strategy.
  83279. */
  83280. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  83281. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  83282. * This in an inclusion test first, then the bounding sphere only exclusion test.
  83283. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  83284. * 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.
  83285. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  83286. * Test :
  83287. * Is the cullable object bounding sphere center in the frustum ?
  83288. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  83289. */
  83290. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  83291. /**
  83292. * No billboard
  83293. */
  83294. static readonly BILLBOARDMODE_NONE: number;
  83295. /** Billboard on X axis */
  83296. static readonly BILLBOARDMODE_X: number;
  83297. /** Billboard on Y axis */
  83298. static readonly BILLBOARDMODE_Y: number;
  83299. /** Billboard on Z axis */
  83300. static readonly BILLBOARDMODE_Z: number;
  83301. /** Billboard on all axes */
  83302. static readonly BILLBOARDMODE_ALL: number;
  83303. private _facetData;
  83304. /**
  83305. * The culling strategy to use to check whether the mesh must be rendered or not.
  83306. * This value can be changed at any time and will be used on the next render mesh selection.
  83307. * The possible values are :
  83308. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  83309. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  83310. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  83311. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  83312. * Please read each static variable documentation to get details about the culling process.
  83313. * */
  83314. cullingStrategy: number;
  83315. /**
  83316. * Gets the number of facets in the mesh
  83317. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  83318. */
  83319. readonly facetNb: number;
  83320. /**
  83321. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  83322. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  83323. */
  83324. partitioningSubdivisions: number;
  83325. /**
  83326. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  83327. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  83328. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  83329. */
  83330. partitioningBBoxRatio: number;
  83331. /**
  83332. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  83333. * Works only for updatable meshes.
  83334. * Doesn't work with multi-materials
  83335. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  83336. */
  83337. mustDepthSortFacets: boolean;
  83338. /**
  83339. * The location (Vector3) where the facet depth sort must be computed from.
  83340. * By default, the active camera position.
  83341. * Used only when facet depth sort is enabled
  83342. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  83343. */
  83344. facetDepthSortFrom: Vector3;
  83345. /**
  83346. * gets a boolean indicating if facetData is enabled
  83347. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  83348. */
  83349. readonly isFacetDataEnabled: boolean;
  83350. /** @hidden */
  83351. _updateNonUniformScalingState(value: boolean): boolean;
  83352. /**
  83353. * An event triggered when this mesh collides with another one
  83354. */
  83355. onCollideObservable: Observable<AbstractMesh>;
  83356. private _onCollideObserver;
  83357. /** Set a function to call when this mesh collides with another one */
  83358. onCollide: () => void;
  83359. /**
  83360. * An event triggered when the collision's position changes
  83361. */
  83362. onCollisionPositionChangeObservable: Observable<Vector3>;
  83363. private _onCollisionPositionChangeObserver;
  83364. /** Set a function to call when the collision's position changes */
  83365. onCollisionPositionChange: () => void;
  83366. /**
  83367. * An event triggered when material is changed
  83368. */
  83369. onMaterialChangedObservable: Observable<AbstractMesh>;
  83370. /**
  83371. * Gets or sets the orientation for POV movement & rotation
  83372. */
  83373. definedFacingForward: boolean;
  83374. /** @hidden */
  83375. _occlusionQuery: Nullable<WebGLQuery>;
  83376. private _visibility;
  83377. /** @hidden */
  83378. _isActive: boolean;
  83379. /** @hidden */
  83380. _renderingGroup: RenderingGroup;
  83381. /**
  83382. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  83383. */
  83384. /**
  83385. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  83386. */
  83387. visibility: number;
  83388. /** Gets or sets the alpha index used to sort transparent meshes
  83389. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  83390. */
  83391. alphaIndex: number;
  83392. /**
  83393. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  83394. */
  83395. isVisible: boolean;
  83396. /**
  83397. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  83398. */
  83399. isPickable: boolean;
  83400. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  83401. showSubMeshesBoundingBox: boolean;
  83402. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  83403. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  83404. */
  83405. isBlocker: boolean;
  83406. /**
  83407. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  83408. */
  83409. enablePointerMoveEvents: boolean;
  83410. /**
  83411. * Specifies the rendering group id for this mesh (0 by default)
  83412. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  83413. */
  83414. renderingGroupId: number;
  83415. private _material;
  83416. /** Gets or sets current material */
  83417. material: Nullable<Material>;
  83418. private _receiveShadows;
  83419. /**
  83420. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  83421. * @see http://doc.babylonjs.com/babylon101/shadows
  83422. */
  83423. receiveShadows: boolean;
  83424. /** Defines color to use when rendering outline */
  83425. outlineColor: Color3;
  83426. /** Define width to use when rendering outline */
  83427. outlineWidth: number;
  83428. /** Defines color to use when rendering overlay */
  83429. overlayColor: Color3;
  83430. /** Defines alpha to use when rendering overlay */
  83431. overlayAlpha: number;
  83432. private _hasVertexAlpha;
  83433. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  83434. hasVertexAlpha: boolean;
  83435. private _useVertexColors;
  83436. /** 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) */
  83437. useVertexColors: boolean;
  83438. private _computeBonesUsingShaders;
  83439. /**
  83440. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  83441. */
  83442. computeBonesUsingShaders: boolean;
  83443. private _numBoneInfluencers;
  83444. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  83445. numBoneInfluencers: number;
  83446. private _applyFog;
  83447. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  83448. applyFog: boolean;
  83449. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  83450. useOctreeForRenderingSelection: boolean;
  83451. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  83452. useOctreeForPicking: boolean;
  83453. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  83454. useOctreeForCollisions: boolean;
  83455. private _layerMask;
  83456. /**
  83457. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  83458. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  83459. */
  83460. layerMask: number;
  83461. /**
  83462. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  83463. */
  83464. alwaysSelectAsActiveMesh: boolean;
  83465. /**
  83466. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  83467. */
  83468. doNotSyncBoundingInfo: boolean;
  83469. /**
  83470. * Gets or sets the current action manager
  83471. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83472. */
  83473. actionManager: Nullable<AbstractActionManager>;
  83474. private _checkCollisions;
  83475. private _collisionMask;
  83476. private _collisionGroup;
  83477. /**
  83478. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  83479. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83480. */
  83481. ellipsoid: Vector3;
  83482. /**
  83483. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  83484. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83485. */
  83486. ellipsoidOffset: Vector3;
  83487. private _collider;
  83488. private _oldPositionForCollisions;
  83489. private _diffPositionForCollisions;
  83490. /**
  83491. * Gets or sets a collision mask used to mask collisions (default is -1).
  83492. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  83493. */
  83494. collisionMask: number;
  83495. /**
  83496. * Gets or sets the current collision group mask (-1 by default).
  83497. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  83498. */
  83499. collisionGroup: number;
  83500. /**
  83501. * Defines edge width used when edgesRenderer is enabled
  83502. * @see https://www.babylonjs-playground.com/#10OJSG#13
  83503. */
  83504. edgesWidth: number;
  83505. /**
  83506. * Defines edge color used when edgesRenderer is enabled
  83507. * @see https://www.babylonjs-playground.com/#10OJSG#13
  83508. */
  83509. edgesColor: Color4;
  83510. /** @hidden */
  83511. _edgesRenderer: Nullable<IEdgesRenderer>;
  83512. /** @hidden */
  83513. _masterMesh: Nullable<AbstractMesh>;
  83514. /** @hidden */
  83515. _boundingInfo: Nullable<BoundingInfo>;
  83516. /** @hidden */
  83517. _renderId: number;
  83518. /**
  83519. * Gets or sets the list of subMeshes
  83520. * @see http://doc.babylonjs.com/how_to/multi_materials
  83521. */
  83522. subMeshes: SubMesh[];
  83523. /** @hidden */
  83524. _intersectionsInProgress: AbstractMesh[];
  83525. /** @hidden */
  83526. _unIndexed: boolean;
  83527. /** @hidden */
  83528. _lightSources: Light[];
  83529. /** @hidden */
  83530. readonly _positions: Nullable<Vector3[]>;
  83531. /** @hidden */
  83532. _waitingActions: any;
  83533. /** @hidden */
  83534. _waitingFreezeWorldMatrix: Nullable<boolean>;
  83535. private _skeleton;
  83536. /** @hidden */
  83537. _bonesTransformMatrices: Nullable<Float32Array>;
  83538. /**
  83539. * Gets or sets a skeleton to apply skining transformations
  83540. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  83541. */
  83542. skeleton: Nullable<Skeleton>;
  83543. /**
  83544. * An event triggered when the mesh is rebuilt.
  83545. */
  83546. onRebuildObservable: Observable<AbstractMesh>;
  83547. /**
  83548. * Creates a new AbstractMesh
  83549. * @param name defines the name of the mesh
  83550. * @param scene defines the hosting scene
  83551. */
  83552. constructor(name: string, scene?: Nullable<Scene>);
  83553. /**
  83554. * Returns the string "AbstractMesh"
  83555. * @returns "AbstractMesh"
  83556. */
  83557. getClassName(): string;
  83558. /**
  83559. * Gets a string representation of the current mesh
  83560. * @param fullDetails defines a boolean indicating if full details must be included
  83561. * @returns a string representation of the current mesh
  83562. */
  83563. toString(fullDetails?: boolean): string;
  83564. /**
  83565. * @hidden
  83566. */
  83567. protected _getEffectiveParent(): Nullable<Node>;
  83568. /** @hidden */
  83569. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  83570. /** @hidden */
  83571. _rebuild(): void;
  83572. /** @hidden */
  83573. _resyncLightSources(): void;
  83574. /** @hidden */
  83575. _resyncLighSource(light: Light): void;
  83576. /** @hidden */
  83577. _unBindEffect(): void;
  83578. /** @hidden */
  83579. _removeLightSource(light: Light): void;
  83580. private _markSubMeshesAsDirty;
  83581. /** @hidden */
  83582. _markSubMeshesAsLightDirty(): void;
  83583. /** @hidden */
  83584. _markSubMeshesAsAttributesDirty(): void;
  83585. /** @hidden */
  83586. _markSubMeshesAsMiscDirty(): void;
  83587. /**
  83588. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  83589. */
  83590. scaling: Vector3;
  83591. /**
  83592. * Returns true if the mesh is blocked. Implemented by child classes
  83593. */
  83594. readonly isBlocked: boolean;
  83595. /**
  83596. * Returns the mesh itself by default. Implemented by child classes
  83597. * @param camera defines the camera to use to pick the right LOD level
  83598. * @returns the currentAbstractMesh
  83599. */
  83600. getLOD(camera: Camera): Nullable<AbstractMesh>;
  83601. /**
  83602. * Returns 0 by default. Implemented by child classes
  83603. * @returns an integer
  83604. */
  83605. getTotalVertices(): number;
  83606. /**
  83607. * Returns a positive integer : the total number of indices in this mesh geometry.
  83608. * @returns the numner of indices or zero if the mesh has no geometry.
  83609. */
  83610. getTotalIndices(): number;
  83611. /**
  83612. * Returns null by default. Implemented by child classes
  83613. * @returns null
  83614. */
  83615. getIndices(): Nullable<IndicesArray>;
  83616. /**
  83617. * Returns the array of the requested vertex data kind. Implemented by child classes
  83618. * @param kind defines the vertex data kind to use
  83619. * @returns null
  83620. */
  83621. getVerticesData(kind: string): Nullable<FloatArray>;
  83622. /**
  83623. * Sets the vertex data of the mesh geometry for the requested `kind`.
  83624. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  83625. * Note that a new underlying VertexBuffer object is created each call.
  83626. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  83627. * @param kind defines vertex data kind:
  83628. * * VertexBuffer.PositionKind
  83629. * * VertexBuffer.UVKind
  83630. * * VertexBuffer.UV2Kind
  83631. * * VertexBuffer.UV3Kind
  83632. * * VertexBuffer.UV4Kind
  83633. * * VertexBuffer.UV5Kind
  83634. * * VertexBuffer.UV6Kind
  83635. * * VertexBuffer.ColorKind
  83636. * * VertexBuffer.MatricesIndicesKind
  83637. * * VertexBuffer.MatricesIndicesExtraKind
  83638. * * VertexBuffer.MatricesWeightsKind
  83639. * * VertexBuffer.MatricesWeightsExtraKind
  83640. * @param data defines the data source
  83641. * @param updatable defines if the data must be flagged as updatable (or static)
  83642. * @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
  83643. * @returns the current mesh
  83644. */
  83645. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  83646. /**
  83647. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  83648. * If the mesh has no geometry, it is simply returned as it is.
  83649. * @param kind defines vertex data kind:
  83650. * * VertexBuffer.PositionKind
  83651. * * VertexBuffer.UVKind
  83652. * * VertexBuffer.UV2Kind
  83653. * * VertexBuffer.UV3Kind
  83654. * * VertexBuffer.UV4Kind
  83655. * * VertexBuffer.UV5Kind
  83656. * * VertexBuffer.UV6Kind
  83657. * * VertexBuffer.ColorKind
  83658. * * VertexBuffer.MatricesIndicesKind
  83659. * * VertexBuffer.MatricesIndicesExtraKind
  83660. * * VertexBuffer.MatricesWeightsKind
  83661. * * VertexBuffer.MatricesWeightsExtraKind
  83662. * @param data defines the data source
  83663. * @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
  83664. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  83665. * @returns the current mesh
  83666. */
  83667. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  83668. /**
  83669. * Sets the mesh indices,
  83670. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  83671. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  83672. * @param totalVertices Defines the total number of vertices
  83673. * @returns the current mesh
  83674. */
  83675. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  83676. /**
  83677. * Gets a boolean indicating if specific vertex data is present
  83678. * @param kind defines the vertex data kind to use
  83679. * @returns true is data kind is present
  83680. */
  83681. isVerticesDataPresent(kind: string): boolean;
  83682. /**
  83683. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  83684. * @returns a BoundingInfo
  83685. */
  83686. getBoundingInfo(): BoundingInfo;
  83687. /**
  83688. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  83689. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  83690. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  83691. * @returns the current mesh
  83692. */
  83693. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  83694. /**
  83695. * Overwrite the current bounding info
  83696. * @param boundingInfo defines the new bounding info
  83697. * @returns the current mesh
  83698. */
  83699. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  83700. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  83701. readonly useBones: boolean;
  83702. /** @hidden */
  83703. _preActivate(): void;
  83704. /** @hidden */
  83705. _preActivateForIntermediateRendering(renderId: number): void;
  83706. /** @hidden */
  83707. _activate(renderId: number): boolean;
  83708. /** @hidden */
  83709. _freeze(): void;
  83710. /** @hidden */
  83711. _unFreeze(): void;
  83712. /**
  83713. * Gets the current world matrix
  83714. * @returns a Matrix
  83715. */
  83716. getWorldMatrix(): Matrix;
  83717. /** @hidden */
  83718. _getWorldMatrixDeterminant(): number;
  83719. /**
  83720. * Perform relative position change from the point of view of behind the front of the mesh.
  83721. * This is performed taking into account the meshes current rotation, so you do not have to care.
  83722. * Supports definition of mesh facing forward or backward
  83723. * @param amountRight defines the distance on the right axis
  83724. * @param amountUp defines the distance on the up axis
  83725. * @param amountForward defines the distance on the forward axis
  83726. * @returns the current mesh
  83727. */
  83728. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  83729. /**
  83730. * Calculate relative position change from the point of view of behind the front of the mesh.
  83731. * This is performed taking into account the meshes current rotation, so you do not have to care.
  83732. * Supports definition of mesh facing forward or backward
  83733. * @param amountRight defines the distance on the right axis
  83734. * @param amountUp defines the distance on the up axis
  83735. * @param amountForward defines the distance on the forward axis
  83736. * @returns the new displacement vector
  83737. */
  83738. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  83739. /**
  83740. * Perform relative rotation change from the point of view of behind the front of the mesh.
  83741. * Supports definition of mesh facing forward or backward
  83742. * @param flipBack defines the flip
  83743. * @param twirlClockwise defines the twirl
  83744. * @param tiltRight defines the tilt
  83745. * @returns the current mesh
  83746. */
  83747. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  83748. /**
  83749. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  83750. * Supports definition of mesh facing forward or backward.
  83751. * @param flipBack defines the flip
  83752. * @param twirlClockwise defines the twirl
  83753. * @param tiltRight defines the tilt
  83754. * @returns the new rotation vector
  83755. */
  83756. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  83757. /**
  83758. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  83759. * @param includeDescendants Include bounding info from descendants as well (true by default)
  83760. * @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
  83761. * @returns the new bounding vectors
  83762. */
  83763. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  83764. min: Vector3;
  83765. max: Vector3;
  83766. };
  83767. /**
  83768. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  83769. * This means the mesh underlying bounding box and sphere are recomputed.
  83770. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  83771. * @returns the current mesh
  83772. */
  83773. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  83774. /** @hidden */
  83775. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  83776. /** @hidden */
  83777. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  83778. /** @hidden */
  83779. _updateBoundingInfo(): AbstractMesh;
  83780. /** @hidden */
  83781. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  83782. /** @hidden */
  83783. protected _afterComputeWorldMatrix(): void;
  83784. /** @hidden */
  83785. readonly _effectiveMesh: AbstractMesh;
  83786. /**
  83787. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  83788. * A mesh is in the frustum if its bounding box intersects the frustum
  83789. * @param frustumPlanes defines the frustum to test
  83790. * @returns true if the mesh is in the frustum planes
  83791. */
  83792. isInFrustum(frustumPlanes: Plane[]): boolean;
  83793. /**
  83794. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  83795. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  83796. * @param frustumPlanes defines the frustum to test
  83797. * @returns true if the mesh is completely in the frustum planes
  83798. */
  83799. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  83800. /**
  83801. * True if the mesh intersects another mesh or a SolidParticle object
  83802. * @param mesh defines a target mesh or SolidParticle to test
  83803. * @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)
  83804. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  83805. * @returns true if there is an intersection
  83806. */
  83807. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  83808. /**
  83809. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  83810. * @param point defines the point to test
  83811. * @returns true if there is an intersection
  83812. */
  83813. intersectsPoint(point: Vector3): boolean;
  83814. /**
  83815. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  83816. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83817. */
  83818. checkCollisions: boolean;
  83819. /**
  83820. * Gets Collider object used to compute collisions (not physics)
  83821. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83822. */
  83823. readonly collider: Collider;
  83824. /**
  83825. * Move the mesh using collision engine
  83826. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83827. * @param displacement defines the requested displacement vector
  83828. * @returns the current mesh
  83829. */
  83830. moveWithCollisions(displacement: Vector3): AbstractMesh;
  83831. private _onCollisionPositionChange;
  83832. /** @hidden */
  83833. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  83834. /** @hidden */
  83835. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  83836. /** @hidden */
  83837. _checkCollision(collider: Collider): AbstractMesh;
  83838. /** @hidden */
  83839. _generatePointsArray(): boolean;
  83840. /**
  83841. * Checks if the passed Ray intersects with the mesh
  83842. * @param ray defines the ray to use
  83843. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  83844. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  83845. * @returns the picking info
  83846. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  83847. */
  83848. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  83849. /**
  83850. * Clones the current mesh
  83851. * @param name defines the mesh name
  83852. * @param newParent defines the new mesh parent
  83853. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  83854. * @returns the new mesh
  83855. */
  83856. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  83857. /**
  83858. * Disposes all the submeshes of the current meshnp
  83859. * @returns the current mesh
  83860. */
  83861. releaseSubMeshes(): AbstractMesh;
  83862. /**
  83863. * Releases resources associated with this abstract mesh.
  83864. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  83865. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  83866. */
  83867. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  83868. /**
  83869. * Adds the passed mesh as a child to the current mesh
  83870. * @param mesh defines the child mesh
  83871. * @returns the current mesh
  83872. */
  83873. addChild(mesh: AbstractMesh): AbstractMesh;
  83874. /**
  83875. * Removes the passed mesh from the current mesh children list
  83876. * @param mesh defines the child mesh
  83877. * @returns the current mesh
  83878. */
  83879. removeChild(mesh: AbstractMesh): AbstractMesh;
  83880. /** @hidden */
  83881. private _initFacetData;
  83882. /**
  83883. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  83884. * This method can be called within the render loop.
  83885. * 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
  83886. * @returns the current mesh
  83887. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83888. */
  83889. updateFacetData(): AbstractMesh;
  83890. /**
  83891. * Returns the facetLocalNormals array.
  83892. * The normals are expressed in the mesh local spac
  83893. * @returns an array of Vector3
  83894. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83895. */
  83896. getFacetLocalNormals(): Vector3[];
  83897. /**
  83898. * Returns the facetLocalPositions array.
  83899. * The facet positions are expressed in the mesh local space
  83900. * @returns an array of Vector3
  83901. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83902. */
  83903. getFacetLocalPositions(): Vector3[];
  83904. /**
  83905. * Returns the facetLocalPartioning array
  83906. * @returns an array of array of numbers
  83907. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83908. */
  83909. getFacetLocalPartitioning(): number[][];
  83910. /**
  83911. * Returns the i-th facet position in the world system.
  83912. * This method allocates a new Vector3 per call
  83913. * @param i defines the facet index
  83914. * @returns a new Vector3
  83915. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83916. */
  83917. getFacetPosition(i: number): Vector3;
  83918. /**
  83919. * Sets the reference Vector3 with the i-th facet position in the world system
  83920. * @param i defines the facet index
  83921. * @param ref defines the target vector
  83922. * @returns the current mesh
  83923. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83924. */
  83925. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  83926. /**
  83927. * Returns the i-th facet normal in the world system.
  83928. * This method allocates a new Vector3 per call
  83929. * @param i defines the facet index
  83930. * @returns a new Vector3
  83931. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83932. */
  83933. getFacetNormal(i: number): Vector3;
  83934. /**
  83935. * Sets the reference Vector3 with the i-th facet normal in the world system
  83936. * @param i defines the facet index
  83937. * @param ref defines the target vector
  83938. * @returns the current mesh
  83939. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83940. */
  83941. getFacetNormalToRef(i: number, ref: Vector3): this;
  83942. /**
  83943. * 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)
  83944. * @param x defines x coordinate
  83945. * @param y defines y coordinate
  83946. * @param z defines z coordinate
  83947. * @returns the array of facet indexes
  83948. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83949. */
  83950. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  83951. /**
  83952. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  83953. * @param projected sets as the (x,y,z) world projection on the facet
  83954. * @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
  83955. * @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
  83956. * @param x defines x coordinate
  83957. * @param y defines y coordinate
  83958. * @param z defines z coordinate
  83959. * @returns the face index if found (or null instead)
  83960. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83961. */
  83962. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  83963. /**
  83964. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  83965. * @param projected sets as the (x,y,z) local projection on the facet
  83966. * @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
  83967. * @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
  83968. * @param x defines x coordinate
  83969. * @param y defines y coordinate
  83970. * @param z defines z coordinate
  83971. * @returns the face index if found (or null instead)
  83972. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83973. */
  83974. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  83975. /**
  83976. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  83977. * @returns the parameters
  83978. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83979. */
  83980. getFacetDataParameters(): any;
  83981. /**
  83982. * Disables the feature FacetData and frees the related memory
  83983. * @returns the current mesh
  83984. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83985. */
  83986. disableFacetData(): AbstractMesh;
  83987. /**
  83988. * Updates the AbstractMesh indices array
  83989. * @param indices defines the data source
  83990. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  83991. * @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)
  83992. * @returns the current mesh
  83993. */
  83994. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  83995. /**
  83996. * Creates new normals data for the mesh
  83997. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  83998. * @returns the current mesh
  83999. */
  84000. createNormals(updatable: boolean): AbstractMesh;
  84001. /**
  84002. * Align the mesh with a normal
  84003. * @param normal defines the normal to use
  84004. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  84005. * @returns the current mesh
  84006. */
  84007. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  84008. /** @hidden */
  84009. _checkOcclusionQuery(): boolean;
  84010. }
  84011. }
  84012. declare module BABYLON {
  84013. /**
  84014. * Interface used to define ActionEvent
  84015. */
  84016. export interface IActionEvent {
  84017. /** The mesh or sprite that triggered the action */
  84018. source: any;
  84019. /** The X mouse cursor position at the time of the event */
  84020. pointerX: number;
  84021. /** The Y mouse cursor position at the time of the event */
  84022. pointerY: number;
  84023. /** The mesh that is currently pointed at (can be null) */
  84024. meshUnderPointer: Nullable<AbstractMesh>;
  84025. /** the original (browser) event that triggered the ActionEvent */
  84026. sourceEvent?: any;
  84027. /** additional data for the event */
  84028. additionalData?: any;
  84029. }
  84030. /**
  84031. * ActionEvent is the event being sent when an action is triggered.
  84032. */
  84033. export class ActionEvent implements IActionEvent {
  84034. /** The mesh or sprite that triggered the action */
  84035. source: any;
  84036. /** The X mouse cursor position at the time of the event */
  84037. pointerX: number;
  84038. /** The Y mouse cursor position at the time of the event */
  84039. pointerY: number;
  84040. /** The mesh that is currently pointed at (can be null) */
  84041. meshUnderPointer: Nullable<AbstractMesh>;
  84042. /** the original (browser) event that triggered the ActionEvent */
  84043. sourceEvent?: any;
  84044. /** additional data for the event */
  84045. additionalData?: any;
  84046. /**
  84047. * Creates a new ActionEvent
  84048. * @param source The mesh or sprite that triggered the action
  84049. * @param pointerX The X mouse cursor position at the time of the event
  84050. * @param pointerY The Y mouse cursor position at the time of the event
  84051. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  84052. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  84053. * @param additionalData additional data for the event
  84054. */
  84055. constructor(
  84056. /** The mesh or sprite that triggered the action */
  84057. source: any,
  84058. /** The X mouse cursor position at the time of the event */
  84059. pointerX: number,
  84060. /** The Y mouse cursor position at the time of the event */
  84061. pointerY: number,
  84062. /** The mesh that is currently pointed at (can be null) */
  84063. meshUnderPointer: Nullable<AbstractMesh>,
  84064. /** the original (browser) event that triggered the ActionEvent */
  84065. sourceEvent?: any,
  84066. /** additional data for the event */
  84067. additionalData?: any);
  84068. /**
  84069. * Helper function to auto-create an ActionEvent from a source mesh.
  84070. * @param source The source mesh that triggered the event
  84071. * @param evt The original (browser) event
  84072. * @param additionalData additional data for the event
  84073. * @returns the new ActionEvent
  84074. */
  84075. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  84076. /**
  84077. * Helper function to auto-create an ActionEvent from a source sprite
  84078. * @param source The source sprite that triggered the event
  84079. * @param scene Scene associated with the sprite
  84080. * @param evt The original (browser) event
  84081. * @param additionalData additional data for the event
  84082. * @returns the new ActionEvent
  84083. */
  84084. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  84085. /**
  84086. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  84087. * @param scene the scene where the event occurred
  84088. * @param evt The original (browser) event
  84089. * @returns the new ActionEvent
  84090. */
  84091. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  84092. /**
  84093. * Helper function to auto-create an ActionEvent from a primitive
  84094. * @param prim defines the target primitive
  84095. * @param pointerPos defines the pointer position
  84096. * @param evt The original (browser) event
  84097. * @param additionalData additional data for the event
  84098. * @returns the new ActionEvent
  84099. */
  84100. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  84101. }
  84102. }
  84103. declare module BABYLON {
  84104. /**
  84105. * Abstract class used to decouple action Manager from scene and meshes.
  84106. * Do not instantiate.
  84107. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  84108. */
  84109. export abstract class AbstractActionManager implements IDisposable {
  84110. /** Gets the list of active triggers */
  84111. static Triggers: {
  84112. [key: string]: number;
  84113. };
  84114. /** Gets the cursor to use when hovering items */
  84115. hoverCursor: string;
  84116. /** Gets the list of actions */
  84117. actions: IAction[];
  84118. /**
  84119. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  84120. */
  84121. isRecursive: boolean;
  84122. /**
  84123. * Releases all associated resources
  84124. */
  84125. abstract dispose(): void;
  84126. /**
  84127. * Does this action manager has pointer triggers
  84128. */
  84129. abstract readonly hasPointerTriggers: boolean;
  84130. /**
  84131. * Does this action manager has pick triggers
  84132. */
  84133. abstract readonly hasPickTriggers: boolean;
  84134. /**
  84135. * Process a specific trigger
  84136. * @param trigger defines the trigger to process
  84137. * @param evt defines the event details to be processed
  84138. */
  84139. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  84140. /**
  84141. * Does this action manager handles actions of any of the given triggers
  84142. * @param triggers defines the triggers to be tested
  84143. * @return a boolean indicating whether one (or more) of the triggers is handled
  84144. */
  84145. abstract hasSpecificTriggers(triggers: number[]): boolean;
  84146. /**
  84147. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  84148. * speed.
  84149. * @param triggerA defines the trigger to be tested
  84150. * @param triggerB defines the trigger to be tested
  84151. * @return a boolean indicating whether one (or more) of the triggers is handled
  84152. */
  84153. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  84154. /**
  84155. * Does this action manager handles actions of a given trigger
  84156. * @param trigger defines the trigger to be tested
  84157. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  84158. * @return whether the trigger is handled
  84159. */
  84160. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  84161. /**
  84162. * Serialize this manager to a JSON object
  84163. * @param name defines the property name to store this manager
  84164. * @returns a JSON representation of this manager
  84165. */
  84166. abstract serialize(name: string): any;
  84167. /**
  84168. * Registers an action to this action manager
  84169. * @param action defines the action to be registered
  84170. * @return the action amended (prepared) after registration
  84171. */
  84172. abstract registerAction(action: IAction): Nullable<IAction>;
  84173. /**
  84174. * Unregisters an action to this action manager
  84175. * @param action defines the action to be unregistered
  84176. * @return a boolean indicating whether the action has been unregistered
  84177. */
  84178. abstract unregisterAction(action: IAction): Boolean;
  84179. /**
  84180. * Does exist one action manager with at least one trigger
  84181. **/
  84182. static readonly HasTriggers: boolean;
  84183. /**
  84184. * Does exist one action manager with at least one pick trigger
  84185. **/
  84186. static readonly HasPickTriggers: boolean;
  84187. /**
  84188. * Does exist one action manager that handles actions of a given trigger
  84189. * @param trigger defines the trigger to be tested
  84190. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  84191. **/
  84192. static HasSpecificTrigger(trigger: number): boolean;
  84193. }
  84194. }
  84195. declare module BABYLON {
  84196. /**
  84197. * Defines how a node can be built from a string name.
  84198. */
  84199. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  84200. /**
  84201. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  84202. */
  84203. export class Node implements IBehaviorAware<Node> {
  84204. /** @hidden */
  84205. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  84206. private static _NodeConstructors;
  84207. /**
  84208. * Add a new node constructor
  84209. * @param type defines the type name of the node to construct
  84210. * @param constructorFunc defines the constructor function
  84211. */
  84212. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  84213. /**
  84214. * Returns a node constructor based on type name
  84215. * @param type defines the type name
  84216. * @param name defines the new node name
  84217. * @param scene defines the hosting scene
  84218. * @param options defines optional options to transmit to constructors
  84219. * @returns the new constructor or null
  84220. */
  84221. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  84222. /**
  84223. * Gets or sets the name of the node
  84224. */
  84225. name: string;
  84226. /**
  84227. * Gets or sets the id of the node
  84228. */
  84229. id: string;
  84230. /**
  84231. * Gets or sets the unique id of the node
  84232. */
  84233. uniqueId: number;
  84234. /**
  84235. * Gets or sets a string used to store user defined state for the node
  84236. */
  84237. state: string;
  84238. /**
  84239. * Gets or sets an object used to store user defined information for the node
  84240. */
  84241. metadata: any;
  84242. /**
  84243. * For internal use only. Please do not use.
  84244. */
  84245. reservedDataStore: any;
  84246. /**
  84247. * List of inspectable custom properties (used by the Inspector)
  84248. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84249. */
  84250. inspectableCustomProperties: IInspectable[];
  84251. /**
  84252. * Gets or sets a boolean used to define if the node must be serialized
  84253. */
  84254. doNotSerialize: boolean;
  84255. /** @hidden */
  84256. _isDisposed: boolean;
  84257. /**
  84258. * Gets a list of Animations associated with the node
  84259. */
  84260. animations: Animation[];
  84261. protected _ranges: {
  84262. [name: string]: Nullable<AnimationRange>;
  84263. };
  84264. /**
  84265. * Callback raised when the node is ready to be used
  84266. */
  84267. onReady: (node: Node) => void;
  84268. private _isEnabled;
  84269. private _isParentEnabled;
  84270. private _isReady;
  84271. /** @hidden */
  84272. _currentRenderId: number;
  84273. private _parentUpdateId;
  84274. protected _childUpdateId: number;
  84275. /** @hidden */
  84276. _waitingParentId: Nullable<string>;
  84277. /** @hidden */
  84278. _scene: Scene;
  84279. /** @hidden */
  84280. _cache: any;
  84281. private _parentNode;
  84282. private _children;
  84283. /** @hidden */
  84284. _worldMatrix: Matrix;
  84285. /** @hidden */
  84286. _worldMatrixDeterminant: number;
  84287. /** @hidden */
  84288. _worldMatrixDeterminantIsDirty: boolean;
  84289. /** @hidden */
  84290. private _sceneRootNodesIndex;
  84291. /**
  84292. * Gets a boolean indicating if the node has been disposed
  84293. * @returns true if the node was disposed
  84294. */
  84295. isDisposed(): boolean;
  84296. /**
  84297. * Gets or sets the parent of the node (without keeping the current position in the scene)
  84298. * @see https://doc.babylonjs.com/how_to/parenting
  84299. */
  84300. parent: Nullable<Node>;
  84301. private addToSceneRootNodes;
  84302. private removeFromSceneRootNodes;
  84303. private _animationPropertiesOverride;
  84304. /**
  84305. * Gets or sets the animation properties override
  84306. */
  84307. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  84308. /**
  84309. * Gets a string idenfifying the name of the class
  84310. * @returns "Node" string
  84311. */
  84312. getClassName(): string;
  84313. /** @hidden */
  84314. readonly _isNode: boolean;
  84315. /**
  84316. * An event triggered when the mesh is disposed
  84317. */
  84318. onDisposeObservable: Observable<Node>;
  84319. private _onDisposeObserver;
  84320. /**
  84321. * Sets a callback that will be raised when the node will be disposed
  84322. */
  84323. onDispose: () => void;
  84324. /**
  84325. * Creates a new Node
  84326. * @param name the name and id to be given to this node
  84327. * @param scene the scene this node will be added to
  84328. * @param addToRootNodes the node will be added to scene.rootNodes
  84329. */
  84330. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  84331. /**
  84332. * Gets the scene of the node
  84333. * @returns a scene
  84334. */
  84335. getScene(): Scene;
  84336. /**
  84337. * Gets the engine of the node
  84338. * @returns a Engine
  84339. */
  84340. getEngine(): Engine;
  84341. private _behaviors;
  84342. /**
  84343. * Attach a behavior to the node
  84344. * @see http://doc.babylonjs.com/features/behaviour
  84345. * @param behavior defines the behavior to attach
  84346. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  84347. * @returns the current Node
  84348. */
  84349. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  84350. /**
  84351. * Remove an attached behavior
  84352. * @see http://doc.babylonjs.com/features/behaviour
  84353. * @param behavior defines the behavior to attach
  84354. * @returns the current Node
  84355. */
  84356. removeBehavior(behavior: Behavior<Node>): Node;
  84357. /**
  84358. * Gets the list of attached behaviors
  84359. * @see http://doc.babylonjs.com/features/behaviour
  84360. */
  84361. readonly behaviors: Behavior<Node>[];
  84362. /**
  84363. * Gets an attached behavior by name
  84364. * @param name defines the name of the behavior to look for
  84365. * @see http://doc.babylonjs.com/features/behaviour
  84366. * @returns null if behavior was not found else the requested behavior
  84367. */
  84368. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  84369. /**
  84370. * Returns the latest update of the World matrix
  84371. * @returns a Matrix
  84372. */
  84373. getWorldMatrix(): Matrix;
  84374. /** @hidden */
  84375. _getWorldMatrixDeterminant(): number;
  84376. /**
  84377. * Returns directly the latest state of the mesh World matrix.
  84378. * A Matrix is returned.
  84379. */
  84380. readonly worldMatrixFromCache: Matrix;
  84381. /** @hidden */
  84382. _initCache(): void;
  84383. /** @hidden */
  84384. updateCache(force?: boolean): void;
  84385. /** @hidden */
  84386. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  84387. /** @hidden */
  84388. _updateCache(ignoreParentClass?: boolean): void;
  84389. /** @hidden */
  84390. _isSynchronized(): boolean;
  84391. /** @hidden */
  84392. _markSyncedWithParent(): void;
  84393. /** @hidden */
  84394. isSynchronizedWithParent(): boolean;
  84395. /** @hidden */
  84396. isSynchronized(): boolean;
  84397. /**
  84398. * Is this node ready to be used/rendered
  84399. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  84400. * @return true if the node is ready
  84401. */
  84402. isReady(completeCheck?: boolean): boolean;
  84403. /**
  84404. * Is this node enabled?
  84405. * 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
  84406. * @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
  84407. * @return whether this node (and its parent) is enabled
  84408. */
  84409. isEnabled(checkAncestors?: boolean): boolean;
  84410. /** @hidden */
  84411. protected _syncParentEnabledState(): void;
  84412. /**
  84413. * Set the enabled state of this node
  84414. * @param value defines the new enabled state
  84415. */
  84416. setEnabled(value: boolean): void;
  84417. /**
  84418. * Is this node a descendant of the given node?
  84419. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  84420. * @param ancestor defines the parent node to inspect
  84421. * @returns a boolean indicating if this node is a descendant of the given node
  84422. */
  84423. isDescendantOf(ancestor: Node): boolean;
  84424. /** @hidden */
  84425. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  84426. /**
  84427. * Will return all nodes that have this node as ascendant
  84428. * @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
  84429. * @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
  84430. * @return all children nodes of all types
  84431. */
  84432. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  84433. /**
  84434. * Get all child-meshes of this node
  84435. * @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)
  84436. * @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
  84437. * @returns an array of AbstractMesh
  84438. */
  84439. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  84440. /**
  84441. * Get all direct children of this node
  84442. * @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
  84443. * @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)
  84444. * @returns an array of Node
  84445. */
  84446. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  84447. /** @hidden */
  84448. _setReady(state: boolean): void;
  84449. /**
  84450. * Get an animation by name
  84451. * @param name defines the name of the animation to look for
  84452. * @returns null if not found else the requested animation
  84453. */
  84454. getAnimationByName(name: string): Nullable<Animation>;
  84455. /**
  84456. * Creates an animation range for this node
  84457. * @param name defines the name of the range
  84458. * @param from defines the starting key
  84459. * @param to defines the end key
  84460. */
  84461. createAnimationRange(name: string, from: number, to: number): void;
  84462. /**
  84463. * Delete a specific animation range
  84464. * @param name defines the name of the range to delete
  84465. * @param deleteFrames defines if animation frames from the range must be deleted as well
  84466. */
  84467. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  84468. /**
  84469. * Get an animation range by name
  84470. * @param name defines the name of the animation range to look for
  84471. * @returns null if not found else the requested animation range
  84472. */
  84473. getAnimationRange(name: string): Nullable<AnimationRange>;
  84474. /**
  84475. * Gets the list of all animation ranges defined on this node
  84476. * @returns an array
  84477. */
  84478. getAnimationRanges(): Nullable<AnimationRange>[];
  84479. /**
  84480. * Will start the animation sequence
  84481. * @param name defines the range frames for animation sequence
  84482. * @param loop defines if the animation should loop (false by default)
  84483. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  84484. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  84485. * @returns the object created for this animation. If range does not exist, it will return null
  84486. */
  84487. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  84488. /**
  84489. * Serialize animation ranges into a JSON compatible object
  84490. * @returns serialization object
  84491. */
  84492. serializeAnimationRanges(): any;
  84493. /**
  84494. * Computes the world matrix of the node
  84495. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  84496. * @returns the world matrix
  84497. */
  84498. computeWorldMatrix(force?: boolean): Matrix;
  84499. /**
  84500. * Releases resources associated with this node.
  84501. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  84502. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  84503. */
  84504. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  84505. /**
  84506. * Parse animation range data from a serialization object and store them into a given node
  84507. * @param node defines where to store the animation ranges
  84508. * @param parsedNode defines the serialization object to read data from
  84509. * @param scene defines the hosting scene
  84510. */
  84511. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  84512. }
  84513. }
  84514. declare module BABYLON {
  84515. /**
  84516. * Class used to store any kind of animation
  84517. */
  84518. export class Animation {
  84519. /**Name of the animation */
  84520. name: string;
  84521. /**Property to animate */
  84522. targetProperty: string;
  84523. /**The frames per second of the animation */
  84524. framePerSecond: number;
  84525. /**The data type of the animation */
  84526. dataType: number;
  84527. /**The loop mode of the animation */
  84528. loopMode?: number | undefined;
  84529. /**Specifies if blending should be enabled */
  84530. enableBlending?: boolean | undefined;
  84531. /**
  84532. * Use matrix interpolation instead of using direct key value when animating matrices
  84533. */
  84534. static AllowMatricesInterpolation: boolean;
  84535. /**
  84536. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  84537. */
  84538. static AllowMatrixDecomposeForInterpolation: boolean;
  84539. /**
  84540. * Stores the key frames of the animation
  84541. */
  84542. private _keys;
  84543. /**
  84544. * Stores the easing function of the animation
  84545. */
  84546. private _easingFunction;
  84547. /**
  84548. * @hidden Internal use only
  84549. */
  84550. _runtimeAnimations: RuntimeAnimation[];
  84551. /**
  84552. * The set of event that will be linked to this animation
  84553. */
  84554. private _events;
  84555. /**
  84556. * Stores an array of target property paths
  84557. */
  84558. targetPropertyPath: string[];
  84559. /**
  84560. * Stores the blending speed of the animation
  84561. */
  84562. blendingSpeed: number;
  84563. /**
  84564. * Stores the animation ranges for the animation
  84565. */
  84566. private _ranges;
  84567. /**
  84568. * @hidden Internal use
  84569. */
  84570. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  84571. /**
  84572. * Sets up an animation
  84573. * @param property The property to animate
  84574. * @param animationType The animation type to apply
  84575. * @param framePerSecond The frames per second of the animation
  84576. * @param easingFunction The easing function used in the animation
  84577. * @returns The created animation
  84578. */
  84579. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  84580. /**
  84581. * Create and start an animation on a node
  84582. * @param name defines the name of the global animation that will be run on all nodes
  84583. * @param node defines the root node where the animation will take place
  84584. * @param targetProperty defines property to animate
  84585. * @param framePerSecond defines the number of frame per second yo use
  84586. * @param totalFrame defines the number of frames in total
  84587. * @param from defines the initial value
  84588. * @param to defines the final value
  84589. * @param loopMode defines which loop mode you want to use (off by default)
  84590. * @param easingFunction defines the easing function to use (linear by default)
  84591. * @param onAnimationEnd defines the callback to call when animation end
  84592. * @returns the animatable created for this animation
  84593. */
  84594. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  84595. /**
  84596. * Create and start an animation on a node and its descendants
  84597. * @param name defines the name of the global animation that will be run on all nodes
  84598. * @param node defines the root node where the animation will take place
  84599. * @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
  84600. * @param targetProperty defines property to animate
  84601. * @param framePerSecond defines the number of frame per second to use
  84602. * @param totalFrame defines the number of frames in total
  84603. * @param from defines the initial value
  84604. * @param to defines the final value
  84605. * @param loopMode defines which loop mode you want to use (off by default)
  84606. * @param easingFunction defines the easing function to use (linear by default)
  84607. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  84608. * @returns the list of animatables created for all nodes
  84609. * @example https://www.babylonjs-playground.com/#MH0VLI
  84610. */
  84611. 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[]>;
  84612. /**
  84613. * Creates a new animation, merges it with the existing animations and starts it
  84614. * @param name Name of the animation
  84615. * @param node Node which contains the scene that begins the animations
  84616. * @param targetProperty Specifies which property to animate
  84617. * @param framePerSecond The frames per second of the animation
  84618. * @param totalFrame The total number of frames
  84619. * @param from The frame at the beginning of the animation
  84620. * @param to The frame at the end of the animation
  84621. * @param loopMode Specifies the loop mode of the animation
  84622. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  84623. * @param onAnimationEnd Callback to run once the animation is complete
  84624. * @returns Nullable animation
  84625. */
  84626. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  84627. /**
  84628. * Transition property of an host to the target Value
  84629. * @param property The property to transition
  84630. * @param targetValue The target Value of the property
  84631. * @param host The object where the property to animate belongs
  84632. * @param scene Scene used to run the animation
  84633. * @param frameRate Framerate (in frame/s) to use
  84634. * @param transition The transition type we want to use
  84635. * @param duration The duration of the animation, in milliseconds
  84636. * @param onAnimationEnd Callback trigger at the end of the animation
  84637. * @returns Nullable animation
  84638. */
  84639. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  84640. /**
  84641. * Return the array of runtime animations currently using this animation
  84642. */
  84643. readonly runtimeAnimations: RuntimeAnimation[];
  84644. /**
  84645. * Specifies if any of the runtime animations are currently running
  84646. */
  84647. readonly hasRunningRuntimeAnimations: boolean;
  84648. /**
  84649. * Initializes the animation
  84650. * @param name Name of the animation
  84651. * @param targetProperty Property to animate
  84652. * @param framePerSecond The frames per second of the animation
  84653. * @param dataType The data type of the animation
  84654. * @param loopMode The loop mode of the animation
  84655. * @param enableBlending Specifies if blending should be enabled
  84656. */
  84657. constructor(
  84658. /**Name of the animation */
  84659. name: string,
  84660. /**Property to animate */
  84661. targetProperty: string,
  84662. /**The frames per second of the animation */
  84663. framePerSecond: number,
  84664. /**The data type of the animation */
  84665. dataType: number,
  84666. /**The loop mode of the animation */
  84667. loopMode?: number | undefined,
  84668. /**Specifies if blending should be enabled */
  84669. enableBlending?: boolean | undefined);
  84670. /**
  84671. * Converts the animation to a string
  84672. * @param fullDetails support for multiple levels of logging within scene loading
  84673. * @returns String form of the animation
  84674. */
  84675. toString(fullDetails?: boolean): string;
  84676. /**
  84677. * Add an event to this animation
  84678. * @param event Event to add
  84679. */
  84680. addEvent(event: AnimationEvent): void;
  84681. /**
  84682. * Remove all events found at the given frame
  84683. * @param frame The frame to remove events from
  84684. */
  84685. removeEvents(frame: number): void;
  84686. /**
  84687. * Retrieves all the events from the animation
  84688. * @returns Events from the animation
  84689. */
  84690. getEvents(): AnimationEvent[];
  84691. /**
  84692. * Creates an animation range
  84693. * @param name Name of the animation range
  84694. * @param from Starting frame of the animation range
  84695. * @param to Ending frame of the animation
  84696. */
  84697. createRange(name: string, from: number, to: number): void;
  84698. /**
  84699. * Deletes an animation range by name
  84700. * @param name Name of the animation range to delete
  84701. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  84702. */
  84703. deleteRange(name: string, deleteFrames?: boolean): void;
  84704. /**
  84705. * Gets the animation range by name, or null if not defined
  84706. * @param name Name of the animation range
  84707. * @returns Nullable animation range
  84708. */
  84709. getRange(name: string): Nullable<AnimationRange>;
  84710. /**
  84711. * Gets the key frames from the animation
  84712. * @returns The key frames of the animation
  84713. */
  84714. getKeys(): Array<IAnimationKey>;
  84715. /**
  84716. * Gets the highest frame rate of the animation
  84717. * @returns Highest frame rate of the animation
  84718. */
  84719. getHighestFrame(): number;
  84720. /**
  84721. * Gets the easing function of the animation
  84722. * @returns Easing function of the animation
  84723. */
  84724. getEasingFunction(): IEasingFunction;
  84725. /**
  84726. * Sets the easing function of the animation
  84727. * @param easingFunction A custom mathematical formula for animation
  84728. */
  84729. setEasingFunction(easingFunction: EasingFunction): void;
  84730. /**
  84731. * Interpolates a scalar linearly
  84732. * @param startValue Start value of the animation curve
  84733. * @param endValue End value of the animation curve
  84734. * @param gradient Scalar amount to interpolate
  84735. * @returns Interpolated scalar value
  84736. */
  84737. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  84738. /**
  84739. * Interpolates a scalar cubically
  84740. * @param startValue Start value of the animation curve
  84741. * @param outTangent End tangent of the animation
  84742. * @param endValue End value of the animation curve
  84743. * @param inTangent Start tangent of the animation curve
  84744. * @param gradient Scalar amount to interpolate
  84745. * @returns Interpolated scalar value
  84746. */
  84747. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  84748. /**
  84749. * Interpolates a quaternion using a spherical linear interpolation
  84750. * @param startValue Start value of the animation curve
  84751. * @param endValue End value of the animation curve
  84752. * @param gradient Scalar amount to interpolate
  84753. * @returns Interpolated quaternion value
  84754. */
  84755. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  84756. /**
  84757. * Interpolates a quaternion cubically
  84758. * @param startValue Start value of the animation curve
  84759. * @param outTangent End tangent of the animation curve
  84760. * @param endValue End value of the animation curve
  84761. * @param inTangent Start tangent of the animation curve
  84762. * @param gradient Scalar amount to interpolate
  84763. * @returns Interpolated quaternion value
  84764. */
  84765. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  84766. /**
  84767. * Interpolates a Vector3 linearl
  84768. * @param startValue Start value of the animation curve
  84769. * @param endValue End value of the animation curve
  84770. * @param gradient Scalar amount to interpolate
  84771. * @returns Interpolated scalar value
  84772. */
  84773. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  84774. /**
  84775. * Interpolates a Vector3 cubically
  84776. * @param startValue Start value of the animation curve
  84777. * @param outTangent End tangent of the animation
  84778. * @param endValue End value of the animation curve
  84779. * @param inTangent Start tangent of the animation curve
  84780. * @param gradient Scalar amount to interpolate
  84781. * @returns InterpolatedVector3 value
  84782. */
  84783. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  84784. /**
  84785. * Interpolates a Vector2 linearly
  84786. * @param startValue Start value of the animation curve
  84787. * @param endValue End value of the animation curve
  84788. * @param gradient Scalar amount to interpolate
  84789. * @returns Interpolated Vector2 value
  84790. */
  84791. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  84792. /**
  84793. * Interpolates a Vector2 cubically
  84794. * @param startValue Start value of the animation curve
  84795. * @param outTangent End tangent of the animation
  84796. * @param endValue End value of the animation curve
  84797. * @param inTangent Start tangent of the animation curve
  84798. * @param gradient Scalar amount to interpolate
  84799. * @returns Interpolated Vector2 value
  84800. */
  84801. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  84802. /**
  84803. * Interpolates a size linearly
  84804. * @param startValue Start value of the animation curve
  84805. * @param endValue End value of the animation curve
  84806. * @param gradient Scalar amount to interpolate
  84807. * @returns Interpolated Size value
  84808. */
  84809. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  84810. /**
  84811. * Interpolates a Color3 linearly
  84812. * @param startValue Start value of the animation curve
  84813. * @param endValue End value of the animation curve
  84814. * @param gradient Scalar amount to interpolate
  84815. * @returns Interpolated Color3 value
  84816. */
  84817. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  84818. /**
  84819. * @hidden Internal use only
  84820. */
  84821. _getKeyValue(value: any): any;
  84822. /**
  84823. * @hidden Internal use only
  84824. */
  84825. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  84826. /**
  84827. * Defines the function to use to interpolate matrices
  84828. * @param startValue defines the start matrix
  84829. * @param endValue defines the end matrix
  84830. * @param gradient defines the gradient between both matrices
  84831. * @param result defines an optional target matrix where to store the interpolation
  84832. * @returns the interpolated matrix
  84833. */
  84834. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  84835. /**
  84836. * Makes a copy of the animation
  84837. * @returns Cloned animation
  84838. */
  84839. clone(): Animation;
  84840. /**
  84841. * Sets the key frames of the animation
  84842. * @param values The animation key frames to set
  84843. */
  84844. setKeys(values: Array<IAnimationKey>): void;
  84845. /**
  84846. * Serializes the animation to an object
  84847. * @returns Serialized object
  84848. */
  84849. serialize(): any;
  84850. /**
  84851. * Float animation type
  84852. */
  84853. private static _ANIMATIONTYPE_FLOAT;
  84854. /**
  84855. * Vector3 animation type
  84856. */
  84857. private static _ANIMATIONTYPE_VECTOR3;
  84858. /**
  84859. * Quaternion animation type
  84860. */
  84861. private static _ANIMATIONTYPE_QUATERNION;
  84862. /**
  84863. * Matrix animation type
  84864. */
  84865. private static _ANIMATIONTYPE_MATRIX;
  84866. /**
  84867. * Color3 animation type
  84868. */
  84869. private static _ANIMATIONTYPE_COLOR3;
  84870. /**
  84871. * Vector2 animation type
  84872. */
  84873. private static _ANIMATIONTYPE_VECTOR2;
  84874. /**
  84875. * Size animation type
  84876. */
  84877. private static _ANIMATIONTYPE_SIZE;
  84878. /**
  84879. * Relative Loop Mode
  84880. */
  84881. private static _ANIMATIONLOOPMODE_RELATIVE;
  84882. /**
  84883. * Cycle Loop Mode
  84884. */
  84885. private static _ANIMATIONLOOPMODE_CYCLE;
  84886. /**
  84887. * Constant Loop Mode
  84888. */
  84889. private static _ANIMATIONLOOPMODE_CONSTANT;
  84890. /**
  84891. * Get the float animation type
  84892. */
  84893. static readonly ANIMATIONTYPE_FLOAT: number;
  84894. /**
  84895. * Get the Vector3 animation type
  84896. */
  84897. static readonly ANIMATIONTYPE_VECTOR3: number;
  84898. /**
  84899. * Get the Vector2 animation type
  84900. */
  84901. static readonly ANIMATIONTYPE_VECTOR2: number;
  84902. /**
  84903. * Get the Size animation type
  84904. */
  84905. static readonly ANIMATIONTYPE_SIZE: number;
  84906. /**
  84907. * Get the Quaternion animation type
  84908. */
  84909. static readonly ANIMATIONTYPE_QUATERNION: number;
  84910. /**
  84911. * Get the Matrix animation type
  84912. */
  84913. static readonly ANIMATIONTYPE_MATRIX: number;
  84914. /**
  84915. * Get the Color3 animation type
  84916. */
  84917. static readonly ANIMATIONTYPE_COLOR3: number;
  84918. /**
  84919. * Get the Relative Loop Mode
  84920. */
  84921. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  84922. /**
  84923. * Get the Cycle Loop Mode
  84924. */
  84925. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  84926. /**
  84927. * Get the Constant Loop Mode
  84928. */
  84929. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  84930. /** @hidden */
  84931. static _UniversalLerp(left: any, right: any, amount: number): any;
  84932. /**
  84933. * Parses an animation object and creates an animation
  84934. * @param parsedAnimation Parsed animation object
  84935. * @returns Animation object
  84936. */
  84937. static Parse(parsedAnimation: any): Animation;
  84938. /**
  84939. * Appends the serialized animations from the source animations
  84940. * @param source Source containing the animations
  84941. * @param destination Target to store the animations
  84942. */
  84943. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  84944. }
  84945. }
  84946. declare module BABYLON {
  84947. /**
  84948. * Base class of all the textures in babylon.
  84949. * It groups all the common properties the materials, post process, lights... might need
  84950. * in order to make a correct use of the texture.
  84951. */
  84952. export class BaseTexture implements IAnimatable {
  84953. /**
  84954. * Default anisotropic filtering level for the application.
  84955. * It is set to 4 as a good tradeoff between perf and quality.
  84956. */
  84957. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  84958. /**
  84959. * Gets or sets the unique id of the texture
  84960. */
  84961. uniqueId: number;
  84962. /**
  84963. * Define the name of the texture.
  84964. */
  84965. name: string;
  84966. /**
  84967. * Gets or sets an object used to store user defined information.
  84968. */
  84969. metadata: any;
  84970. /**
  84971. * For internal use only. Please do not use.
  84972. */
  84973. reservedDataStore: any;
  84974. private _hasAlpha;
  84975. /**
  84976. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  84977. */
  84978. hasAlpha: boolean;
  84979. /**
  84980. * Defines if the alpha value should be determined via the rgb values.
  84981. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  84982. */
  84983. getAlphaFromRGB: boolean;
  84984. /**
  84985. * Intensity or strength of the texture.
  84986. * It is commonly used by materials to fine tune the intensity of the texture
  84987. */
  84988. level: number;
  84989. /**
  84990. * Define the UV chanel to use starting from 0 and defaulting to 0.
  84991. * This is part of the texture as textures usually maps to one uv set.
  84992. */
  84993. coordinatesIndex: number;
  84994. private _coordinatesMode;
  84995. /**
  84996. * How a texture is mapped.
  84997. *
  84998. * | Value | Type | Description |
  84999. * | ----- | ----------------------------------- | ----------- |
  85000. * | 0 | EXPLICIT_MODE | |
  85001. * | 1 | SPHERICAL_MODE | |
  85002. * | 2 | PLANAR_MODE | |
  85003. * | 3 | CUBIC_MODE | |
  85004. * | 4 | PROJECTION_MODE | |
  85005. * | 5 | SKYBOX_MODE | |
  85006. * | 6 | INVCUBIC_MODE | |
  85007. * | 7 | EQUIRECTANGULAR_MODE | |
  85008. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  85009. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  85010. */
  85011. coordinatesMode: number;
  85012. /**
  85013. * | Value | Type | Description |
  85014. * | ----- | ------------------ | ----------- |
  85015. * | 0 | CLAMP_ADDRESSMODE | |
  85016. * | 1 | WRAP_ADDRESSMODE | |
  85017. * | 2 | MIRROR_ADDRESSMODE | |
  85018. */
  85019. wrapU: number;
  85020. /**
  85021. * | Value | Type | Description |
  85022. * | ----- | ------------------ | ----------- |
  85023. * | 0 | CLAMP_ADDRESSMODE | |
  85024. * | 1 | WRAP_ADDRESSMODE | |
  85025. * | 2 | MIRROR_ADDRESSMODE | |
  85026. */
  85027. wrapV: number;
  85028. /**
  85029. * | Value | Type | Description |
  85030. * | ----- | ------------------ | ----------- |
  85031. * | 0 | CLAMP_ADDRESSMODE | |
  85032. * | 1 | WRAP_ADDRESSMODE | |
  85033. * | 2 | MIRROR_ADDRESSMODE | |
  85034. */
  85035. wrapR: number;
  85036. /**
  85037. * With compliant hardware and browser (supporting anisotropic filtering)
  85038. * this defines the level of anisotropic filtering in the texture.
  85039. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  85040. */
  85041. anisotropicFilteringLevel: number;
  85042. /**
  85043. * Define if the texture is a cube texture or if false a 2d texture.
  85044. */
  85045. isCube: boolean;
  85046. /**
  85047. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  85048. */
  85049. is3D: boolean;
  85050. /**
  85051. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  85052. * HDR texture are usually stored in linear space.
  85053. * This only impacts the PBR and Background materials
  85054. */
  85055. gammaSpace: boolean;
  85056. /**
  85057. * Gets whether or not the texture contains RGBD data.
  85058. */
  85059. readonly isRGBD: boolean;
  85060. /**
  85061. * Is Z inverted in the texture (useful in a cube texture).
  85062. */
  85063. invertZ: boolean;
  85064. /**
  85065. * Are mip maps generated for this texture or not.
  85066. */
  85067. readonly noMipmap: boolean;
  85068. /**
  85069. * @hidden
  85070. */
  85071. lodLevelInAlpha: boolean;
  85072. /**
  85073. * With prefiltered texture, defined the offset used during the prefiltering steps.
  85074. */
  85075. lodGenerationOffset: number;
  85076. /**
  85077. * With prefiltered texture, defined the scale used during the prefiltering steps.
  85078. */
  85079. lodGenerationScale: number;
  85080. /**
  85081. * Define if the texture is a render target.
  85082. */
  85083. isRenderTarget: boolean;
  85084. /**
  85085. * Define the unique id of the texture in the scene.
  85086. */
  85087. readonly uid: string;
  85088. /**
  85089. * Return a string representation of the texture.
  85090. * @returns the texture as a string
  85091. */
  85092. toString(): string;
  85093. /**
  85094. * Get the class name of the texture.
  85095. * @returns "BaseTexture"
  85096. */
  85097. getClassName(): string;
  85098. /**
  85099. * Define the list of animation attached to the texture.
  85100. */
  85101. animations: Animation[];
  85102. /**
  85103. * An event triggered when the texture is disposed.
  85104. */
  85105. onDisposeObservable: Observable<BaseTexture>;
  85106. private _onDisposeObserver;
  85107. /**
  85108. * Callback triggered when the texture has been disposed.
  85109. * Kept for back compatibility, you can use the onDisposeObservable instead.
  85110. */
  85111. onDispose: () => void;
  85112. /**
  85113. * Define the current state of the loading sequence when in delayed load mode.
  85114. */
  85115. delayLoadState: number;
  85116. private _scene;
  85117. /** @hidden */
  85118. _texture: Nullable<InternalTexture>;
  85119. private _uid;
  85120. /**
  85121. * Define if the texture is preventinga material to render or not.
  85122. * If not and the texture is not ready, the engine will use a default black texture instead.
  85123. */
  85124. readonly isBlocking: boolean;
  85125. /**
  85126. * Instantiates a new BaseTexture.
  85127. * Base class of all the textures in babylon.
  85128. * It groups all the common properties the materials, post process, lights... might need
  85129. * in order to make a correct use of the texture.
  85130. * @param scene Define the scene the texture blongs to
  85131. */
  85132. constructor(scene: Nullable<Scene>);
  85133. /**
  85134. * Get the scene the texture belongs to.
  85135. * @returns the scene or null if undefined
  85136. */
  85137. getScene(): Nullable<Scene>;
  85138. /**
  85139. * Get the texture transform matrix used to offset tile the texture for istance.
  85140. * @returns the transformation matrix
  85141. */
  85142. getTextureMatrix(): Matrix;
  85143. /**
  85144. * Get the texture reflection matrix used to rotate/transform the reflection.
  85145. * @returns the reflection matrix
  85146. */
  85147. getReflectionTextureMatrix(): Matrix;
  85148. /**
  85149. * Get the underlying lower level texture from Babylon.
  85150. * @returns the insternal texture
  85151. */
  85152. getInternalTexture(): Nullable<InternalTexture>;
  85153. /**
  85154. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  85155. * @returns true if ready or not blocking
  85156. */
  85157. isReadyOrNotBlocking(): boolean;
  85158. /**
  85159. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  85160. * @returns true if fully ready
  85161. */
  85162. isReady(): boolean;
  85163. private _cachedSize;
  85164. /**
  85165. * Get the size of the texture.
  85166. * @returns the texture size.
  85167. */
  85168. getSize(): ISize;
  85169. /**
  85170. * Get the base size of the texture.
  85171. * It can be different from the size if the texture has been resized for POT for instance
  85172. * @returns the base size
  85173. */
  85174. getBaseSize(): ISize;
  85175. /**
  85176. * Update the sampling mode of the texture.
  85177. * Default is Trilinear mode.
  85178. *
  85179. * | Value | Type | Description |
  85180. * | ----- | ------------------ | ----------- |
  85181. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  85182. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  85183. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  85184. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  85185. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  85186. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  85187. * | 7 | NEAREST_LINEAR | |
  85188. * | 8 | NEAREST_NEAREST | |
  85189. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  85190. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  85191. * | 11 | LINEAR_LINEAR | |
  85192. * | 12 | LINEAR_NEAREST | |
  85193. *
  85194. * > _mag_: magnification filter (close to the viewer)
  85195. * > _min_: minification filter (far from the viewer)
  85196. * > _mip_: filter used between mip map levels
  85197. *@param samplingMode Define the new sampling mode of the texture
  85198. */
  85199. updateSamplingMode(samplingMode: number): void;
  85200. /**
  85201. * Scales the texture if is `canRescale()`
  85202. * @param ratio the resize factor we want to use to rescale
  85203. */
  85204. scale(ratio: number): void;
  85205. /**
  85206. * Get if the texture can rescale.
  85207. */
  85208. readonly canRescale: boolean;
  85209. /** @hidden */
  85210. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  85211. /** @hidden */
  85212. _rebuild(): void;
  85213. /**
  85214. * Triggers the load sequence in delayed load mode.
  85215. */
  85216. delayLoad(): void;
  85217. /**
  85218. * Clones the texture.
  85219. * @returns the cloned texture
  85220. */
  85221. clone(): Nullable<BaseTexture>;
  85222. /**
  85223. * Get the texture underlying type (INT, FLOAT...)
  85224. */
  85225. readonly textureType: number;
  85226. /**
  85227. * Get the texture underlying format (RGB, RGBA...)
  85228. */
  85229. readonly textureFormat: number;
  85230. /**
  85231. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  85232. * This will returns an RGBA array buffer containing either in values (0-255) or
  85233. * float values (0-1) depending of the underlying buffer type.
  85234. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  85235. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  85236. * @param buffer defines a user defined buffer to fill with data (can be null)
  85237. * @returns The Array buffer containing the pixels data.
  85238. */
  85239. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  85240. /**
  85241. * Release and destroy the underlying lower level texture aka internalTexture.
  85242. */
  85243. releaseInternalTexture(): void;
  85244. /**
  85245. * Get the polynomial representation of the texture data.
  85246. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  85247. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  85248. */
  85249. sphericalPolynomial: Nullable<SphericalPolynomial>;
  85250. /** @hidden */
  85251. readonly _lodTextureHigh: Nullable<BaseTexture>;
  85252. /** @hidden */
  85253. readonly _lodTextureMid: Nullable<BaseTexture>;
  85254. /** @hidden */
  85255. readonly _lodTextureLow: Nullable<BaseTexture>;
  85256. /**
  85257. * Dispose the texture and release its associated resources.
  85258. */
  85259. dispose(): void;
  85260. /**
  85261. * Serialize the texture into a JSON representation that can be parsed later on.
  85262. * @returns the JSON representation of the texture
  85263. */
  85264. serialize(): any;
  85265. /**
  85266. * Helper function to be called back once a list of texture contains only ready textures.
  85267. * @param textures Define the list of textures to wait for
  85268. * @param callback Define the callback triggered once the entire list will be ready
  85269. */
  85270. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  85271. }
  85272. }
  85273. declare module BABYLON {
  85274. /**
  85275. * Uniform buffer objects.
  85276. *
  85277. * Handles blocks of uniform on the GPU.
  85278. *
  85279. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  85280. *
  85281. * For more information, please refer to :
  85282. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  85283. */
  85284. export class UniformBuffer {
  85285. private _engine;
  85286. private _buffer;
  85287. private _data;
  85288. private _bufferData;
  85289. private _dynamic?;
  85290. private _uniformLocations;
  85291. private _uniformSizes;
  85292. private _uniformLocationPointer;
  85293. private _needSync;
  85294. private _noUBO;
  85295. private _currentEffect;
  85296. private static _MAX_UNIFORM_SIZE;
  85297. private static _tempBuffer;
  85298. /**
  85299. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  85300. * This is dynamic to allow compat with webgl 1 and 2.
  85301. * You will need to pass the name of the uniform as well as the value.
  85302. */
  85303. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  85304. /**
  85305. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  85306. * This is dynamic to allow compat with webgl 1 and 2.
  85307. * You will need to pass the name of the uniform as well as the value.
  85308. */
  85309. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  85310. /**
  85311. * Lambda to Update a single float in a uniform buffer.
  85312. * This is dynamic to allow compat with webgl 1 and 2.
  85313. * You will need to pass the name of the uniform as well as the value.
  85314. */
  85315. updateFloat: (name: string, x: number) => void;
  85316. /**
  85317. * Lambda to Update a vec2 of float in a uniform buffer.
  85318. * This is dynamic to allow compat with webgl 1 and 2.
  85319. * You will need to pass the name of the uniform as well as the value.
  85320. */
  85321. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  85322. /**
  85323. * Lambda to Update a vec3 of float in a uniform buffer.
  85324. * This is dynamic to allow compat with webgl 1 and 2.
  85325. * You will need to pass the name of the uniform as well as the value.
  85326. */
  85327. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  85328. /**
  85329. * Lambda to Update a vec4 of float in a uniform buffer.
  85330. * This is dynamic to allow compat with webgl 1 and 2.
  85331. * You will need to pass the name of the uniform as well as the value.
  85332. */
  85333. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  85334. /**
  85335. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  85336. * This is dynamic to allow compat with webgl 1 and 2.
  85337. * You will need to pass the name of the uniform as well as the value.
  85338. */
  85339. updateMatrix: (name: string, mat: Matrix) => void;
  85340. /**
  85341. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  85342. * This is dynamic to allow compat with webgl 1 and 2.
  85343. * You will need to pass the name of the uniform as well as the value.
  85344. */
  85345. updateVector3: (name: string, vector: Vector3) => void;
  85346. /**
  85347. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  85348. * This is dynamic to allow compat with webgl 1 and 2.
  85349. * You will need to pass the name of the uniform as well as the value.
  85350. */
  85351. updateVector4: (name: string, vector: Vector4) => void;
  85352. /**
  85353. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  85354. * This is dynamic to allow compat with webgl 1 and 2.
  85355. * You will need to pass the name of the uniform as well as the value.
  85356. */
  85357. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  85358. /**
  85359. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  85360. * This is dynamic to allow compat with webgl 1 and 2.
  85361. * You will need to pass the name of the uniform as well as the value.
  85362. */
  85363. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  85364. /**
  85365. * Instantiates a new Uniform buffer objects.
  85366. *
  85367. * Handles blocks of uniform on the GPU.
  85368. *
  85369. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  85370. *
  85371. * For more information, please refer to :
  85372. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  85373. * @param engine Define the engine the buffer is associated with
  85374. * @param data Define the data contained in the buffer
  85375. * @param dynamic Define if the buffer is updatable
  85376. */
  85377. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  85378. /**
  85379. * Indicates if the buffer is using the WebGL2 UBO implementation,
  85380. * or just falling back on setUniformXXX calls.
  85381. */
  85382. readonly useUbo: boolean;
  85383. /**
  85384. * Indicates if the WebGL underlying uniform buffer is in sync
  85385. * with the javascript cache data.
  85386. */
  85387. readonly isSync: boolean;
  85388. /**
  85389. * Indicates if the WebGL underlying uniform buffer is dynamic.
  85390. * Also, a dynamic UniformBuffer will disable cache verification and always
  85391. * update the underlying WebGL uniform buffer to the GPU.
  85392. * @returns if Dynamic, otherwise false
  85393. */
  85394. isDynamic(): boolean;
  85395. /**
  85396. * The data cache on JS side.
  85397. * @returns the underlying data as a float array
  85398. */
  85399. getData(): Float32Array;
  85400. /**
  85401. * The underlying WebGL Uniform buffer.
  85402. * @returns the webgl buffer
  85403. */
  85404. getBuffer(): Nullable<WebGLBuffer>;
  85405. /**
  85406. * std140 layout specifies how to align data within an UBO structure.
  85407. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  85408. * for specs.
  85409. */
  85410. private _fillAlignment;
  85411. /**
  85412. * Adds an uniform in the buffer.
  85413. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  85414. * for the layout to be correct !
  85415. * @param name Name of the uniform, as used in the uniform block in the shader.
  85416. * @param size Data size, or data directly.
  85417. */
  85418. addUniform(name: string, size: number | number[]): void;
  85419. /**
  85420. * Adds a Matrix 4x4 to the uniform buffer.
  85421. * @param name Name of the uniform, as used in the uniform block in the shader.
  85422. * @param mat A 4x4 matrix.
  85423. */
  85424. addMatrix(name: string, mat: Matrix): void;
  85425. /**
  85426. * Adds a vec2 to the uniform buffer.
  85427. * @param name Name of the uniform, as used in the uniform block in the shader.
  85428. * @param x Define the x component value of the vec2
  85429. * @param y Define the y component value of the vec2
  85430. */
  85431. addFloat2(name: string, x: number, y: number): void;
  85432. /**
  85433. * Adds a vec3 to the uniform buffer.
  85434. * @param name Name of the uniform, as used in the uniform block in the shader.
  85435. * @param x Define the x component value of the vec3
  85436. * @param y Define the y component value of the vec3
  85437. * @param z Define the z component value of the vec3
  85438. */
  85439. addFloat3(name: string, x: number, y: number, z: number): void;
  85440. /**
  85441. * Adds a vec3 to the uniform buffer.
  85442. * @param name Name of the uniform, as used in the uniform block in the shader.
  85443. * @param color Define the vec3 from a Color
  85444. */
  85445. addColor3(name: string, color: Color3): void;
  85446. /**
  85447. * Adds a vec4 to the uniform buffer.
  85448. * @param name Name of the uniform, as used in the uniform block in the shader.
  85449. * @param color Define the rgb components from a Color
  85450. * @param alpha Define the a component of the vec4
  85451. */
  85452. addColor4(name: string, color: Color3, alpha: number): void;
  85453. /**
  85454. * Adds a vec3 to the uniform buffer.
  85455. * @param name Name of the uniform, as used in the uniform block in the shader.
  85456. * @param vector Define the vec3 components from a Vector
  85457. */
  85458. addVector3(name: string, vector: Vector3): void;
  85459. /**
  85460. * Adds a Matrix 3x3 to the uniform buffer.
  85461. * @param name Name of the uniform, as used in the uniform block in the shader.
  85462. */
  85463. addMatrix3x3(name: string): void;
  85464. /**
  85465. * Adds a Matrix 2x2 to the uniform buffer.
  85466. * @param name Name of the uniform, as used in the uniform block in the shader.
  85467. */
  85468. addMatrix2x2(name: string): void;
  85469. /**
  85470. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  85471. */
  85472. create(): void;
  85473. /** @hidden */
  85474. _rebuild(): void;
  85475. /**
  85476. * Updates the WebGL Uniform Buffer on the GPU.
  85477. * If the `dynamic` flag is set to true, no cache comparison is done.
  85478. * Otherwise, the buffer will be updated only if the cache differs.
  85479. */
  85480. update(): void;
  85481. /**
  85482. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  85483. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  85484. * @param data Define the flattened data
  85485. * @param size Define the size of the data.
  85486. */
  85487. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  85488. private _updateMatrix3x3ForUniform;
  85489. private _updateMatrix3x3ForEffect;
  85490. private _updateMatrix2x2ForEffect;
  85491. private _updateMatrix2x2ForUniform;
  85492. private _updateFloatForEffect;
  85493. private _updateFloatForUniform;
  85494. private _updateFloat2ForEffect;
  85495. private _updateFloat2ForUniform;
  85496. private _updateFloat3ForEffect;
  85497. private _updateFloat3ForUniform;
  85498. private _updateFloat4ForEffect;
  85499. private _updateFloat4ForUniform;
  85500. private _updateMatrixForEffect;
  85501. private _updateMatrixForUniform;
  85502. private _updateVector3ForEffect;
  85503. private _updateVector3ForUniform;
  85504. private _updateVector4ForEffect;
  85505. private _updateVector4ForUniform;
  85506. private _updateColor3ForEffect;
  85507. private _updateColor3ForUniform;
  85508. private _updateColor4ForEffect;
  85509. private _updateColor4ForUniform;
  85510. /**
  85511. * Sets a sampler uniform on the effect.
  85512. * @param name Define the name of the sampler.
  85513. * @param texture Define the texture to set in the sampler
  85514. */
  85515. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  85516. /**
  85517. * Directly updates the value of the uniform in the cache AND on the GPU.
  85518. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  85519. * @param data Define the flattened data
  85520. */
  85521. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  85522. /**
  85523. * Binds this uniform buffer to an effect.
  85524. * @param effect Define the effect to bind the buffer to
  85525. * @param name Name of the uniform block in the shader.
  85526. */
  85527. bindToEffect(effect: Effect, name: string): void;
  85528. /**
  85529. * Disposes the uniform buffer.
  85530. */
  85531. dispose(): void;
  85532. }
  85533. }
  85534. declare module BABYLON {
  85535. /**
  85536. * This represents the required contract to create a new type of texture loader.
  85537. */
  85538. export interface IInternalTextureLoader {
  85539. /**
  85540. * Defines wether the loader supports cascade loading the different faces.
  85541. */
  85542. supportCascades: boolean;
  85543. /**
  85544. * This returns if the loader support the current file information.
  85545. * @param extension defines the file extension of the file being loaded
  85546. * @param textureFormatInUse defines the current compressed format in use iun the engine
  85547. * @param fallback defines the fallback internal texture if any
  85548. * @param isBase64 defines whether the texture is encoded as a base64
  85549. * @param isBuffer defines whether the texture data are stored as a buffer
  85550. * @returns true if the loader can load the specified file
  85551. */
  85552. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  85553. /**
  85554. * Transform the url before loading if required.
  85555. * @param rootUrl the url of the texture
  85556. * @param textureFormatInUse defines the current compressed format in use iun the engine
  85557. * @returns the transformed texture
  85558. */
  85559. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  85560. /**
  85561. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  85562. * @param rootUrl the url of the texture
  85563. * @param textureFormatInUse defines the current compressed format in use iun the engine
  85564. * @returns the fallback texture
  85565. */
  85566. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  85567. /**
  85568. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  85569. * @param data contains the texture data
  85570. * @param texture defines the BabylonJS internal texture
  85571. * @param createPolynomials will be true if polynomials have been requested
  85572. * @param onLoad defines the callback to trigger once the texture is ready
  85573. * @param onError defines the callback to trigger in case of error
  85574. */
  85575. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  85576. /**
  85577. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  85578. * @param data contains the texture data
  85579. * @param texture defines the BabylonJS internal texture
  85580. * @param callback defines the method to call once ready to upload
  85581. */
  85582. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  85583. }
  85584. }
  85585. declare module BABYLON {
  85586. /**
  85587. * Creation options of the multi render target texture.
  85588. */
  85589. export interface IMultiRenderTargetOptions {
  85590. /**
  85591. * Define if the texture needs to create mip maps after render.
  85592. */
  85593. generateMipMaps?: boolean;
  85594. /**
  85595. * Define the types of all the draw buffers we want to create
  85596. */
  85597. types?: number[];
  85598. /**
  85599. * Define the sampling modes of all the draw buffers we want to create
  85600. */
  85601. samplingModes?: number[];
  85602. /**
  85603. * Define if a depth buffer is required
  85604. */
  85605. generateDepthBuffer?: boolean;
  85606. /**
  85607. * Define if a stencil buffer is required
  85608. */
  85609. generateStencilBuffer?: boolean;
  85610. /**
  85611. * Define if a depth texture is required instead of a depth buffer
  85612. */
  85613. generateDepthTexture?: boolean;
  85614. /**
  85615. * Define the number of desired draw buffers
  85616. */
  85617. textureCount?: number;
  85618. /**
  85619. * Define if aspect ratio should be adapted to the texture or stay the scene one
  85620. */
  85621. doNotChangeAspectRatio?: boolean;
  85622. /**
  85623. * Define the default type of the buffers we are creating
  85624. */
  85625. defaultType?: number;
  85626. }
  85627. /**
  85628. * A multi render target, like a render target provides the ability to render to a texture.
  85629. * Unlike the render target, it can render to several draw buffers in one draw.
  85630. * This is specially interesting in deferred rendering or for any effects requiring more than
  85631. * just one color from a single pass.
  85632. */
  85633. export class MultiRenderTarget extends RenderTargetTexture {
  85634. private _internalTextures;
  85635. private _textures;
  85636. private _multiRenderTargetOptions;
  85637. /**
  85638. * Get if draw buffers are currently supported by the used hardware and browser.
  85639. */
  85640. readonly isSupported: boolean;
  85641. /**
  85642. * Get the list of textures generated by the multi render target.
  85643. */
  85644. readonly textures: Texture[];
  85645. /**
  85646. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  85647. */
  85648. readonly depthTexture: Texture;
  85649. /**
  85650. * Set the wrapping mode on U of all the textures we are rendering to.
  85651. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  85652. */
  85653. wrapU: number;
  85654. /**
  85655. * Set the wrapping mode on V of all the textures we are rendering to.
  85656. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  85657. */
  85658. wrapV: number;
  85659. /**
  85660. * Instantiate a new multi render target texture.
  85661. * A multi render target, like a render target provides the ability to render to a texture.
  85662. * Unlike the render target, it can render to several draw buffers in one draw.
  85663. * This is specially interesting in deferred rendering or for any effects requiring more than
  85664. * just one color from a single pass.
  85665. * @param name Define the name of the texture
  85666. * @param size Define the size of the buffers to render to
  85667. * @param count Define the number of target we are rendering into
  85668. * @param scene Define the scene the texture belongs to
  85669. * @param options Define the options used to create the multi render target
  85670. */
  85671. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  85672. /** @hidden */
  85673. _rebuild(): void;
  85674. private _createInternalTextures;
  85675. private _createTextures;
  85676. /**
  85677. * Define the number of samples used if MSAA is enabled.
  85678. */
  85679. samples: number;
  85680. /**
  85681. * Resize all the textures in the multi render target.
  85682. * Be carrefull as it will recreate all the data in the new texture.
  85683. * @param size Define the new size
  85684. */
  85685. resize(size: any): void;
  85686. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  85687. /**
  85688. * Dispose the render targets and their associated resources
  85689. */
  85690. dispose(): void;
  85691. /**
  85692. * Release all the underlying texture used as draw buffers.
  85693. */
  85694. releaseInternalTextures(): void;
  85695. }
  85696. }
  85697. declare module BABYLON {
  85698. /**
  85699. * Class used to work with sound analyzer using fast fourier transform (FFT)
  85700. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  85701. */
  85702. export class Analyser {
  85703. /**
  85704. * Gets or sets the smoothing
  85705. * @ignorenaming
  85706. */
  85707. SMOOTHING: number;
  85708. /**
  85709. * Gets or sets the FFT table size
  85710. * @ignorenaming
  85711. */
  85712. FFT_SIZE: number;
  85713. /**
  85714. * Gets or sets the bar graph amplitude
  85715. * @ignorenaming
  85716. */
  85717. BARGRAPHAMPLITUDE: number;
  85718. /**
  85719. * Gets or sets the position of the debug canvas
  85720. * @ignorenaming
  85721. */
  85722. DEBUGCANVASPOS: {
  85723. x: number;
  85724. y: number;
  85725. };
  85726. /**
  85727. * Gets or sets the debug canvas size
  85728. * @ignorenaming
  85729. */
  85730. DEBUGCANVASSIZE: {
  85731. width: number;
  85732. height: number;
  85733. };
  85734. private _byteFreqs;
  85735. private _byteTime;
  85736. private _floatFreqs;
  85737. private _webAudioAnalyser;
  85738. private _debugCanvas;
  85739. private _debugCanvasContext;
  85740. private _scene;
  85741. private _registerFunc;
  85742. private _audioEngine;
  85743. /**
  85744. * Creates a new analyser
  85745. * @param scene defines hosting scene
  85746. */
  85747. constructor(scene: Scene);
  85748. /**
  85749. * Get the number of data values you will have to play with for the visualization
  85750. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  85751. * @returns a number
  85752. */
  85753. getFrequencyBinCount(): number;
  85754. /**
  85755. * Gets the current frequency data as a byte array
  85756. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  85757. * @returns a Uint8Array
  85758. */
  85759. getByteFrequencyData(): Uint8Array;
  85760. /**
  85761. * Gets the current waveform as a byte array
  85762. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  85763. * @returns a Uint8Array
  85764. */
  85765. getByteTimeDomainData(): Uint8Array;
  85766. /**
  85767. * Gets the current frequency data as a float array
  85768. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  85769. * @returns a Float32Array
  85770. */
  85771. getFloatFrequencyData(): Float32Array;
  85772. /**
  85773. * Renders the debug canvas
  85774. */
  85775. drawDebugCanvas(): void;
  85776. /**
  85777. * Stops rendering the debug canvas and removes it
  85778. */
  85779. stopDebugCanvas(): void;
  85780. /**
  85781. * Connects two audio nodes
  85782. * @param inputAudioNode defines first node to connect
  85783. * @param outputAudioNode defines second node to connect
  85784. */
  85785. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  85786. /**
  85787. * Releases all associated resources
  85788. */
  85789. dispose(): void;
  85790. }
  85791. }
  85792. declare module BABYLON {
  85793. /**
  85794. * This represents an audio engine and it is responsible
  85795. * to play, synchronize and analyse sounds throughout the application.
  85796. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  85797. */
  85798. export interface IAudioEngine extends IDisposable {
  85799. /**
  85800. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  85801. */
  85802. readonly canUseWebAudio: boolean;
  85803. /**
  85804. * Gets the current AudioContext if available.
  85805. */
  85806. readonly audioContext: Nullable<AudioContext>;
  85807. /**
  85808. * The master gain node defines the global audio volume of your audio engine.
  85809. */
  85810. readonly masterGain: GainNode;
  85811. /**
  85812. * Gets whether or not mp3 are supported by your browser.
  85813. */
  85814. readonly isMP3supported: boolean;
  85815. /**
  85816. * Gets whether or not ogg are supported by your browser.
  85817. */
  85818. readonly isOGGsupported: boolean;
  85819. /**
  85820. * Defines if Babylon should emit a warning if WebAudio is not supported.
  85821. * @ignoreNaming
  85822. */
  85823. WarnedWebAudioUnsupported: boolean;
  85824. /**
  85825. * Defines if the audio engine relies on a custom unlocked button.
  85826. * In this case, the embedded button will not be displayed.
  85827. */
  85828. useCustomUnlockedButton: boolean;
  85829. /**
  85830. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  85831. */
  85832. readonly unlocked: boolean;
  85833. /**
  85834. * Event raised when audio has been unlocked on the browser.
  85835. */
  85836. onAudioUnlockedObservable: Observable<AudioEngine>;
  85837. /**
  85838. * Event raised when audio has been locked on the browser.
  85839. */
  85840. onAudioLockedObservable: Observable<AudioEngine>;
  85841. /**
  85842. * Flags the audio engine in Locked state.
  85843. * This happens due to new browser policies preventing audio to autoplay.
  85844. */
  85845. lock(): void;
  85846. /**
  85847. * Unlocks the audio engine once a user action has been done on the dom.
  85848. * This is helpful to resume play once browser policies have been satisfied.
  85849. */
  85850. unlock(): void;
  85851. }
  85852. /**
  85853. * This represents the default audio engine used in babylon.
  85854. * It is responsible to play, synchronize and analyse sounds throughout the application.
  85855. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  85856. */
  85857. export class AudioEngine implements IAudioEngine {
  85858. private _audioContext;
  85859. private _audioContextInitialized;
  85860. private _muteButton;
  85861. private _hostElement;
  85862. /**
  85863. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  85864. */
  85865. canUseWebAudio: boolean;
  85866. /**
  85867. * The master gain node defines the global audio volume of your audio engine.
  85868. */
  85869. masterGain: GainNode;
  85870. /**
  85871. * Defines if Babylon should emit a warning if WebAudio is not supported.
  85872. * @ignoreNaming
  85873. */
  85874. WarnedWebAudioUnsupported: boolean;
  85875. /**
  85876. * Gets whether or not mp3 are supported by your browser.
  85877. */
  85878. isMP3supported: boolean;
  85879. /**
  85880. * Gets whether or not ogg are supported by your browser.
  85881. */
  85882. isOGGsupported: boolean;
  85883. /**
  85884. * Gets whether audio has been unlocked on the device.
  85885. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  85886. * a user interaction has happened.
  85887. */
  85888. unlocked: boolean;
  85889. /**
  85890. * Defines if the audio engine relies on a custom unlocked button.
  85891. * In this case, the embedded button will not be displayed.
  85892. */
  85893. useCustomUnlockedButton: boolean;
  85894. /**
  85895. * Event raised when audio has been unlocked on the browser.
  85896. */
  85897. onAudioUnlockedObservable: Observable<AudioEngine>;
  85898. /**
  85899. * Event raised when audio has been locked on the browser.
  85900. */
  85901. onAudioLockedObservable: Observable<AudioEngine>;
  85902. /**
  85903. * Gets the current AudioContext if available.
  85904. */
  85905. readonly audioContext: Nullable<AudioContext>;
  85906. private _connectedAnalyser;
  85907. /**
  85908. * Instantiates a new audio engine.
  85909. *
  85910. * There should be only one per page as some browsers restrict the number
  85911. * of audio contexts you can create.
  85912. * @param hostElement defines the host element where to display the mute icon if necessary
  85913. */
  85914. constructor(hostElement?: Nullable<HTMLElement>);
  85915. /**
  85916. * Flags the audio engine in Locked state.
  85917. * This happens due to new browser policies preventing audio to autoplay.
  85918. */
  85919. lock(): void;
  85920. /**
  85921. * Unlocks the audio engine once a user action has been done on the dom.
  85922. * This is helpful to resume play once browser policies have been satisfied.
  85923. */
  85924. unlock(): void;
  85925. private _resumeAudioContext;
  85926. private _initializeAudioContext;
  85927. private _tryToRun;
  85928. private _triggerRunningState;
  85929. private _triggerSuspendedState;
  85930. private _displayMuteButton;
  85931. private _moveButtonToTopLeft;
  85932. private _onResize;
  85933. private _hideMuteButton;
  85934. /**
  85935. * Destroy and release the resources associated with the audio ccontext.
  85936. */
  85937. dispose(): void;
  85938. /**
  85939. * Gets the global volume sets on the master gain.
  85940. * @returns the global volume if set or -1 otherwise
  85941. */
  85942. getGlobalVolume(): number;
  85943. /**
  85944. * Sets the global volume of your experience (sets on the master gain).
  85945. * @param newVolume Defines the new global volume of the application
  85946. */
  85947. setGlobalVolume(newVolume: number): void;
  85948. /**
  85949. * Connect the audio engine to an audio analyser allowing some amazing
  85950. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  85951. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  85952. * @param analyser The analyser to connect to the engine
  85953. */
  85954. connectToAnalyser(analyser: Analyser): void;
  85955. }
  85956. }
  85957. declare module BABYLON {
  85958. /**
  85959. * Interface used to present a loading screen while loading a scene
  85960. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85961. */
  85962. export interface ILoadingScreen {
  85963. /**
  85964. * Function called to display the loading screen
  85965. */
  85966. displayLoadingUI: () => void;
  85967. /**
  85968. * Function called to hide the loading screen
  85969. */
  85970. hideLoadingUI: () => void;
  85971. /**
  85972. * Gets or sets the color to use for the background
  85973. */
  85974. loadingUIBackgroundColor: string;
  85975. /**
  85976. * Gets or sets the text to display while loading
  85977. */
  85978. loadingUIText: string;
  85979. }
  85980. /**
  85981. * Class used for the default loading screen
  85982. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85983. */
  85984. export class DefaultLoadingScreen implements ILoadingScreen {
  85985. private _renderingCanvas;
  85986. private _loadingText;
  85987. private _loadingDivBackgroundColor;
  85988. private _loadingDiv;
  85989. private _loadingTextDiv;
  85990. /**
  85991. * Creates a new default loading screen
  85992. * @param _renderingCanvas defines the canvas used to render the scene
  85993. * @param _loadingText defines the default text to display
  85994. * @param _loadingDivBackgroundColor defines the default background color
  85995. */
  85996. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  85997. /**
  85998. * Function called to display the loading screen
  85999. */
  86000. displayLoadingUI(): void;
  86001. /**
  86002. * Function called to hide the loading screen
  86003. */
  86004. hideLoadingUI(): void;
  86005. /**
  86006. * Gets or sets the text to display while loading
  86007. */
  86008. loadingUIText: string;
  86009. /**
  86010. * Gets or sets the color to use for the background
  86011. */
  86012. loadingUIBackgroundColor: string;
  86013. private _resizeLoadingUI;
  86014. }
  86015. }
  86016. declare module BABYLON {
  86017. /**
  86018. * Settings for finer control over video usage
  86019. */
  86020. export interface VideoTextureSettings {
  86021. /**
  86022. * Applies `autoplay` to video, if specified
  86023. */
  86024. autoPlay?: boolean;
  86025. /**
  86026. * Applies `loop` to video, if specified
  86027. */
  86028. loop?: boolean;
  86029. /**
  86030. * Automatically updates internal texture from video at every frame in the render loop
  86031. */
  86032. autoUpdateTexture: boolean;
  86033. /**
  86034. * Image src displayed during the video loading or until the user interacts with the video.
  86035. */
  86036. poster?: string;
  86037. }
  86038. /**
  86039. * If you want to display a video in your scene, this is the special texture for that.
  86040. * This special texture works similar to other textures, with the exception of a few parameters.
  86041. * @see https://doc.babylonjs.com/how_to/video_texture
  86042. */
  86043. export class VideoTexture extends Texture {
  86044. /**
  86045. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  86046. */
  86047. readonly autoUpdateTexture: boolean;
  86048. /**
  86049. * The video instance used by the texture internally
  86050. */
  86051. readonly video: HTMLVideoElement;
  86052. private _onUserActionRequestedObservable;
  86053. /**
  86054. * Event triggerd when a dom action is required by the user to play the video.
  86055. * This happens due to recent changes in browser policies preventing video to auto start.
  86056. */
  86057. readonly onUserActionRequestedObservable: Observable<Texture>;
  86058. private _generateMipMaps;
  86059. private _engine;
  86060. private _stillImageCaptured;
  86061. private _displayingPosterTexture;
  86062. private _settings;
  86063. private _createInternalTextureOnEvent;
  86064. /**
  86065. * Creates a video texture.
  86066. * If you want to display a video in your scene, this is the special texture for that.
  86067. * This special texture works similar to other textures, with the exception of a few parameters.
  86068. * @see https://doc.babylonjs.com/how_to/video_texture
  86069. * @param name optional name, will detect from video source, if not defined
  86070. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  86071. * @param scene is obviously the current scene.
  86072. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  86073. * @param invertY is false by default but can be used to invert video on Y axis
  86074. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  86075. * @param settings allows finer control over video usage
  86076. */
  86077. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  86078. private _getName;
  86079. private _getVideo;
  86080. private _createInternalTexture;
  86081. private reset;
  86082. /**
  86083. * @hidden Internal method to initiate `update`.
  86084. */
  86085. _rebuild(): void;
  86086. /**
  86087. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  86088. */
  86089. update(): void;
  86090. /**
  86091. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  86092. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  86093. */
  86094. updateTexture(isVisible: boolean): void;
  86095. protected _updateInternalTexture: () => void;
  86096. /**
  86097. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  86098. * @param url New url.
  86099. */
  86100. updateURL(url: string): void;
  86101. /**
  86102. * Dispose the texture and release its associated resources.
  86103. */
  86104. dispose(): void;
  86105. /**
  86106. * Creates a video texture straight from a stream.
  86107. * @param scene Define the scene the texture should be created in
  86108. * @param stream Define the stream the texture should be created from
  86109. * @returns The created video texture as a promise
  86110. */
  86111. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  86112. /**
  86113. * Creates a video texture straight from your WebCam video feed.
  86114. * @param scene Define the scene the texture should be created in
  86115. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  86116. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  86117. * @returns The created video texture as a promise
  86118. */
  86119. static CreateFromWebCamAsync(scene: Scene, constraints: {
  86120. minWidth: number;
  86121. maxWidth: number;
  86122. minHeight: number;
  86123. maxHeight: number;
  86124. deviceId: string;
  86125. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  86126. /**
  86127. * Creates a video texture straight from your WebCam video feed.
  86128. * @param scene Define the scene the texture should be created in
  86129. * @param onReady Define a callback to triggered once the texture will be ready
  86130. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  86131. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  86132. */
  86133. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  86134. minWidth: number;
  86135. maxWidth: number;
  86136. minHeight: number;
  86137. maxHeight: number;
  86138. deviceId: string;
  86139. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  86140. }
  86141. }
  86142. declare module BABYLON {
  86143. /**
  86144. * Interface for attribute information associated with buffer instanciation
  86145. */
  86146. export class InstancingAttributeInfo {
  86147. /**
  86148. * Index/offset of the attribute in the vertex shader
  86149. */
  86150. index: number;
  86151. /**
  86152. * size of the attribute, 1, 2, 3 or 4
  86153. */
  86154. attributeSize: number;
  86155. /**
  86156. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  86157. * default is FLOAT
  86158. */
  86159. attribyteType: number;
  86160. /**
  86161. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  86162. */
  86163. normalized: boolean;
  86164. /**
  86165. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  86166. */
  86167. offset: number;
  86168. /**
  86169. * Name of the GLSL attribute, for debugging purpose only
  86170. */
  86171. attributeName: string;
  86172. }
  86173. /**
  86174. * Define options used to create a depth texture
  86175. */
  86176. export class DepthTextureCreationOptions {
  86177. /** Specifies whether or not a stencil should be allocated in the texture */
  86178. generateStencil?: boolean;
  86179. /** Specifies whether or not bilinear filtering is enable on the texture */
  86180. bilinearFiltering?: boolean;
  86181. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  86182. comparisonFunction?: number;
  86183. /** Specifies if the created texture is a cube texture */
  86184. isCube?: boolean;
  86185. }
  86186. /**
  86187. * Class used to describe the capabilities of the engine relatively to the current browser
  86188. */
  86189. export class EngineCapabilities {
  86190. /** Maximum textures units per fragment shader */
  86191. maxTexturesImageUnits: number;
  86192. /** Maximum texture units per vertex shader */
  86193. maxVertexTextureImageUnits: number;
  86194. /** Maximum textures units in the entire pipeline */
  86195. maxCombinedTexturesImageUnits: number;
  86196. /** Maximum texture size */
  86197. maxTextureSize: number;
  86198. /** Maximum cube texture size */
  86199. maxCubemapTextureSize: number;
  86200. /** Maximum render texture size */
  86201. maxRenderTextureSize: number;
  86202. /** Maximum number of vertex attributes */
  86203. maxVertexAttribs: number;
  86204. /** Maximum number of varyings */
  86205. maxVaryingVectors: number;
  86206. /** Maximum number of uniforms per vertex shader */
  86207. maxVertexUniformVectors: number;
  86208. /** Maximum number of uniforms per fragment shader */
  86209. maxFragmentUniformVectors: number;
  86210. /** Defines if standard derivates (dx/dy) are supported */
  86211. standardDerivatives: boolean;
  86212. /** Defines if s3tc texture compression is supported */
  86213. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  86214. /** Defines if pvrtc texture compression is supported */
  86215. pvrtc: any;
  86216. /** Defines if etc1 texture compression is supported */
  86217. etc1: any;
  86218. /** Defines if etc2 texture compression is supported */
  86219. etc2: any;
  86220. /** Defines if astc texture compression is supported */
  86221. astc: any;
  86222. /** Defines if float textures are supported */
  86223. textureFloat: boolean;
  86224. /** Defines if vertex array objects are supported */
  86225. vertexArrayObject: boolean;
  86226. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  86227. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  86228. /** Gets the maximum level of anisotropy supported */
  86229. maxAnisotropy: number;
  86230. /** Defines if instancing is supported */
  86231. instancedArrays: boolean;
  86232. /** Defines if 32 bits indices are supported */
  86233. uintIndices: boolean;
  86234. /** Defines if high precision shaders are supported */
  86235. highPrecisionShaderSupported: boolean;
  86236. /** Defines if depth reading in the fragment shader is supported */
  86237. fragmentDepthSupported: boolean;
  86238. /** Defines if float texture linear filtering is supported*/
  86239. textureFloatLinearFiltering: boolean;
  86240. /** Defines if rendering to float textures is supported */
  86241. textureFloatRender: boolean;
  86242. /** Defines if half float textures are supported*/
  86243. textureHalfFloat: boolean;
  86244. /** Defines if half float texture linear filtering is supported*/
  86245. textureHalfFloatLinearFiltering: boolean;
  86246. /** Defines if rendering to half float textures is supported */
  86247. textureHalfFloatRender: boolean;
  86248. /** Defines if textureLOD shader command is supported */
  86249. textureLOD: boolean;
  86250. /** Defines if draw buffers extension is supported */
  86251. drawBuffersExtension: boolean;
  86252. /** Defines if depth textures are supported */
  86253. depthTextureExtension: boolean;
  86254. /** Defines if float color buffer are supported */
  86255. colorBufferFloat: boolean;
  86256. /** Gets disjoint timer query extension (null if not supported) */
  86257. timerQuery: EXT_disjoint_timer_query;
  86258. /** Defines if timestamp can be used with timer query */
  86259. canUseTimestampForTimerQuery: boolean;
  86260. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  86261. multiview: any;
  86262. /** Function used to let the system compiles shaders in background */
  86263. parallelShaderCompile: {
  86264. COMPLETION_STATUS_KHR: number;
  86265. };
  86266. }
  86267. /** Interface defining initialization parameters for Engine class */
  86268. export interface EngineOptions extends WebGLContextAttributes {
  86269. /**
  86270. * Defines if the engine should no exceed a specified device ratio
  86271. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  86272. */
  86273. limitDeviceRatio?: number;
  86274. /**
  86275. * Defines if webvr should be enabled automatically
  86276. * @see http://doc.babylonjs.com/how_to/webvr_camera
  86277. */
  86278. autoEnableWebVR?: boolean;
  86279. /**
  86280. * Defines if webgl2 should be turned off even if supported
  86281. * @see http://doc.babylonjs.com/features/webgl2
  86282. */
  86283. disableWebGL2Support?: boolean;
  86284. /**
  86285. * Defines if webaudio should be initialized as well
  86286. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86287. */
  86288. audioEngine?: boolean;
  86289. /**
  86290. * Defines if animations should run using a deterministic lock step
  86291. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  86292. */
  86293. deterministicLockstep?: boolean;
  86294. /** Defines the maximum steps to use with deterministic lock step mode */
  86295. lockstepMaxSteps?: number;
  86296. /**
  86297. * Defines that engine should ignore context lost events
  86298. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  86299. */
  86300. doNotHandleContextLost?: boolean;
  86301. /**
  86302. * Defines that engine should ignore modifying touch action attribute and style
  86303. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  86304. */
  86305. doNotHandleTouchAction?: boolean;
  86306. /**
  86307. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  86308. */
  86309. useHighPrecisionFloats?: boolean;
  86310. }
  86311. /**
  86312. * Defines the interface used by display changed events
  86313. */
  86314. export interface IDisplayChangedEventArgs {
  86315. /** Gets the vrDisplay object (if any) */
  86316. vrDisplay: Nullable<any>;
  86317. /** Gets a boolean indicating if webVR is supported */
  86318. vrSupported: boolean;
  86319. }
  86320. /**
  86321. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  86322. */
  86323. export class Engine {
  86324. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  86325. static ExceptionList: ({
  86326. key: string;
  86327. capture: string;
  86328. captureConstraint: number;
  86329. targets: string[];
  86330. } | {
  86331. key: string;
  86332. capture: null;
  86333. captureConstraint: null;
  86334. targets: string[];
  86335. })[];
  86336. /** Gets the list of created engines */
  86337. static readonly Instances: Engine[];
  86338. /**
  86339. * Gets the latest created engine
  86340. */
  86341. static readonly LastCreatedEngine: Nullable<Engine>;
  86342. /**
  86343. * Gets the latest created scene
  86344. */
  86345. static readonly LastCreatedScene: Nullable<Scene>;
  86346. /**
  86347. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  86348. * @param flag defines which part of the materials must be marked as dirty
  86349. * @param predicate defines a predicate used to filter which materials should be affected
  86350. */
  86351. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  86352. /**
  86353. * Hidden
  86354. */
  86355. static _TextureLoaders: IInternalTextureLoader[];
  86356. /** Defines that alpha blending is disabled */
  86357. static readonly ALPHA_DISABLE: number;
  86358. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  86359. static readonly ALPHA_ADD: number;
  86360. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  86361. static readonly ALPHA_COMBINE: number;
  86362. /** Defines that alpha blending to DEST - SRC * DEST */
  86363. static readonly ALPHA_SUBTRACT: number;
  86364. /** Defines that alpha blending to SRC * DEST */
  86365. static readonly ALPHA_MULTIPLY: number;
  86366. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  86367. static readonly ALPHA_MAXIMIZED: number;
  86368. /** Defines that alpha blending to SRC + DEST */
  86369. static readonly ALPHA_ONEONE: number;
  86370. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  86371. static readonly ALPHA_PREMULTIPLIED: number;
  86372. /**
  86373. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  86374. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  86375. */
  86376. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  86377. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  86378. static readonly ALPHA_INTERPOLATE: number;
  86379. /**
  86380. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  86381. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  86382. */
  86383. static readonly ALPHA_SCREENMODE: number;
  86384. /** Defines that the ressource is not delayed*/
  86385. static readonly DELAYLOADSTATE_NONE: number;
  86386. /** Defines that the ressource was successfully delay loaded */
  86387. static readonly DELAYLOADSTATE_LOADED: number;
  86388. /** Defines that the ressource is currently delay loading */
  86389. static readonly DELAYLOADSTATE_LOADING: number;
  86390. /** Defines that the ressource is delayed and has not started loading */
  86391. static readonly DELAYLOADSTATE_NOTLOADED: number;
  86392. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  86393. static readonly NEVER: number;
  86394. /** 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 */
  86395. static readonly ALWAYS: number;
  86396. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  86397. static readonly LESS: number;
  86398. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  86399. static readonly EQUAL: number;
  86400. /** 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 */
  86401. static readonly LEQUAL: number;
  86402. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  86403. static readonly GREATER: number;
  86404. /** 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 */
  86405. static readonly GEQUAL: number;
  86406. /** 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 */
  86407. static readonly NOTEQUAL: number;
  86408. /** Passed to stencilOperation to specify that stencil value must be kept */
  86409. static readonly KEEP: number;
  86410. /** Passed to stencilOperation to specify that stencil value must be replaced */
  86411. static readonly REPLACE: number;
  86412. /** Passed to stencilOperation to specify that stencil value must be incremented */
  86413. static readonly INCR: number;
  86414. /** Passed to stencilOperation to specify that stencil value must be decremented */
  86415. static readonly DECR: number;
  86416. /** Passed to stencilOperation to specify that stencil value must be inverted */
  86417. static readonly INVERT: number;
  86418. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  86419. static readonly INCR_WRAP: number;
  86420. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  86421. static readonly DECR_WRAP: number;
  86422. /** Texture is not repeating outside of 0..1 UVs */
  86423. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  86424. /** Texture is repeating outside of 0..1 UVs */
  86425. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  86426. /** Texture is repeating and mirrored */
  86427. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  86428. /** ALPHA */
  86429. static readonly TEXTUREFORMAT_ALPHA: number;
  86430. /** LUMINANCE */
  86431. static readonly TEXTUREFORMAT_LUMINANCE: number;
  86432. /** LUMINANCE_ALPHA */
  86433. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  86434. /** RGB */
  86435. static readonly TEXTUREFORMAT_RGB: number;
  86436. /** RGBA */
  86437. static readonly TEXTUREFORMAT_RGBA: number;
  86438. /** RED */
  86439. static readonly TEXTUREFORMAT_RED: number;
  86440. /** RED (2nd reference) */
  86441. static readonly TEXTUREFORMAT_R: number;
  86442. /** RG */
  86443. static readonly TEXTUREFORMAT_RG: number;
  86444. /** RED_INTEGER */
  86445. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  86446. /** RED_INTEGER (2nd reference) */
  86447. static readonly TEXTUREFORMAT_R_INTEGER: number;
  86448. /** RG_INTEGER */
  86449. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  86450. /** RGB_INTEGER */
  86451. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  86452. /** RGBA_INTEGER */
  86453. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  86454. /** UNSIGNED_BYTE */
  86455. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  86456. /** UNSIGNED_BYTE (2nd reference) */
  86457. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  86458. /** FLOAT */
  86459. static readonly TEXTURETYPE_FLOAT: number;
  86460. /** HALF_FLOAT */
  86461. static readonly TEXTURETYPE_HALF_FLOAT: number;
  86462. /** BYTE */
  86463. static readonly TEXTURETYPE_BYTE: number;
  86464. /** SHORT */
  86465. static readonly TEXTURETYPE_SHORT: number;
  86466. /** UNSIGNED_SHORT */
  86467. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  86468. /** INT */
  86469. static readonly TEXTURETYPE_INT: number;
  86470. /** UNSIGNED_INT */
  86471. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  86472. /** UNSIGNED_SHORT_4_4_4_4 */
  86473. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  86474. /** UNSIGNED_SHORT_5_5_5_1 */
  86475. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  86476. /** UNSIGNED_SHORT_5_6_5 */
  86477. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  86478. /** UNSIGNED_INT_2_10_10_10_REV */
  86479. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  86480. /** UNSIGNED_INT_24_8 */
  86481. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  86482. /** UNSIGNED_INT_10F_11F_11F_REV */
  86483. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  86484. /** UNSIGNED_INT_5_9_9_9_REV */
  86485. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  86486. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  86487. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  86488. /** nearest is mag = nearest and min = nearest and mip = linear */
  86489. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  86490. /** Bilinear is mag = linear and min = linear and mip = nearest */
  86491. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  86492. /** Trilinear is mag = linear and min = linear and mip = linear */
  86493. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  86494. /** nearest is mag = nearest and min = nearest and mip = linear */
  86495. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  86496. /** Bilinear is mag = linear and min = linear and mip = nearest */
  86497. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  86498. /** Trilinear is mag = linear and min = linear and mip = linear */
  86499. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  86500. /** mag = nearest and min = nearest and mip = nearest */
  86501. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  86502. /** mag = nearest and min = linear and mip = nearest */
  86503. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  86504. /** mag = nearest and min = linear and mip = linear */
  86505. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  86506. /** mag = nearest and min = linear and mip = none */
  86507. static readonly TEXTURE_NEAREST_LINEAR: number;
  86508. /** mag = nearest and min = nearest and mip = none */
  86509. static readonly TEXTURE_NEAREST_NEAREST: number;
  86510. /** mag = linear and min = nearest and mip = nearest */
  86511. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  86512. /** mag = linear and min = nearest and mip = linear */
  86513. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  86514. /** mag = linear and min = linear and mip = none */
  86515. static readonly TEXTURE_LINEAR_LINEAR: number;
  86516. /** mag = linear and min = nearest and mip = none */
  86517. static readonly TEXTURE_LINEAR_NEAREST: number;
  86518. /** Explicit coordinates mode */
  86519. static readonly TEXTURE_EXPLICIT_MODE: number;
  86520. /** Spherical coordinates mode */
  86521. static readonly TEXTURE_SPHERICAL_MODE: number;
  86522. /** Planar coordinates mode */
  86523. static readonly TEXTURE_PLANAR_MODE: number;
  86524. /** Cubic coordinates mode */
  86525. static readonly TEXTURE_CUBIC_MODE: number;
  86526. /** Projection coordinates mode */
  86527. static readonly TEXTURE_PROJECTION_MODE: number;
  86528. /** Skybox coordinates mode */
  86529. static readonly TEXTURE_SKYBOX_MODE: number;
  86530. /** Inverse Cubic coordinates mode */
  86531. static readonly TEXTURE_INVCUBIC_MODE: number;
  86532. /** Equirectangular coordinates mode */
  86533. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  86534. /** Equirectangular Fixed coordinates mode */
  86535. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  86536. /** Equirectangular Fixed Mirrored coordinates mode */
  86537. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  86538. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  86539. static readonly SCALEMODE_FLOOR: number;
  86540. /** Defines that texture rescaling will look for the nearest power of 2 size */
  86541. static readonly SCALEMODE_NEAREST: number;
  86542. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  86543. static readonly SCALEMODE_CEILING: number;
  86544. /**
  86545. * Returns the current npm package of the sdk
  86546. */
  86547. static readonly NpmPackage: string;
  86548. /**
  86549. * Returns the current version of the framework
  86550. */
  86551. static readonly Version: string;
  86552. /**
  86553. * Returns a string describing the current engine
  86554. */
  86555. readonly description: string;
  86556. /**
  86557. * Gets or sets the epsilon value used by collision engine
  86558. */
  86559. static CollisionsEpsilon: number;
  86560. /**
  86561. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  86562. */
  86563. static ShadersRepository: string;
  86564. /**
  86565. * Method called to create the default loading screen.
  86566. * This can be overriden in your own app.
  86567. * @param canvas The rendering canvas element
  86568. * @returns The loading screen
  86569. */
  86570. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  86571. /**
  86572. * Method called to create the default rescale post process on each engine.
  86573. */
  86574. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  86575. /**
  86576. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  86577. */
  86578. forcePOTTextures: boolean;
  86579. /**
  86580. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  86581. */
  86582. isFullscreen: boolean;
  86583. /**
  86584. * Gets a boolean indicating if the pointer is currently locked
  86585. */
  86586. isPointerLock: boolean;
  86587. /**
  86588. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  86589. */
  86590. cullBackFaces: boolean;
  86591. /**
  86592. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  86593. */
  86594. renderEvenInBackground: boolean;
  86595. /**
  86596. * Gets or sets a boolean indicating that cache can be kept between frames
  86597. */
  86598. preventCacheWipeBetweenFrames: boolean;
  86599. /**
  86600. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  86601. **/
  86602. enableOfflineSupport: boolean;
  86603. /**
  86604. * 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)
  86605. **/
  86606. disableManifestCheck: boolean;
  86607. /**
  86608. * Gets the list of created scenes
  86609. */
  86610. scenes: Scene[];
  86611. /**
  86612. * Event raised when a new scene is created
  86613. */
  86614. onNewSceneAddedObservable: Observable<Scene>;
  86615. /**
  86616. * Gets the list of created postprocesses
  86617. */
  86618. postProcesses: PostProcess[];
  86619. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  86620. validateShaderPrograms: boolean;
  86621. /**
  86622. * Observable event triggered each time the rendering canvas is resized
  86623. */
  86624. onResizeObservable: Observable<Engine>;
  86625. /**
  86626. * Observable event triggered each time the canvas loses focus
  86627. */
  86628. onCanvasBlurObservable: Observable<Engine>;
  86629. /**
  86630. * Observable event triggered each time the canvas gains focus
  86631. */
  86632. onCanvasFocusObservable: Observable<Engine>;
  86633. /**
  86634. * Observable event triggered each time the canvas receives pointerout event
  86635. */
  86636. onCanvasPointerOutObservable: Observable<PointerEvent>;
  86637. /**
  86638. * Observable event triggered before each texture is initialized
  86639. */
  86640. onBeforeTextureInitObservable: Observable<Texture>;
  86641. private _vrDisplay;
  86642. private _vrSupported;
  86643. private _oldSize;
  86644. private _oldHardwareScaleFactor;
  86645. private _vrExclusivePointerMode;
  86646. private _webVRInitPromise;
  86647. /**
  86648. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  86649. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  86650. */
  86651. readonly isInVRExclusivePointerMode: boolean;
  86652. /**
  86653. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  86654. */
  86655. disableUniformBuffers: boolean;
  86656. /** @hidden */
  86657. _uniformBuffers: UniformBuffer[];
  86658. /**
  86659. * Gets a boolean indicating that the engine supports uniform buffers
  86660. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86661. */
  86662. readonly supportsUniformBuffers: boolean;
  86663. /**
  86664. * Observable raised when the engine begins a new frame
  86665. */
  86666. onBeginFrameObservable: Observable<Engine>;
  86667. /**
  86668. * If set, will be used to request the next animation frame for the render loop
  86669. */
  86670. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  86671. /**
  86672. * Observable raised when the engine ends the current frame
  86673. */
  86674. onEndFrameObservable: Observable<Engine>;
  86675. /**
  86676. * Observable raised when the engine is about to compile a shader
  86677. */
  86678. onBeforeShaderCompilationObservable: Observable<Engine>;
  86679. /**
  86680. * Observable raised when the engine has jsut compiled a shader
  86681. */
  86682. onAfterShaderCompilationObservable: Observable<Engine>;
  86683. /** @hidden */
  86684. _gl: WebGLRenderingContext;
  86685. private _renderingCanvas;
  86686. private _windowIsBackground;
  86687. private _webGLVersion;
  86688. protected _highPrecisionShadersAllowed: boolean;
  86689. /** @hidden */
  86690. readonly _shouldUseHighPrecisionShader: boolean;
  86691. /**
  86692. * Gets a boolean indicating that only power of 2 textures are supported
  86693. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  86694. */
  86695. readonly needPOTTextures: boolean;
  86696. /** @hidden */
  86697. _badOS: boolean;
  86698. /** @hidden */
  86699. _badDesktopOS: boolean;
  86700. /**
  86701. * Gets the audio engine
  86702. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86703. * @ignorenaming
  86704. */
  86705. static audioEngine: IAudioEngine;
  86706. /**
  86707. * Default AudioEngine factory responsible of creating the Audio Engine.
  86708. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  86709. */
  86710. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  86711. /**
  86712. * Default offline support factory responsible of creating a tool used to store data locally.
  86713. * By default, this will create a Database object if the workload has been embedded.
  86714. */
  86715. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  86716. private _onFocus;
  86717. private _onBlur;
  86718. private _onCanvasPointerOut;
  86719. private _onCanvasBlur;
  86720. private _onCanvasFocus;
  86721. private _onFullscreenChange;
  86722. private _onPointerLockChange;
  86723. private _onVRDisplayPointerRestricted;
  86724. private _onVRDisplayPointerUnrestricted;
  86725. private _onVrDisplayConnect;
  86726. private _onVrDisplayDisconnect;
  86727. private _onVrDisplayPresentChange;
  86728. /**
  86729. * Observable signaled when VR display mode changes
  86730. */
  86731. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  86732. /**
  86733. * Observable signaled when VR request present is complete
  86734. */
  86735. onVRRequestPresentComplete: Observable<boolean>;
  86736. /**
  86737. * Observable signaled when VR request present starts
  86738. */
  86739. onVRRequestPresentStart: Observable<Engine>;
  86740. private _hardwareScalingLevel;
  86741. /** @hidden */
  86742. protected _caps: EngineCapabilities;
  86743. private _pointerLockRequested;
  86744. private _isStencilEnable;
  86745. private _colorWrite;
  86746. private _loadingScreen;
  86747. /** @hidden */
  86748. _drawCalls: PerfCounter;
  86749. private _glVersion;
  86750. private _glRenderer;
  86751. private _glVendor;
  86752. private _videoTextureSupported;
  86753. private _renderingQueueLaunched;
  86754. private _activeRenderLoops;
  86755. private _deterministicLockstep;
  86756. private _lockstepMaxSteps;
  86757. /**
  86758. * Observable signaled when a context lost event is raised
  86759. */
  86760. onContextLostObservable: Observable<Engine>;
  86761. /**
  86762. * Observable signaled when a context restored event is raised
  86763. */
  86764. onContextRestoredObservable: Observable<Engine>;
  86765. private _onContextLost;
  86766. private _onContextRestored;
  86767. private _contextWasLost;
  86768. private _doNotHandleContextLost;
  86769. /**
  86770. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  86771. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  86772. */
  86773. doNotHandleContextLost: boolean;
  86774. private _performanceMonitor;
  86775. private _fps;
  86776. private _deltaTime;
  86777. /**
  86778. * Turn this value on if you want to pause FPS computation when in background
  86779. */
  86780. disablePerformanceMonitorInBackground: boolean;
  86781. /**
  86782. * Gets the performance monitor attached to this engine
  86783. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  86784. */
  86785. readonly performanceMonitor: PerformanceMonitor;
  86786. /**
  86787. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  86788. */
  86789. disableVertexArrayObjects: boolean;
  86790. /** @hidden */
  86791. protected _depthCullingState: _DepthCullingState;
  86792. /** @hidden */
  86793. protected _stencilState: _StencilState;
  86794. /** @hidden */
  86795. protected _alphaState: _AlphaState;
  86796. /** @hidden */
  86797. protected _alphaMode: number;
  86798. protected _internalTexturesCache: InternalTexture[];
  86799. /** @hidden */
  86800. protected _activeChannel: number;
  86801. private _currentTextureChannel;
  86802. /** @hidden */
  86803. protected _boundTexturesCache: {
  86804. [key: string]: Nullable<InternalTexture>;
  86805. };
  86806. /** @hidden */
  86807. protected _currentEffect: Nullable<Effect>;
  86808. /** @hidden */
  86809. protected _currentProgram: Nullable<WebGLProgram>;
  86810. private _compiledEffects;
  86811. private _vertexAttribArraysEnabled;
  86812. /** @hidden */
  86813. protected _cachedViewport: Nullable<Viewport>;
  86814. private _cachedVertexArrayObject;
  86815. /** @hidden */
  86816. protected _cachedVertexBuffers: any;
  86817. /** @hidden */
  86818. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  86819. /** @hidden */
  86820. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  86821. /** @hidden */
  86822. protected _currentRenderTarget: Nullable<InternalTexture>;
  86823. private _uintIndicesCurrentlySet;
  86824. private _currentBoundBuffer;
  86825. /** @hidden */
  86826. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  86827. private _currentBufferPointers;
  86828. private _currentInstanceLocations;
  86829. private _currentInstanceBuffers;
  86830. private _textureUnits;
  86831. private _workingCanvas;
  86832. private _workingContext;
  86833. private _rescalePostProcess;
  86834. private _dummyFramebuffer;
  86835. private _externalData;
  86836. private _bindedRenderFunction;
  86837. private _vaoRecordInProgress;
  86838. private _mustWipeVertexAttributes;
  86839. private _emptyTexture;
  86840. private _emptyCubeTexture;
  86841. private _emptyTexture3D;
  86842. /** @hidden */
  86843. _frameHandler: number;
  86844. private _nextFreeTextureSlots;
  86845. private _maxSimultaneousTextures;
  86846. private _activeRequests;
  86847. private _texturesSupported;
  86848. private _textureFormatInUse;
  86849. /**
  86850. * Gets the list of texture formats supported
  86851. */
  86852. readonly texturesSupported: Array<string>;
  86853. /**
  86854. * Gets the list of texture formats in use
  86855. */
  86856. readonly textureFormatInUse: Nullable<string>;
  86857. /**
  86858. * Gets the current viewport
  86859. */
  86860. readonly currentViewport: Nullable<Viewport>;
  86861. /**
  86862. * Gets the default empty texture
  86863. */
  86864. readonly emptyTexture: InternalTexture;
  86865. /**
  86866. * Gets the default empty 3D texture
  86867. */
  86868. readonly emptyTexture3D: InternalTexture;
  86869. /**
  86870. * Gets the default empty cube texture
  86871. */
  86872. readonly emptyCubeTexture: InternalTexture;
  86873. /**
  86874. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  86875. */
  86876. readonly premultipliedAlpha: boolean;
  86877. /**
  86878. * Creates a new engine
  86879. * @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
  86880. * @param antialias defines enable antialiasing (default: false)
  86881. * @param options defines further options to be sent to the getContext() function
  86882. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  86883. */
  86884. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  86885. private _disableTouchAction;
  86886. private _rebuildInternalTextures;
  86887. private _rebuildEffects;
  86888. /**
  86889. * Gets a boolean indicating if all created effects are ready
  86890. * @returns true if all effects are ready
  86891. */
  86892. areAllEffectsReady(): boolean;
  86893. private _rebuildBuffers;
  86894. private _initGLContext;
  86895. /**
  86896. * Gets version of the current webGL context
  86897. */
  86898. readonly webGLVersion: number;
  86899. /**
  86900. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  86901. */
  86902. readonly isStencilEnable: boolean;
  86903. private _prepareWorkingCanvas;
  86904. /**
  86905. * Reset the texture cache to empty state
  86906. */
  86907. resetTextureCache(): void;
  86908. /**
  86909. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  86910. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  86911. * @returns true if engine is in deterministic lock step mode
  86912. */
  86913. isDeterministicLockStep(): boolean;
  86914. /**
  86915. * Gets the max steps when engine is running in deterministic lock step
  86916. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  86917. * @returns the max steps
  86918. */
  86919. getLockstepMaxSteps(): number;
  86920. /**
  86921. * Gets an object containing information about the current webGL context
  86922. * @returns an object containing the vender, the renderer and the version of the current webGL context
  86923. */
  86924. getGlInfo(): {
  86925. vendor: string;
  86926. renderer: string;
  86927. version: string;
  86928. };
  86929. /**
  86930. * Gets current aspect ratio
  86931. * @param camera defines the camera to use to get the aspect ratio
  86932. * @param useScreen defines if screen size must be used (or the current render target if any)
  86933. * @returns a number defining the aspect ratio
  86934. */
  86935. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  86936. /**
  86937. * Gets current screen aspect ratio
  86938. * @returns a number defining the aspect ratio
  86939. */
  86940. getScreenAspectRatio(): number;
  86941. /**
  86942. * Gets the current render width
  86943. * @param useScreen defines if screen size must be used (or the current render target if any)
  86944. * @returns a number defining the current render width
  86945. */
  86946. getRenderWidth(useScreen?: boolean): number;
  86947. /**
  86948. * Gets the current render height
  86949. * @param useScreen defines if screen size must be used (or the current render target if any)
  86950. * @returns a number defining the current render height
  86951. */
  86952. getRenderHeight(useScreen?: boolean): number;
  86953. /**
  86954. * Gets the HTML canvas attached with the current webGL context
  86955. * @returns a HTML canvas
  86956. */
  86957. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  86958. /**
  86959. * Gets the client rect of the HTML canvas attached with the current webGL context
  86960. * @returns a client rectanglee
  86961. */
  86962. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  86963. /**
  86964. * Defines the hardware scaling level.
  86965. * By default the hardware scaling level is computed from the window device ratio.
  86966. * 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.
  86967. * @param level defines the level to use
  86968. */
  86969. setHardwareScalingLevel(level: number): void;
  86970. /**
  86971. * Gets the current hardware scaling level.
  86972. * By default the hardware scaling level is computed from the window device ratio.
  86973. * 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.
  86974. * @returns a number indicating the current hardware scaling level
  86975. */
  86976. getHardwareScalingLevel(): number;
  86977. /**
  86978. * Gets the list of loaded textures
  86979. * @returns an array containing all loaded textures
  86980. */
  86981. getLoadedTexturesCache(): InternalTexture[];
  86982. /**
  86983. * Gets the object containing all engine capabilities
  86984. * @returns the EngineCapabilities object
  86985. */
  86986. getCaps(): EngineCapabilities;
  86987. /**
  86988. * Gets the current depth function
  86989. * @returns a number defining the depth function
  86990. */
  86991. getDepthFunction(): Nullable<number>;
  86992. /**
  86993. * Sets the current depth function
  86994. * @param depthFunc defines the function to use
  86995. */
  86996. setDepthFunction(depthFunc: number): void;
  86997. /**
  86998. * Sets the current depth function to GREATER
  86999. */
  87000. setDepthFunctionToGreater(): void;
  87001. /**
  87002. * Sets the current depth function to GEQUAL
  87003. */
  87004. setDepthFunctionToGreaterOrEqual(): void;
  87005. /**
  87006. * Sets the current depth function to LESS
  87007. */
  87008. setDepthFunctionToLess(): void;
  87009. private _cachedStencilBuffer;
  87010. private _cachedStencilFunction;
  87011. private _cachedStencilMask;
  87012. private _cachedStencilOperationPass;
  87013. private _cachedStencilOperationFail;
  87014. private _cachedStencilOperationDepthFail;
  87015. private _cachedStencilReference;
  87016. /**
  87017. * Caches the the state of the stencil buffer
  87018. */
  87019. cacheStencilState(): void;
  87020. /**
  87021. * Restores the state of the stencil buffer
  87022. */
  87023. restoreStencilState(): void;
  87024. /**
  87025. * Sets the current depth function to LEQUAL
  87026. */
  87027. setDepthFunctionToLessOrEqual(): void;
  87028. /**
  87029. * Gets a boolean indicating if stencil buffer is enabled
  87030. * @returns the current stencil buffer state
  87031. */
  87032. getStencilBuffer(): boolean;
  87033. /**
  87034. * Enable or disable the stencil buffer
  87035. * @param enable defines if the stencil buffer must be enabled or disabled
  87036. */
  87037. setStencilBuffer(enable: boolean): void;
  87038. /**
  87039. * Gets the current stencil mask
  87040. * @returns a number defining the new stencil mask to use
  87041. */
  87042. getStencilMask(): number;
  87043. /**
  87044. * Sets the current stencil mask
  87045. * @param mask defines the new stencil mask to use
  87046. */
  87047. setStencilMask(mask: number): void;
  87048. /**
  87049. * Gets the current stencil function
  87050. * @returns a number defining the stencil function to use
  87051. */
  87052. getStencilFunction(): number;
  87053. /**
  87054. * Gets the current stencil reference value
  87055. * @returns a number defining the stencil reference value to use
  87056. */
  87057. getStencilFunctionReference(): number;
  87058. /**
  87059. * Gets the current stencil mask
  87060. * @returns a number defining the stencil mask to use
  87061. */
  87062. getStencilFunctionMask(): number;
  87063. /**
  87064. * Sets the current stencil function
  87065. * @param stencilFunc defines the new stencil function to use
  87066. */
  87067. setStencilFunction(stencilFunc: number): void;
  87068. /**
  87069. * Sets the current stencil reference
  87070. * @param reference defines the new stencil reference to use
  87071. */
  87072. setStencilFunctionReference(reference: number): void;
  87073. /**
  87074. * Sets the current stencil mask
  87075. * @param mask defines the new stencil mask to use
  87076. */
  87077. setStencilFunctionMask(mask: number): void;
  87078. /**
  87079. * Gets the current stencil operation when stencil fails
  87080. * @returns a number defining stencil operation to use when stencil fails
  87081. */
  87082. getStencilOperationFail(): number;
  87083. /**
  87084. * Gets the current stencil operation when depth fails
  87085. * @returns a number defining stencil operation to use when depth fails
  87086. */
  87087. getStencilOperationDepthFail(): number;
  87088. /**
  87089. * Gets the current stencil operation when stencil passes
  87090. * @returns a number defining stencil operation to use when stencil passes
  87091. */
  87092. getStencilOperationPass(): number;
  87093. /**
  87094. * Sets the stencil operation to use when stencil fails
  87095. * @param operation defines the stencil operation to use when stencil fails
  87096. */
  87097. setStencilOperationFail(operation: number): void;
  87098. /**
  87099. * Sets the stencil operation to use when depth fails
  87100. * @param operation defines the stencil operation to use when depth fails
  87101. */
  87102. setStencilOperationDepthFail(operation: number): void;
  87103. /**
  87104. * Sets the stencil operation to use when stencil passes
  87105. * @param operation defines the stencil operation to use when stencil passes
  87106. */
  87107. setStencilOperationPass(operation: number): void;
  87108. /**
  87109. * Sets a boolean indicating if the dithering state is enabled or disabled
  87110. * @param value defines the dithering state
  87111. */
  87112. setDitheringState(value: boolean): void;
  87113. /**
  87114. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  87115. * @param value defines the rasterizer state
  87116. */
  87117. setRasterizerState(value: boolean): void;
  87118. /**
  87119. * stop executing a render loop function and remove it from the execution array
  87120. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  87121. */
  87122. stopRenderLoop(renderFunction?: () => void): void;
  87123. /** @hidden */
  87124. _renderLoop(): void;
  87125. /**
  87126. * Register and execute a render loop. The engine can have more than one render function
  87127. * @param renderFunction defines the function to continuously execute
  87128. */
  87129. runRenderLoop(renderFunction: () => void): void;
  87130. /**
  87131. * Toggle full screen mode
  87132. * @param requestPointerLock defines if a pointer lock should be requested from the user
  87133. */
  87134. switchFullscreen(requestPointerLock: boolean): void;
  87135. /**
  87136. * Enters full screen mode
  87137. * @param requestPointerLock defines if a pointer lock should be requested from the user
  87138. */
  87139. enterFullscreen(requestPointerLock: boolean): void;
  87140. /**
  87141. * Exits full screen mode
  87142. */
  87143. exitFullscreen(): void;
  87144. /**
  87145. * Clear the current render buffer or the current render target (if any is set up)
  87146. * @param color defines the color to use
  87147. * @param backBuffer defines if the back buffer must be cleared
  87148. * @param depth defines if the depth buffer must be cleared
  87149. * @param stencil defines if the stencil buffer must be cleared
  87150. */
  87151. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  87152. /**
  87153. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  87154. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  87155. * @param y defines the y-coordinate of the corner of the clear rectangle
  87156. * @param width defines the width of the clear rectangle
  87157. * @param height defines the height of the clear rectangle
  87158. * @param clearColor defines the clear color
  87159. */
  87160. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  87161. /**
  87162. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  87163. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  87164. * @param y defines the y-coordinate of the corner of the clear rectangle
  87165. * @param width defines the width of the clear rectangle
  87166. * @param height defines the height of the clear rectangle
  87167. */
  87168. enableScissor(x: number, y: number, width: number, height: number): void;
  87169. /**
  87170. * Disable previously set scissor test rectangle
  87171. */
  87172. disableScissor(): void;
  87173. private _viewportCached;
  87174. /** @hidden */
  87175. _viewport(x: number, y: number, width: number, height: number): void;
  87176. /**
  87177. * Set the WebGL's viewport
  87178. * @param viewport defines the viewport element to be used
  87179. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  87180. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  87181. */
  87182. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  87183. /**
  87184. * Directly set the WebGL Viewport
  87185. * @param x defines the x coordinate of the viewport (in screen space)
  87186. * @param y defines the y coordinate of the viewport (in screen space)
  87187. * @param width defines the width of the viewport (in screen space)
  87188. * @param height defines the height of the viewport (in screen space)
  87189. * @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
  87190. */
  87191. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  87192. /**
  87193. * Begin a new frame
  87194. */
  87195. beginFrame(): void;
  87196. /**
  87197. * Enf the current frame
  87198. */
  87199. endFrame(): void;
  87200. /**
  87201. * Resize the view according to the canvas' size
  87202. */
  87203. resize(): void;
  87204. /**
  87205. * Force a specific size of the canvas
  87206. * @param width defines the new canvas' width
  87207. * @param height defines the new canvas' height
  87208. */
  87209. setSize(width: number, height: number): void;
  87210. /**
  87211. * Gets a boolean indicating if a webVR device was detected
  87212. * @returns true if a webVR device was detected
  87213. */
  87214. isVRDevicePresent(): boolean;
  87215. /**
  87216. * Gets the current webVR device
  87217. * @returns the current webVR device (or null)
  87218. */
  87219. getVRDevice(): any;
  87220. /**
  87221. * Initializes a webVR display and starts listening to display change events
  87222. * The onVRDisplayChangedObservable will be notified upon these changes
  87223. * @returns The onVRDisplayChangedObservable
  87224. */
  87225. initWebVR(): Observable<IDisplayChangedEventArgs>;
  87226. /**
  87227. * Initializes a webVR display and starts listening to display change events
  87228. * The onVRDisplayChangedObservable will be notified upon these changes
  87229. * @returns A promise containing a VRDisplay and if vr is supported
  87230. */
  87231. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  87232. /**
  87233. * Call this function to switch to webVR mode
  87234. * Will do nothing if webVR is not supported or if there is no webVR device
  87235. * @see http://doc.babylonjs.com/how_to/webvr_camera
  87236. */
  87237. enableVR(): void;
  87238. /**
  87239. * Call this function to leave webVR mode
  87240. * Will do nothing if webVR is not supported or if there is no webVR device
  87241. * @see http://doc.babylonjs.com/how_to/webvr_camera
  87242. */
  87243. disableVR(): void;
  87244. private _onVRFullScreenTriggered;
  87245. private _getVRDisplaysAsync;
  87246. /**
  87247. * Binds the frame buffer to the specified texture.
  87248. * @param texture The texture to render to or null for the default canvas
  87249. * @param faceIndex The face of the texture to render to in case of cube texture
  87250. * @param requiredWidth The width of the target to render to
  87251. * @param requiredHeight The height of the target to render to
  87252. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  87253. * @param depthStencilTexture The depth stencil texture to use to render
  87254. * @param lodLevel defines le lod level to bind to the frame buffer
  87255. */
  87256. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  87257. private bindUnboundFramebuffer;
  87258. /**
  87259. * Unbind the current render target texture from the webGL context
  87260. * @param texture defines the render target texture to unbind
  87261. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  87262. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  87263. */
  87264. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  87265. /**
  87266. * Unbind a list of render target textures from the webGL context
  87267. * This is used only when drawBuffer extension or webGL2 are active
  87268. * @param textures defines the render target textures to unbind
  87269. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  87270. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  87271. */
  87272. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  87273. /**
  87274. * Force the mipmap generation for the given render target texture
  87275. * @param texture defines the render target texture to use
  87276. */
  87277. generateMipMapsForCubemap(texture: InternalTexture): void;
  87278. /**
  87279. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  87280. */
  87281. flushFramebuffer(): void;
  87282. /**
  87283. * Unbind the current render target and bind the default framebuffer
  87284. */
  87285. restoreDefaultFramebuffer(): void;
  87286. /**
  87287. * Create an uniform buffer
  87288. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87289. * @param elements defines the content of the uniform buffer
  87290. * @returns the webGL uniform buffer
  87291. */
  87292. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  87293. /**
  87294. * Create a dynamic uniform buffer
  87295. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87296. * @param elements defines the content of the uniform buffer
  87297. * @returns the webGL uniform buffer
  87298. */
  87299. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  87300. /**
  87301. * Update an existing uniform buffer
  87302. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87303. * @param uniformBuffer defines the target uniform buffer
  87304. * @param elements defines the content to update
  87305. * @param offset defines the offset in the uniform buffer where update should start
  87306. * @param count defines the size of the data to update
  87307. */
  87308. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  87309. private _resetVertexBufferBinding;
  87310. /**
  87311. * Creates a vertex buffer
  87312. * @param data the data for the vertex buffer
  87313. * @returns the new WebGL static buffer
  87314. */
  87315. createVertexBuffer(data: DataArray): WebGLBuffer;
  87316. /**
  87317. * Creates a dynamic vertex buffer
  87318. * @param data the data for the dynamic vertex buffer
  87319. * @returns the new WebGL dynamic buffer
  87320. */
  87321. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  87322. /**
  87323. * Update a dynamic index buffer
  87324. * @param indexBuffer defines the target index buffer
  87325. * @param indices defines the data to update
  87326. * @param offset defines the offset in the target index buffer where update should start
  87327. */
  87328. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  87329. /**
  87330. * Updates a dynamic vertex buffer.
  87331. * @param vertexBuffer the vertex buffer to update
  87332. * @param data the data used to update the vertex buffer
  87333. * @param byteOffset the byte offset of the data
  87334. * @param byteLength the byte length of the data
  87335. */
  87336. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  87337. private _resetIndexBufferBinding;
  87338. /**
  87339. * Creates a new index buffer
  87340. * @param indices defines the content of the index buffer
  87341. * @param updatable defines if the index buffer must be updatable
  87342. * @returns a new webGL buffer
  87343. */
  87344. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  87345. /**
  87346. * Bind a webGL buffer to the webGL context
  87347. * @param buffer defines the buffer to bind
  87348. */
  87349. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  87350. /**
  87351. * Bind an uniform buffer to the current webGL context
  87352. * @param buffer defines the buffer to bind
  87353. */
  87354. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  87355. /**
  87356. * Bind a buffer to the current webGL context at a given location
  87357. * @param buffer defines the buffer to bind
  87358. * @param location defines the index where to bind the buffer
  87359. */
  87360. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  87361. /**
  87362. * Bind a specific block at a given index in a specific shader program
  87363. * @param shaderProgram defines the shader program
  87364. * @param blockName defines the block name
  87365. * @param index defines the index where to bind the block
  87366. */
  87367. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  87368. private bindIndexBuffer;
  87369. private bindBuffer;
  87370. /**
  87371. * update the bound buffer with the given data
  87372. * @param data defines the data to update
  87373. */
  87374. updateArrayBuffer(data: Float32Array): void;
  87375. private _vertexAttribPointer;
  87376. private _bindIndexBufferWithCache;
  87377. private _bindVertexBuffersAttributes;
  87378. /**
  87379. * Records a vertex array object
  87380. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  87381. * @param vertexBuffers defines the list of vertex buffers to store
  87382. * @param indexBuffer defines the index buffer to store
  87383. * @param effect defines the effect to store
  87384. * @returns the new vertex array object
  87385. */
  87386. recordVertexArrayObject(vertexBuffers: {
  87387. [key: string]: VertexBuffer;
  87388. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  87389. /**
  87390. * Bind a specific vertex array object
  87391. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  87392. * @param vertexArrayObject defines the vertex array object to bind
  87393. * @param indexBuffer defines the index buffer to bind
  87394. */
  87395. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  87396. /**
  87397. * Bind webGl buffers directly to the webGL context
  87398. * @param vertexBuffer defines the vertex buffer to bind
  87399. * @param indexBuffer defines the index buffer to bind
  87400. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  87401. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  87402. * @param effect defines the effect associated with the vertex buffer
  87403. */
  87404. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  87405. private _unbindVertexArrayObject;
  87406. /**
  87407. * Bind a list of vertex buffers to the webGL context
  87408. * @param vertexBuffers defines the list of vertex buffers to bind
  87409. * @param indexBuffer defines the index buffer to bind
  87410. * @param effect defines the effect associated with the vertex buffers
  87411. */
  87412. bindBuffers(vertexBuffers: {
  87413. [key: string]: Nullable<VertexBuffer>;
  87414. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  87415. /**
  87416. * Unbind all instance attributes
  87417. */
  87418. unbindInstanceAttributes(): void;
  87419. /**
  87420. * Release and free the memory of a vertex array object
  87421. * @param vao defines the vertex array object to delete
  87422. */
  87423. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  87424. /** @hidden */
  87425. _releaseBuffer(buffer: WebGLBuffer): boolean;
  87426. /**
  87427. * Creates a webGL buffer to use with instanciation
  87428. * @param capacity defines the size of the buffer
  87429. * @returns the webGL buffer
  87430. */
  87431. createInstancesBuffer(capacity: number): WebGLBuffer;
  87432. /**
  87433. * Delete a webGL buffer used with instanciation
  87434. * @param buffer defines the webGL buffer to delete
  87435. */
  87436. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  87437. /**
  87438. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  87439. * @param instancesBuffer defines the webGL buffer to update and bind
  87440. * @param data defines the data to store in the buffer
  87441. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  87442. */
  87443. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  87444. /**
  87445. * Apply all cached states (depth, culling, stencil and alpha)
  87446. */
  87447. applyStates(): void;
  87448. /**
  87449. * Send a draw order
  87450. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  87451. * @param indexStart defines the starting index
  87452. * @param indexCount defines the number of index to draw
  87453. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87454. */
  87455. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  87456. /**
  87457. * Draw a list of points
  87458. * @param verticesStart defines the index of first vertex to draw
  87459. * @param verticesCount defines the count of vertices to draw
  87460. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87461. */
  87462. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  87463. /**
  87464. * Draw a list of unindexed primitives
  87465. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  87466. * @param verticesStart defines the index of first vertex to draw
  87467. * @param verticesCount defines the count of vertices to draw
  87468. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87469. */
  87470. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  87471. /**
  87472. * Draw a list of indexed primitives
  87473. * @param fillMode defines the primitive to use
  87474. * @param indexStart defines the starting index
  87475. * @param indexCount defines the number of index to draw
  87476. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87477. */
  87478. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  87479. /**
  87480. * Draw a list of unindexed primitives
  87481. * @param fillMode defines the primitive to use
  87482. * @param verticesStart defines the index of first vertex to draw
  87483. * @param verticesCount defines the count of vertices to draw
  87484. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87485. */
  87486. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  87487. private _drawMode;
  87488. /** @hidden */
  87489. _releaseEffect(effect: Effect): void;
  87490. /** @hidden */
  87491. _deleteProgram(program: WebGLProgram): void;
  87492. /**
  87493. * Create a new effect (used to store vertex/fragment shaders)
  87494. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  87495. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  87496. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  87497. * @param samplers defines an array of string used to represent textures
  87498. * @param defines defines the string containing the defines to use to compile the shaders
  87499. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  87500. * @param onCompiled defines a function to call when the effect creation is successful
  87501. * @param onError defines a function to call when the effect creation has failed
  87502. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  87503. * @returns the new Effect
  87504. */
  87505. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any): Effect;
  87506. private _compileShader;
  87507. private _compileRawShader;
  87508. /**
  87509. * Directly creates a webGL program
  87510. * @param vertexCode defines the vertex shader code to use
  87511. * @param fragmentCode defines the fragment shader code to use
  87512. * @param context defines the webGL context to use (if not set, the current one will be used)
  87513. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  87514. * @returns the new webGL program
  87515. */
  87516. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  87517. /**
  87518. * Creates a webGL program
  87519. * @param vertexCode defines the vertex shader code to use
  87520. * @param fragmentCode defines the fragment shader code to use
  87521. * @param defines defines the string containing the defines to use to compile the shaders
  87522. * @param context defines the webGL context to use (if not set, the current one will be used)
  87523. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  87524. * @returns the new webGL program
  87525. */
  87526. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  87527. private _createShaderProgram;
  87528. private _finalizeProgram;
  87529. /** @hidden */
  87530. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  87531. /** @hidden */
  87532. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  87533. /**
  87534. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  87535. * @param shaderProgram defines the webGL program to use
  87536. * @param uniformsNames defines the list of uniform names
  87537. * @returns an array of webGL uniform locations
  87538. */
  87539. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  87540. /**
  87541. * Gets the lsit of active attributes for a given webGL program
  87542. * @param shaderProgram defines the webGL program to use
  87543. * @param attributesNames defines the list of attribute names to get
  87544. * @returns an array of indices indicating the offset of each attribute
  87545. */
  87546. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  87547. /**
  87548. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  87549. * @param effect defines the effect to activate
  87550. */
  87551. enableEffect(effect: Nullable<Effect>): void;
  87552. /**
  87553. * Set the value of an uniform to an array of int32
  87554. * @param uniform defines the webGL uniform location where to store the value
  87555. * @param array defines the array of int32 to store
  87556. */
  87557. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  87558. /**
  87559. * Set the value of an uniform to an array of int32 (stored as vec2)
  87560. * @param uniform defines the webGL uniform location where to store the value
  87561. * @param array defines the array of int32 to store
  87562. */
  87563. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  87564. /**
  87565. * Set the value of an uniform to an array of int32 (stored as vec3)
  87566. * @param uniform defines the webGL uniform location where to store the value
  87567. * @param array defines the array of int32 to store
  87568. */
  87569. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  87570. /**
  87571. * Set the value of an uniform to an array of int32 (stored as vec4)
  87572. * @param uniform defines the webGL uniform location where to store the value
  87573. * @param array defines the array of int32 to store
  87574. */
  87575. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  87576. /**
  87577. * Set the value of an uniform to an array of float32
  87578. * @param uniform defines the webGL uniform location where to store the value
  87579. * @param array defines the array of float32 to store
  87580. */
  87581. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  87582. /**
  87583. * Set the value of an uniform to an array of float32 (stored as vec2)
  87584. * @param uniform defines the webGL uniform location where to store the value
  87585. * @param array defines the array of float32 to store
  87586. */
  87587. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  87588. /**
  87589. * Set the value of an uniform to an array of float32 (stored as vec3)
  87590. * @param uniform defines the webGL uniform location where to store the value
  87591. * @param array defines the array of float32 to store
  87592. */
  87593. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  87594. /**
  87595. * Set the value of an uniform to an array of float32 (stored as vec4)
  87596. * @param uniform defines the webGL uniform location where to store the value
  87597. * @param array defines the array of float32 to store
  87598. */
  87599. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  87600. /**
  87601. * Set the value of an uniform to an array of number
  87602. * @param uniform defines the webGL uniform location where to store the value
  87603. * @param array defines the array of number to store
  87604. */
  87605. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  87606. /**
  87607. * Set the value of an uniform to an array of number (stored as vec2)
  87608. * @param uniform defines the webGL uniform location where to store the value
  87609. * @param array defines the array of number to store
  87610. */
  87611. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  87612. /**
  87613. * Set the value of an uniform to an array of number (stored as vec3)
  87614. * @param uniform defines the webGL uniform location where to store the value
  87615. * @param array defines the array of number to store
  87616. */
  87617. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  87618. /**
  87619. * Set the value of an uniform to an array of number (stored as vec4)
  87620. * @param uniform defines the webGL uniform location where to store the value
  87621. * @param array defines the array of number to store
  87622. */
  87623. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  87624. /**
  87625. * Set the value of an uniform to an array of float32 (stored as matrices)
  87626. * @param uniform defines the webGL uniform location where to store the value
  87627. * @param matrices defines the array of float32 to store
  87628. */
  87629. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  87630. /**
  87631. * Set the value of an uniform to a matrix
  87632. * @param uniform defines the webGL uniform location where to store the value
  87633. * @param matrix defines the matrix to store
  87634. */
  87635. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  87636. /**
  87637. * Set the value of an uniform to a matrix (3x3)
  87638. * @param uniform defines the webGL uniform location where to store the value
  87639. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  87640. */
  87641. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  87642. /**
  87643. * Set the value of an uniform to a matrix (2x2)
  87644. * @param uniform defines the webGL uniform location where to store the value
  87645. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  87646. */
  87647. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  87648. /**
  87649. * Set the value of an uniform to a number (int)
  87650. * @param uniform defines the webGL uniform location where to store the value
  87651. * @param value defines the int number to store
  87652. */
  87653. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  87654. /**
  87655. * Set the value of an uniform to a number (float)
  87656. * @param uniform defines the webGL uniform location where to store the value
  87657. * @param value defines the float number to store
  87658. */
  87659. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  87660. /**
  87661. * Set the value of an uniform to a vec2
  87662. * @param uniform defines the webGL uniform location where to store the value
  87663. * @param x defines the 1st component of the value
  87664. * @param y defines the 2nd component of the value
  87665. */
  87666. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  87667. /**
  87668. * Set the value of an uniform to a vec3
  87669. * @param uniform defines the webGL uniform location where to store the value
  87670. * @param x defines the 1st component of the value
  87671. * @param y defines the 2nd component of the value
  87672. * @param z defines the 3rd component of the value
  87673. */
  87674. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  87675. /**
  87676. * Set the value of an uniform to a boolean
  87677. * @param uniform defines the webGL uniform location where to store the value
  87678. * @param bool defines the boolean to store
  87679. */
  87680. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  87681. /**
  87682. * Set the value of an uniform to a vec4
  87683. * @param uniform defines the webGL uniform location where to store the value
  87684. * @param x defines the 1st component of the value
  87685. * @param y defines the 2nd component of the value
  87686. * @param z defines the 3rd component of the value
  87687. * @param w defines the 4th component of the value
  87688. */
  87689. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  87690. /**
  87691. * Set the value of an uniform to a Color3
  87692. * @param uniform defines the webGL uniform location where to store the value
  87693. * @param color3 defines the color to store
  87694. */
  87695. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  87696. /**
  87697. * Set the value of an uniform to a Color3 and an alpha value
  87698. * @param uniform defines the webGL uniform location where to store the value
  87699. * @param color3 defines the color to store
  87700. * @param alpha defines the alpha component to store
  87701. */
  87702. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  87703. /**
  87704. * Sets a Color4 on a uniform variable
  87705. * @param uniform defines the uniform location
  87706. * @param color4 defines the value to be set
  87707. */
  87708. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  87709. /**
  87710. * Set various states to the webGL context
  87711. * @param culling defines backface culling state
  87712. * @param zOffset defines the value to apply to zOffset (0 by default)
  87713. * @param force defines if states must be applied even if cache is up to date
  87714. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  87715. */
  87716. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  87717. /**
  87718. * Set the z offset to apply to current rendering
  87719. * @param value defines the offset to apply
  87720. */
  87721. setZOffset(value: number): void;
  87722. /**
  87723. * Gets the current value of the zOffset
  87724. * @returns the current zOffset state
  87725. */
  87726. getZOffset(): number;
  87727. /**
  87728. * Enable or disable depth buffering
  87729. * @param enable defines the state to set
  87730. */
  87731. setDepthBuffer(enable: boolean): void;
  87732. /**
  87733. * Gets a boolean indicating if depth writing is enabled
  87734. * @returns the current depth writing state
  87735. */
  87736. getDepthWrite(): boolean;
  87737. /**
  87738. * Enable or disable depth writing
  87739. * @param enable defines the state to set
  87740. */
  87741. setDepthWrite(enable: boolean): void;
  87742. /**
  87743. * Enable or disable color writing
  87744. * @param enable defines the state to set
  87745. */
  87746. setColorWrite(enable: boolean): void;
  87747. /**
  87748. * Gets a boolean indicating if color writing is enabled
  87749. * @returns the current color writing state
  87750. */
  87751. getColorWrite(): boolean;
  87752. /**
  87753. * Sets alpha constants used by some alpha blending modes
  87754. * @param r defines the red component
  87755. * @param g defines the green component
  87756. * @param b defines the blue component
  87757. * @param a defines the alpha component
  87758. */
  87759. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  87760. /**
  87761. * Sets the current alpha mode
  87762. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  87763. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  87764. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  87765. */
  87766. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  87767. /**
  87768. * Gets the current alpha mode
  87769. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  87770. * @returns the current alpha mode
  87771. */
  87772. getAlphaMode(): number;
  87773. /**
  87774. * Clears the list of texture accessible through engine.
  87775. * This can help preventing texture load conflict due to name collision.
  87776. */
  87777. clearInternalTexturesCache(): void;
  87778. /**
  87779. * Force the entire cache to be cleared
  87780. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  87781. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  87782. */
  87783. wipeCaches(bruteForce?: boolean): void;
  87784. /**
  87785. * Set the compressed texture format to use, based on the formats you have, and the formats
  87786. * supported by the hardware / browser.
  87787. *
  87788. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  87789. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  87790. * to API arguments needed to compressed textures. This puts the burden on the container
  87791. * generator to house the arcane code for determining these for current & future formats.
  87792. *
  87793. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  87794. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  87795. *
  87796. * Note: The result of this call is not taken into account when a texture is base64.
  87797. *
  87798. * @param formatsAvailable defines the list of those format families you have created
  87799. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  87800. *
  87801. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  87802. * @returns The extension selected.
  87803. */
  87804. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  87805. private _getSamplingParameters;
  87806. private _partialLoadImg;
  87807. private _cascadeLoadImgs;
  87808. /** @hidden */
  87809. _createTexture(): WebGLTexture;
  87810. /**
  87811. * Usually called from Texture.ts.
  87812. * Passed information to create a WebGLTexture
  87813. * @param urlArg defines a value which contains one of the following:
  87814. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  87815. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  87816. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  87817. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  87818. * @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)
  87819. * @param scene needed for loading to the correct scene
  87820. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  87821. * @param onLoad optional callback to be called upon successful completion
  87822. * @param onError optional callback to be called upon failure
  87823. * @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
  87824. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  87825. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  87826. * @param forcedExtension defines the extension to use to pick the right loader
  87827. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  87828. * @returns a InternalTexture for assignment back into BABYLON.Texture
  87829. */
  87830. 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;
  87831. private _rescaleTexture;
  87832. /**
  87833. * Update a raw texture
  87834. * @param texture defines the texture to update
  87835. * @param data defines the data to store in the texture
  87836. * @param format defines the format of the data
  87837. * @param invertY defines if data must be stored with Y axis inverted
  87838. * @param compression defines the compression used (null by default)
  87839. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  87840. */
  87841. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  87842. /**
  87843. * Creates a raw texture
  87844. * @param data defines the data to store in the texture
  87845. * @param width defines the width of the texture
  87846. * @param height defines the height of the texture
  87847. * @param format defines the format of the data
  87848. * @param generateMipMaps defines if the engine should generate the mip levels
  87849. * @param invertY defines if data must be stored with Y axis inverted
  87850. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  87851. * @param compression defines the compression used (null by default)
  87852. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  87853. * @returns the raw texture inside an InternalTexture
  87854. */
  87855. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  87856. private _unpackFlipYCached;
  87857. /**
  87858. * In case you are sharing the context with other applications, it might
  87859. * be interested to not cache the unpack flip y state to ensure a consistent
  87860. * value would be set.
  87861. */
  87862. enableUnpackFlipYCached: boolean;
  87863. /** @hidden */
  87864. _unpackFlipY(value: boolean): void;
  87865. /** @hidden */
  87866. _getUnpackAlignement(): number;
  87867. /**
  87868. * Creates a dynamic texture
  87869. * @param width defines the width of the texture
  87870. * @param height defines the height of the texture
  87871. * @param generateMipMaps defines if the engine should generate the mip levels
  87872. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  87873. * @returns the dynamic texture inside an InternalTexture
  87874. */
  87875. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  87876. /**
  87877. * Update the sampling mode of a given texture
  87878. * @param samplingMode defines the required sampling mode
  87879. * @param texture defines the texture to update
  87880. */
  87881. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  87882. /**
  87883. * Update the content of a dynamic texture
  87884. * @param texture defines the texture to update
  87885. * @param canvas defines the canvas containing the source
  87886. * @param invertY defines if data must be stored with Y axis inverted
  87887. * @param premulAlpha defines if alpha is stored as premultiplied
  87888. * @param format defines the format of the data
  87889. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  87890. */
  87891. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  87892. /**
  87893. * Update a video texture
  87894. * @param texture defines the texture to update
  87895. * @param video defines the video element to use
  87896. * @param invertY defines if data must be stored with Y axis inverted
  87897. */
  87898. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  87899. /**
  87900. * Updates a depth texture Comparison Mode and Function.
  87901. * If the comparison Function is equal to 0, the mode will be set to none.
  87902. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  87903. * @param texture The texture to set the comparison function for
  87904. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  87905. */
  87906. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  87907. private _setupDepthStencilTexture;
  87908. /**
  87909. * Creates a depth stencil texture.
  87910. * This is only available in WebGL 2 or with the depth texture extension available.
  87911. * @param size The size of face edge in the texture.
  87912. * @param options The options defining the texture.
  87913. * @returns The texture
  87914. */
  87915. createDepthStencilTexture(size: number | {
  87916. width: number;
  87917. height: number;
  87918. }, options: DepthTextureCreationOptions): InternalTexture;
  87919. /**
  87920. * Creates a depth stencil texture.
  87921. * This is only available in WebGL 2 or with the depth texture extension available.
  87922. * @param size The size of face edge in the texture.
  87923. * @param options The options defining the texture.
  87924. * @returns The texture
  87925. */
  87926. private _createDepthStencilTexture;
  87927. /**
  87928. * Creates a depth stencil cube texture.
  87929. * This is only available in WebGL 2.
  87930. * @param size The size of face edge in the cube texture.
  87931. * @param options The options defining the cube texture.
  87932. * @returns The cube texture
  87933. */
  87934. private _createDepthStencilCubeTexture;
  87935. /**
  87936. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  87937. * @param renderTarget The render target to set the frame buffer for
  87938. */
  87939. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  87940. /**
  87941. * Creates a new render target texture
  87942. * @param size defines the size of the texture
  87943. * @param options defines the options used to create the texture
  87944. * @returns a new render target texture stored in an InternalTexture
  87945. */
  87946. createRenderTargetTexture(size: number | {
  87947. width: number;
  87948. height: number;
  87949. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  87950. /**
  87951. * Create a multi render target texture
  87952. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  87953. * @param size defines the size of the texture
  87954. * @param options defines the creation options
  87955. * @returns the cube texture as an InternalTexture
  87956. */
  87957. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  87958. private _setupFramebufferDepthAttachments;
  87959. /**
  87960. * Updates the sample count of a render target texture
  87961. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  87962. * @param texture defines the texture to update
  87963. * @param samples defines the sample count to set
  87964. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  87965. */
  87966. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  87967. /**
  87968. * Update the sample count for a given multiple render target texture
  87969. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  87970. * @param textures defines the textures to update
  87971. * @param samples defines the sample count to set
  87972. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  87973. */
  87974. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  87975. /** @hidden */
  87976. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  87977. /** @hidden */
  87978. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  87979. /** @hidden */
  87980. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  87981. /** @hidden */
  87982. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  87983. /**
  87984. * Creates a new render target cube texture
  87985. * @param size defines the size of the texture
  87986. * @param options defines the options used to create the texture
  87987. * @returns a new render target cube texture stored in an InternalTexture
  87988. */
  87989. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  87990. /**
  87991. * Creates a cube texture
  87992. * @param rootUrl defines the url where the files to load is located
  87993. * @param scene defines the current scene
  87994. * @param files defines the list of files to load (1 per face)
  87995. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  87996. * @param onLoad defines an optional callback raised when the texture is loaded
  87997. * @param onError defines an optional callback raised if there is an issue to load the texture
  87998. * @param format defines the format of the data
  87999. * @param forcedExtension defines the extension to use to pick the right loader
  88000. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  88001. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88002. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88003. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  88004. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  88005. * @returns the cube texture as an InternalTexture
  88006. */
  88007. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  88008. /**
  88009. * @hidden
  88010. */
  88011. _setCubeMapTextureParams(loadMipmap: boolean): void;
  88012. /**
  88013. * Update a raw cube texture
  88014. * @param texture defines the texture to udpdate
  88015. * @param data defines the data to store
  88016. * @param format defines the data format
  88017. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  88018. * @param invertY defines if data must be stored with Y axis inverted
  88019. * @param compression defines the compression used (null by default)
  88020. * @param level defines which level of the texture to update
  88021. */
  88022. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  88023. /**
  88024. * Creates a new raw cube texture
  88025. * @param data defines the array of data to use to create each face
  88026. * @param size defines the size of the textures
  88027. * @param format defines the format of the data
  88028. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  88029. * @param generateMipMaps defines if the engine should generate the mip levels
  88030. * @param invertY defines if data must be stored with Y axis inverted
  88031. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  88032. * @param compression defines the compression used (null by default)
  88033. * @returns the cube texture as an InternalTexture
  88034. */
  88035. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  88036. /**
  88037. * Creates a new raw cube texture from a specified url
  88038. * @param url defines the url where the data is located
  88039. * @param scene defines the current scene
  88040. * @param size defines the size of the textures
  88041. * @param format defines the format of the data
  88042. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  88043. * @param noMipmap defines if the engine should avoid generating the mip levels
  88044. * @param callback defines a callback used to extract texture data from loaded data
  88045. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  88046. * @param onLoad defines a callback called when texture is loaded
  88047. * @param onError defines a callback called if there is an error
  88048. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  88049. * @param invertY defines if data must be stored with Y axis inverted
  88050. * @returns the cube texture as an InternalTexture
  88051. */
  88052. 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;
  88053. /**
  88054. * Update a raw 3D texture
  88055. * @param texture defines the texture to update
  88056. * @param data defines the data to store
  88057. * @param format defines the data format
  88058. * @param invertY defines if data must be stored with Y axis inverted
  88059. * @param compression defines the used compression (can be null)
  88060. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  88061. */
  88062. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  88063. /**
  88064. * Creates a new raw 3D texture
  88065. * @param data defines the data used to create the texture
  88066. * @param width defines the width of the texture
  88067. * @param height defines the height of the texture
  88068. * @param depth defines the depth of the texture
  88069. * @param format defines the format of the texture
  88070. * @param generateMipMaps defines if the engine must generate mip levels
  88071. * @param invertY defines if data must be stored with Y axis inverted
  88072. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  88073. * @param compression defines the compressed used (can be null)
  88074. * @param textureType defines the compressed used (can be null)
  88075. * @returns a new raw 3D texture (stored in an InternalTexture)
  88076. */
  88077. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  88078. private _prepareWebGLTextureContinuation;
  88079. private _prepareWebGLTexture;
  88080. private _convertRGBtoRGBATextureData;
  88081. /** @hidden */
  88082. _releaseFramebufferObjects(texture: InternalTexture): void;
  88083. /** @hidden */
  88084. _releaseTexture(texture: InternalTexture): void;
  88085. private setProgram;
  88086. private _boundUniforms;
  88087. /**
  88088. * Binds an effect to the webGL context
  88089. * @param effect defines the effect to bind
  88090. */
  88091. bindSamplers(effect: Effect): void;
  88092. private _activateCurrentTexture;
  88093. /** @hidden */
  88094. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  88095. /** @hidden */
  88096. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  88097. /**
  88098. * Sets a texture to the webGL context from a postprocess
  88099. * @param channel defines the channel to use
  88100. * @param postProcess defines the source postprocess
  88101. */
  88102. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  88103. /**
  88104. * Binds the output of the passed in post process to the texture channel specified
  88105. * @param channel The channel the texture should be bound to
  88106. * @param postProcess The post process which's output should be bound
  88107. */
  88108. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  88109. /**
  88110. * Unbind all textures from the webGL context
  88111. */
  88112. unbindAllTextures(): void;
  88113. /**
  88114. * Sets a texture to the according uniform.
  88115. * @param channel The texture channel
  88116. * @param uniform The uniform to set
  88117. * @param texture The texture to apply
  88118. */
  88119. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  88120. /**
  88121. * Sets a depth stencil texture from a render target to the according uniform.
  88122. * @param channel The texture channel
  88123. * @param uniform The uniform to set
  88124. * @param texture The render target texture containing the depth stencil texture to apply
  88125. */
  88126. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  88127. private _bindSamplerUniformToChannel;
  88128. private _getTextureWrapMode;
  88129. private _setTexture;
  88130. /**
  88131. * Sets an array of texture to the webGL context
  88132. * @param channel defines the channel where the texture array must be set
  88133. * @param uniform defines the associated uniform location
  88134. * @param textures defines the array of textures to bind
  88135. */
  88136. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  88137. /** @hidden */
  88138. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  88139. private _setTextureParameterFloat;
  88140. private _setTextureParameterInteger;
  88141. /**
  88142. * Reads pixels from the current frame buffer. Please note that this function can be slow
  88143. * @param x defines the x coordinate of the rectangle where pixels must be read
  88144. * @param y defines the y coordinate of the rectangle where pixels must be read
  88145. * @param width defines the width of the rectangle where pixels must be read
  88146. * @param height defines the height of the rectangle where pixels must be read
  88147. * @returns a Uint8Array containing RGBA colors
  88148. */
  88149. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  88150. /**
  88151. * Add an externaly attached data from its key.
  88152. * This method call will fail and return false, if such key already exists.
  88153. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  88154. * @param key the unique key that identifies the data
  88155. * @param data the data object to associate to the key for this Engine instance
  88156. * @return true if no such key were already present and the data was added successfully, false otherwise
  88157. */
  88158. addExternalData<T>(key: string, data: T): boolean;
  88159. /**
  88160. * Get an externaly attached data from its key
  88161. * @param key the unique key that identifies the data
  88162. * @return the associated data, if present (can be null), or undefined if not present
  88163. */
  88164. getExternalData<T>(key: string): T;
  88165. /**
  88166. * Get an externaly attached data from its key, create it using a factory if it's not already present
  88167. * @param key the unique key that identifies the data
  88168. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  88169. * @return the associated data, can be null if the factory returned null.
  88170. */
  88171. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  88172. /**
  88173. * Remove an externaly attached data from the Engine instance
  88174. * @param key the unique key that identifies the data
  88175. * @return true if the data was successfully removed, false if it doesn't exist
  88176. */
  88177. removeExternalData(key: string): boolean;
  88178. /**
  88179. * Unbind all vertex attributes from the webGL context
  88180. */
  88181. unbindAllAttributes(): void;
  88182. /**
  88183. * 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
  88184. */
  88185. releaseEffects(): void;
  88186. /**
  88187. * Dispose and release all associated resources
  88188. */
  88189. dispose(): void;
  88190. /**
  88191. * Display the loading screen
  88192. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88193. */
  88194. displayLoadingUI(): void;
  88195. /**
  88196. * Hide the loading screen
  88197. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88198. */
  88199. hideLoadingUI(): void;
  88200. /**
  88201. * Gets the current loading screen object
  88202. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88203. */
  88204. /**
  88205. * Sets the current loading screen object
  88206. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88207. */
  88208. loadingScreen: ILoadingScreen;
  88209. /**
  88210. * Sets the current loading screen text
  88211. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88212. */
  88213. loadingUIText: string;
  88214. /**
  88215. * Sets the current loading screen background color
  88216. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88217. */
  88218. loadingUIBackgroundColor: string;
  88219. /**
  88220. * Attach a new callback raised when context lost event is fired
  88221. * @param callback defines the callback to call
  88222. */
  88223. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  88224. /**
  88225. * Attach a new callback raised when context restored event is fired
  88226. * @param callback defines the callback to call
  88227. */
  88228. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  88229. /**
  88230. * Gets the source code of the vertex shader associated with a specific webGL program
  88231. * @param program defines the program to use
  88232. * @returns a string containing the source code of the vertex shader associated with the program
  88233. */
  88234. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  88235. /**
  88236. * Gets the source code of the fragment shader associated with a specific webGL program
  88237. * @param program defines the program to use
  88238. * @returns a string containing the source code of the fragment shader associated with the program
  88239. */
  88240. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  88241. /**
  88242. * Get the current error code of the webGL context
  88243. * @returns the error code
  88244. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  88245. */
  88246. getError(): number;
  88247. /**
  88248. * Gets the current framerate
  88249. * @returns a number representing the framerate
  88250. */
  88251. getFps(): number;
  88252. /**
  88253. * Gets the time spent between current and previous frame
  88254. * @returns a number representing the delta time in ms
  88255. */
  88256. getDeltaTime(): number;
  88257. private _measureFps;
  88258. /** @hidden */
  88259. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  88260. private _canRenderToFloatFramebuffer;
  88261. private _canRenderToHalfFloatFramebuffer;
  88262. private _canRenderToFramebuffer;
  88263. /** @hidden */
  88264. _getWebGLTextureType(type: number): number;
  88265. private _getInternalFormat;
  88266. /** @hidden */
  88267. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  88268. /** @hidden */
  88269. _getRGBAMultiSampleBufferFormat(type: number): number;
  88270. /** @hidden */
  88271. _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;
  88272. /** @hidden */
  88273. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  88274. private _partialLoadFile;
  88275. private _cascadeLoadFiles;
  88276. /**
  88277. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  88278. * @returns true if the engine can be created
  88279. * @ignorenaming
  88280. */
  88281. static isSupported(): boolean;
  88282. }
  88283. }
  88284. declare module BABYLON {
  88285. /**
  88286. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  88287. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  88288. */
  88289. export class EffectFallbacks {
  88290. private _defines;
  88291. private _currentRank;
  88292. private _maxRank;
  88293. private _mesh;
  88294. /**
  88295. * Removes the fallback from the bound mesh.
  88296. */
  88297. unBindMesh(): void;
  88298. /**
  88299. * Adds a fallback on the specified property.
  88300. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88301. * @param define The name of the define in the shader
  88302. */
  88303. addFallback(rank: number, define: string): void;
  88304. /**
  88305. * Sets the mesh to use CPU skinning when needing to fallback.
  88306. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88307. * @param mesh The mesh to use the fallbacks.
  88308. */
  88309. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  88310. /**
  88311. * Checks to see if more fallbacks are still availible.
  88312. */
  88313. readonly isMoreFallbacks: boolean;
  88314. /**
  88315. * Removes the defines that shoould be removed when falling back.
  88316. * @param currentDefines defines the current define statements for the shader.
  88317. * @param effect defines the current effect we try to compile
  88318. * @returns The resulting defines with defines of the current rank removed.
  88319. */
  88320. reduce(currentDefines: string, effect: Effect): string;
  88321. }
  88322. /**
  88323. * Options to be used when creating an effect.
  88324. */
  88325. export class EffectCreationOptions {
  88326. /**
  88327. * Atrributes that will be used in the shader.
  88328. */
  88329. attributes: string[];
  88330. /**
  88331. * Uniform varible names that will be set in the shader.
  88332. */
  88333. uniformsNames: string[];
  88334. /**
  88335. * Uniform buffer varible names that will be set in the shader.
  88336. */
  88337. uniformBuffersNames: string[];
  88338. /**
  88339. * Sampler texture variable names that will be set in the shader.
  88340. */
  88341. samplers: string[];
  88342. /**
  88343. * Define statements that will be set in the shader.
  88344. */
  88345. defines: any;
  88346. /**
  88347. * Possible fallbacks for this effect to improve performance when needed.
  88348. */
  88349. fallbacks: Nullable<EffectFallbacks>;
  88350. /**
  88351. * Callback that will be called when the shader is compiled.
  88352. */
  88353. onCompiled: Nullable<(effect: Effect) => void>;
  88354. /**
  88355. * Callback that will be called if an error occurs during shader compilation.
  88356. */
  88357. onError: Nullable<(effect: Effect, errors: string) => void>;
  88358. /**
  88359. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  88360. */
  88361. indexParameters: any;
  88362. /**
  88363. * Max number of lights that can be used in the shader.
  88364. */
  88365. maxSimultaneousLights: number;
  88366. /**
  88367. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  88368. */
  88369. transformFeedbackVaryings: Nullable<string[]>;
  88370. }
  88371. /**
  88372. * Effect containing vertex and fragment shader that can be executed on an object.
  88373. */
  88374. export class Effect {
  88375. /**
  88376. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  88377. */
  88378. static ShadersRepository: string;
  88379. /**
  88380. * Name of the effect.
  88381. */
  88382. name: any;
  88383. /**
  88384. * String container all the define statements that should be set on the shader.
  88385. */
  88386. defines: string;
  88387. /**
  88388. * Callback that will be called when the shader is compiled.
  88389. */
  88390. onCompiled: Nullable<(effect: Effect) => void>;
  88391. /**
  88392. * Callback that will be called if an error occurs during shader compilation.
  88393. */
  88394. onError: Nullable<(effect: Effect, errors: string) => void>;
  88395. /**
  88396. * Callback that will be called when effect is bound.
  88397. */
  88398. onBind: Nullable<(effect: Effect) => void>;
  88399. /**
  88400. * Unique ID of the effect.
  88401. */
  88402. uniqueId: number;
  88403. /**
  88404. * Observable that will be called when the shader is compiled.
  88405. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  88406. */
  88407. onCompileObservable: Observable<Effect>;
  88408. /**
  88409. * Observable that will be called if an error occurs during shader compilation.
  88410. */
  88411. onErrorObservable: Observable<Effect>;
  88412. /** @hidden */
  88413. _onBindObservable: Nullable<Observable<Effect>>;
  88414. /**
  88415. * Observable that will be called when effect is bound.
  88416. */
  88417. readonly onBindObservable: Observable<Effect>;
  88418. /** @hidden */
  88419. _bonesComputationForcedToCPU: boolean;
  88420. private static _uniqueIdSeed;
  88421. private _engine;
  88422. private _uniformBuffersNames;
  88423. private _uniformsNames;
  88424. private _samplerList;
  88425. private _samplers;
  88426. private _isReady;
  88427. private _compilationError;
  88428. private _attributesNames;
  88429. private _attributes;
  88430. private _uniforms;
  88431. /**
  88432. * Key for the effect.
  88433. * @hidden
  88434. */
  88435. _key: string;
  88436. private _indexParameters;
  88437. private _fallbacks;
  88438. private _vertexSourceCode;
  88439. private _fragmentSourceCode;
  88440. private _vertexSourceCodeOverride;
  88441. private _fragmentSourceCodeOverride;
  88442. private _transformFeedbackVaryings;
  88443. /**
  88444. * Compiled shader to webGL program.
  88445. * @hidden
  88446. */
  88447. _program: WebGLProgram;
  88448. private _valueCache;
  88449. private static _baseCache;
  88450. /**
  88451. * Instantiates an effect.
  88452. * An effect can be used to create/manage/execute vertex and fragment shaders.
  88453. * @param baseName Name of the effect.
  88454. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  88455. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  88456. * @param samplers List of sampler variables that will be passed to the shader.
  88457. * @param engine Engine to be used to render the effect
  88458. * @param defines Define statements to be added to the shader.
  88459. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  88460. * @param onCompiled Callback that will be called when the shader is compiled.
  88461. * @param onError Callback that will be called if an error occurs during shader compilation.
  88462. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  88463. */
  88464. 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);
  88465. /**
  88466. * Unique key for this effect
  88467. */
  88468. readonly key: string;
  88469. /**
  88470. * If the effect has been compiled and prepared.
  88471. * @returns if the effect is compiled and prepared.
  88472. */
  88473. isReady(): boolean;
  88474. /**
  88475. * The engine the effect was initialized with.
  88476. * @returns the engine.
  88477. */
  88478. getEngine(): Engine;
  88479. /**
  88480. * The compiled webGL program for the effect
  88481. * @returns the webGL program.
  88482. */
  88483. getProgram(): WebGLProgram;
  88484. /**
  88485. * The set of names of attribute variables for the shader.
  88486. * @returns An array of attribute names.
  88487. */
  88488. getAttributesNames(): string[];
  88489. /**
  88490. * Returns the attribute at the given index.
  88491. * @param index The index of the attribute.
  88492. * @returns The location of the attribute.
  88493. */
  88494. getAttributeLocation(index: number): number;
  88495. /**
  88496. * Returns the attribute based on the name of the variable.
  88497. * @param name of the attribute to look up.
  88498. * @returns the attribute location.
  88499. */
  88500. getAttributeLocationByName(name: string): number;
  88501. /**
  88502. * The number of attributes.
  88503. * @returns the numnber of attributes.
  88504. */
  88505. getAttributesCount(): number;
  88506. /**
  88507. * Gets the index of a uniform variable.
  88508. * @param uniformName of the uniform to look up.
  88509. * @returns the index.
  88510. */
  88511. getUniformIndex(uniformName: string): number;
  88512. /**
  88513. * Returns the attribute based on the name of the variable.
  88514. * @param uniformName of the uniform to look up.
  88515. * @returns the location of the uniform.
  88516. */
  88517. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  88518. /**
  88519. * Returns an array of sampler variable names
  88520. * @returns The array of sampler variable neames.
  88521. */
  88522. getSamplers(): string[];
  88523. /**
  88524. * The error from the last compilation.
  88525. * @returns the error string.
  88526. */
  88527. getCompilationError(): string;
  88528. /**
  88529. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  88530. * @param func The callback to be used.
  88531. */
  88532. executeWhenCompiled(func: (effect: Effect) => void): void;
  88533. private _checkIsReady;
  88534. /** @hidden */
  88535. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  88536. /** @hidden */
  88537. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  88538. /** @hidden */
  88539. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  88540. private _processShaderConversion;
  88541. private _processIncludes;
  88542. private _processPrecision;
  88543. /**
  88544. * Recompiles the webGL program
  88545. * @param vertexSourceCode The source code for the vertex shader.
  88546. * @param fragmentSourceCode The source code for the fragment shader.
  88547. * @param onCompiled Callback called when completed.
  88548. * @param onError Callback called on error.
  88549. * @hidden
  88550. */
  88551. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  88552. /**
  88553. * Gets the uniform locations of the the specified variable names
  88554. * @param names THe names of the variables to lookup.
  88555. * @returns Array of locations in the same order as variable names.
  88556. */
  88557. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  88558. /**
  88559. * Prepares the effect
  88560. * @hidden
  88561. */
  88562. _prepareEffect(): void;
  88563. /**
  88564. * Checks if the effect is supported. (Must be called after compilation)
  88565. */
  88566. readonly isSupported: boolean;
  88567. /**
  88568. * Binds a texture to the engine to be used as output of the shader.
  88569. * @param channel Name of the output variable.
  88570. * @param texture Texture to bind.
  88571. * @hidden
  88572. */
  88573. _bindTexture(channel: string, texture: InternalTexture): void;
  88574. /**
  88575. * Sets a texture on the engine to be used in the shader.
  88576. * @param channel Name of the sampler variable.
  88577. * @param texture Texture to set.
  88578. */
  88579. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  88580. /**
  88581. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  88582. * @param channel Name of the sampler variable.
  88583. * @param texture Texture to set.
  88584. */
  88585. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  88586. /**
  88587. * Sets an array of textures on the engine to be used in the shader.
  88588. * @param channel Name of the variable.
  88589. * @param textures Textures to set.
  88590. */
  88591. setTextureArray(channel: string, textures: BaseTexture[]): void;
  88592. /**
  88593. * 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)
  88594. * @param channel Name of the sampler variable.
  88595. * @param postProcess Post process to get the input texture from.
  88596. */
  88597. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  88598. /**
  88599. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  88600. * 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)
  88601. * @param channel Name of the sampler variable.
  88602. * @param postProcess Post process to get the output texture from.
  88603. */
  88604. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  88605. /** @hidden */
  88606. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  88607. /** @hidden */
  88608. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  88609. /** @hidden */
  88610. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  88611. /** @hidden */
  88612. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  88613. /**
  88614. * Binds a buffer to a uniform.
  88615. * @param buffer Buffer to bind.
  88616. * @param name Name of the uniform variable to bind to.
  88617. */
  88618. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  88619. /**
  88620. * Binds block to a uniform.
  88621. * @param blockName Name of the block to bind.
  88622. * @param index Index to bind.
  88623. */
  88624. bindUniformBlock(blockName: string, index: number): void;
  88625. /**
  88626. * Sets an interger value on a uniform variable.
  88627. * @param uniformName Name of the variable.
  88628. * @param value Value to be set.
  88629. * @returns this effect.
  88630. */
  88631. setInt(uniformName: string, value: number): Effect;
  88632. /**
  88633. * Sets an int array on a uniform variable.
  88634. * @param uniformName Name of the variable.
  88635. * @param array array to be set.
  88636. * @returns this effect.
  88637. */
  88638. setIntArray(uniformName: string, array: Int32Array): Effect;
  88639. /**
  88640. * 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)
  88641. * @param uniformName Name of the variable.
  88642. * @param array array to be set.
  88643. * @returns this effect.
  88644. */
  88645. setIntArray2(uniformName: string, array: Int32Array): Effect;
  88646. /**
  88647. * 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)
  88648. * @param uniformName Name of the variable.
  88649. * @param array array to be set.
  88650. * @returns this effect.
  88651. */
  88652. setIntArray3(uniformName: string, array: Int32Array): Effect;
  88653. /**
  88654. * 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)
  88655. * @param uniformName Name of the variable.
  88656. * @param array array to be set.
  88657. * @returns this effect.
  88658. */
  88659. setIntArray4(uniformName: string, array: Int32Array): Effect;
  88660. /**
  88661. * Sets an float array on a uniform variable.
  88662. * @param uniformName Name of the variable.
  88663. * @param array array to be set.
  88664. * @returns this effect.
  88665. */
  88666. setFloatArray(uniformName: string, array: Float32Array): Effect;
  88667. /**
  88668. * 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)
  88669. * @param uniformName Name of the variable.
  88670. * @param array array to be set.
  88671. * @returns this effect.
  88672. */
  88673. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  88674. /**
  88675. * 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)
  88676. * @param uniformName Name of the variable.
  88677. * @param array array to be set.
  88678. * @returns this effect.
  88679. */
  88680. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  88681. /**
  88682. * 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)
  88683. * @param uniformName Name of the variable.
  88684. * @param array array to be set.
  88685. * @returns this effect.
  88686. */
  88687. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  88688. /**
  88689. * Sets an array on a uniform variable.
  88690. * @param uniformName Name of the variable.
  88691. * @param array array to be set.
  88692. * @returns this effect.
  88693. */
  88694. setArray(uniformName: string, array: number[]): Effect;
  88695. /**
  88696. * 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)
  88697. * @param uniformName Name of the variable.
  88698. * @param array array to be set.
  88699. * @returns this effect.
  88700. */
  88701. setArray2(uniformName: string, array: number[]): Effect;
  88702. /**
  88703. * 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)
  88704. * @param uniformName Name of the variable.
  88705. * @param array array to be set.
  88706. * @returns this effect.
  88707. */
  88708. setArray3(uniformName: string, array: number[]): Effect;
  88709. /**
  88710. * 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)
  88711. * @param uniformName Name of the variable.
  88712. * @param array array to be set.
  88713. * @returns this effect.
  88714. */
  88715. setArray4(uniformName: string, array: number[]): Effect;
  88716. /**
  88717. * Sets matrices on a uniform variable.
  88718. * @param uniformName Name of the variable.
  88719. * @param matrices matrices to be set.
  88720. * @returns this effect.
  88721. */
  88722. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  88723. /**
  88724. * Sets matrix on a uniform variable.
  88725. * @param uniformName Name of the variable.
  88726. * @param matrix matrix to be set.
  88727. * @returns this effect.
  88728. */
  88729. setMatrix(uniformName: string, matrix: Matrix): Effect;
  88730. /**
  88731. * 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)
  88732. * @param uniformName Name of the variable.
  88733. * @param matrix matrix to be set.
  88734. * @returns this effect.
  88735. */
  88736. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  88737. /**
  88738. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  88739. * @param uniformName Name of the variable.
  88740. * @param matrix matrix to be set.
  88741. * @returns this effect.
  88742. */
  88743. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  88744. /**
  88745. * Sets a float on a uniform variable.
  88746. * @param uniformName Name of the variable.
  88747. * @param value value to be set.
  88748. * @returns this effect.
  88749. */
  88750. setFloat(uniformName: string, value: number): Effect;
  88751. /**
  88752. * Sets a boolean on a uniform variable.
  88753. * @param uniformName Name of the variable.
  88754. * @param bool value to be set.
  88755. * @returns this effect.
  88756. */
  88757. setBool(uniformName: string, bool: boolean): Effect;
  88758. /**
  88759. * Sets a Vector2 on a uniform variable.
  88760. * @param uniformName Name of the variable.
  88761. * @param vector2 vector2 to be set.
  88762. * @returns this effect.
  88763. */
  88764. setVector2(uniformName: string, vector2: Vector2): Effect;
  88765. /**
  88766. * Sets a float2 on a uniform variable.
  88767. * @param uniformName Name of the variable.
  88768. * @param x First float in float2.
  88769. * @param y Second float in float2.
  88770. * @returns this effect.
  88771. */
  88772. setFloat2(uniformName: string, x: number, y: number): Effect;
  88773. /**
  88774. * Sets a Vector3 on a uniform variable.
  88775. * @param uniformName Name of the variable.
  88776. * @param vector3 Value to be set.
  88777. * @returns this effect.
  88778. */
  88779. setVector3(uniformName: string, vector3: Vector3): Effect;
  88780. /**
  88781. * Sets a float3 on a uniform variable.
  88782. * @param uniformName Name of the variable.
  88783. * @param x First float in float3.
  88784. * @param y Second float in float3.
  88785. * @param z Third float in float3.
  88786. * @returns this effect.
  88787. */
  88788. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  88789. /**
  88790. * Sets a Vector4 on a uniform variable.
  88791. * @param uniformName Name of the variable.
  88792. * @param vector4 Value to be set.
  88793. * @returns this effect.
  88794. */
  88795. setVector4(uniformName: string, vector4: Vector4): Effect;
  88796. /**
  88797. * Sets a float4 on a uniform variable.
  88798. * @param uniformName Name of the variable.
  88799. * @param x First float in float4.
  88800. * @param y Second float in float4.
  88801. * @param z Third float in float4.
  88802. * @param w Fourth float in float4.
  88803. * @returns this effect.
  88804. */
  88805. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  88806. /**
  88807. * Sets a Color3 on a uniform variable.
  88808. * @param uniformName Name of the variable.
  88809. * @param color3 Value to be set.
  88810. * @returns this effect.
  88811. */
  88812. setColor3(uniformName: string, color3: Color3): Effect;
  88813. /**
  88814. * Sets a Color4 on a uniform variable.
  88815. * @param uniformName Name of the variable.
  88816. * @param color3 Value to be set.
  88817. * @param alpha Alpha value to be set.
  88818. * @returns this effect.
  88819. */
  88820. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  88821. /**
  88822. * Sets a Color4 on a uniform variable
  88823. * @param uniformName defines the name of the variable
  88824. * @param color4 defines the value to be set
  88825. * @returns this effect.
  88826. */
  88827. setDirectColor4(uniformName: string, color4: Color4): Effect;
  88828. /**
  88829. * This function will add a new shader to the shader store
  88830. * @param name the name of the shader
  88831. * @param pixelShader optional pixel shader content
  88832. * @param vertexShader optional vertex shader content
  88833. */
  88834. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  88835. /**
  88836. * Store of each shader (The can be looked up using effect.key)
  88837. */
  88838. static ShadersStore: {
  88839. [key: string]: string;
  88840. };
  88841. /**
  88842. * Store of each included file for a shader (The can be looked up using effect.key)
  88843. */
  88844. static IncludesShadersStore: {
  88845. [key: string]: string;
  88846. };
  88847. /**
  88848. * Resets the cache of effects.
  88849. */
  88850. static ResetCache(): void;
  88851. }
  88852. }
  88853. declare module BABYLON {
  88854. /**
  88855. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  88856. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  88857. * 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;
  88858. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  88859. */
  88860. export class ColorCurves {
  88861. private _dirty;
  88862. private _tempColor;
  88863. private _globalCurve;
  88864. private _highlightsCurve;
  88865. private _midtonesCurve;
  88866. private _shadowsCurve;
  88867. private _positiveCurve;
  88868. private _negativeCurve;
  88869. private _globalHue;
  88870. private _globalDensity;
  88871. private _globalSaturation;
  88872. private _globalExposure;
  88873. /**
  88874. * Gets the global Hue value.
  88875. * 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).
  88876. */
  88877. /**
  88878. * Sets the global Hue value.
  88879. * 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).
  88880. */
  88881. globalHue: number;
  88882. /**
  88883. * Gets the global Density value.
  88884. * 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.
  88885. * Values less than zero provide a filter of opposite hue.
  88886. */
  88887. /**
  88888. * Sets the global Density value.
  88889. * 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.
  88890. * Values less than zero provide a filter of opposite hue.
  88891. */
  88892. globalDensity: number;
  88893. /**
  88894. * Gets the global Saturation value.
  88895. * 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.
  88896. */
  88897. /**
  88898. * Sets the global Saturation value.
  88899. * 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.
  88900. */
  88901. globalSaturation: number;
  88902. /**
  88903. * Gets the global Exposure value.
  88904. * 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.
  88905. */
  88906. /**
  88907. * Sets the global Exposure value.
  88908. * 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.
  88909. */
  88910. globalExposure: number;
  88911. private _highlightsHue;
  88912. private _highlightsDensity;
  88913. private _highlightsSaturation;
  88914. private _highlightsExposure;
  88915. /**
  88916. * Gets the highlights Hue value.
  88917. * 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).
  88918. */
  88919. /**
  88920. * Sets the highlights Hue value.
  88921. * 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).
  88922. */
  88923. highlightsHue: number;
  88924. /**
  88925. * Gets the highlights Density value.
  88926. * 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.
  88927. * Values less than zero provide a filter of opposite hue.
  88928. */
  88929. /**
  88930. * Sets the highlights Density value.
  88931. * 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.
  88932. * Values less than zero provide a filter of opposite hue.
  88933. */
  88934. highlightsDensity: number;
  88935. /**
  88936. * Gets the highlights Saturation value.
  88937. * 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.
  88938. */
  88939. /**
  88940. * Sets the highlights Saturation value.
  88941. * 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.
  88942. */
  88943. highlightsSaturation: number;
  88944. /**
  88945. * Gets the highlights Exposure value.
  88946. * 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.
  88947. */
  88948. /**
  88949. * Sets the highlights Exposure value.
  88950. * 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.
  88951. */
  88952. highlightsExposure: number;
  88953. private _midtonesHue;
  88954. private _midtonesDensity;
  88955. private _midtonesSaturation;
  88956. private _midtonesExposure;
  88957. /**
  88958. * Gets the midtones Hue value.
  88959. * 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).
  88960. */
  88961. /**
  88962. * Sets the midtones Hue value.
  88963. * 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).
  88964. */
  88965. midtonesHue: number;
  88966. /**
  88967. * Gets the midtones Density value.
  88968. * 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.
  88969. * Values less than zero provide a filter of opposite hue.
  88970. */
  88971. /**
  88972. * Sets the midtones Density value.
  88973. * 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.
  88974. * Values less than zero provide a filter of opposite hue.
  88975. */
  88976. midtonesDensity: number;
  88977. /**
  88978. * Gets the midtones Saturation value.
  88979. * 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.
  88980. */
  88981. /**
  88982. * Sets the midtones Saturation value.
  88983. * 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.
  88984. */
  88985. midtonesSaturation: number;
  88986. /**
  88987. * Gets the midtones Exposure value.
  88988. * 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.
  88989. */
  88990. /**
  88991. * Sets the midtones Exposure value.
  88992. * 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.
  88993. */
  88994. midtonesExposure: number;
  88995. private _shadowsHue;
  88996. private _shadowsDensity;
  88997. private _shadowsSaturation;
  88998. private _shadowsExposure;
  88999. /**
  89000. * Gets the shadows Hue value.
  89001. * 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).
  89002. */
  89003. /**
  89004. * Sets the shadows Hue value.
  89005. * 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).
  89006. */
  89007. shadowsHue: number;
  89008. /**
  89009. * Gets the shadows Density value.
  89010. * 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.
  89011. * Values less than zero provide a filter of opposite hue.
  89012. */
  89013. /**
  89014. * Sets the shadows Density value.
  89015. * 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.
  89016. * Values less than zero provide a filter of opposite hue.
  89017. */
  89018. shadowsDensity: number;
  89019. /**
  89020. * Gets the shadows Saturation value.
  89021. * 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.
  89022. */
  89023. /**
  89024. * Sets the shadows Saturation value.
  89025. * 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.
  89026. */
  89027. shadowsSaturation: number;
  89028. /**
  89029. * Gets the shadows Exposure value.
  89030. * 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.
  89031. */
  89032. /**
  89033. * Sets the shadows Exposure value.
  89034. * 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.
  89035. */
  89036. shadowsExposure: number;
  89037. /**
  89038. * Returns the class name
  89039. * @returns The class name
  89040. */
  89041. getClassName(): string;
  89042. /**
  89043. * Binds the color curves to the shader.
  89044. * @param colorCurves The color curve to bind
  89045. * @param effect The effect to bind to
  89046. * @param positiveUniform The positive uniform shader parameter
  89047. * @param neutralUniform The neutral uniform shader parameter
  89048. * @param negativeUniform The negative uniform shader parameter
  89049. */
  89050. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  89051. /**
  89052. * Prepare the list of uniforms associated with the ColorCurves effects.
  89053. * @param uniformsList The list of uniforms used in the effect
  89054. */
  89055. static PrepareUniforms(uniformsList: string[]): void;
  89056. /**
  89057. * Returns color grading data based on a hue, density, saturation and exposure value.
  89058. * @param filterHue The hue of the color filter.
  89059. * @param filterDensity The density of the color filter.
  89060. * @param saturation The saturation.
  89061. * @param exposure The exposure.
  89062. * @param result The result data container.
  89063. */
  89064. private getColorGradingDataToRef;
  89065. /**
  89066. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  89067. * @param value The input slider value in range [-100,100].
  89068. * @returns Adjusted value.
  89069. */
  89070. private static applyColorGradingSliderNonlinear;
  89071. /**
  89072. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  89073. * @param hue The hue (H) input.
  89074. * @param saturation The saturation (S) input.
  89075. * @param brightness The brightness (B) input.
  89076. * @result An RGBA color represented as Vector4.
  89077. */
  89078. private static fromHSBToRef;
  89079. /**
  89080. * Returns a value clamped between min and max
  89081. * @param value The value to clamp
  89082. * @param min The minimum of value
  89083. * @param max The maximum of value
  89084. * @returns The clamped value.
  89085. */
  89086. private static clamp;
  89087. /**
  89088. * Clones the current color curve instance.
  89089. * @return The cloned curves
  89090. */
  89091. clone(): ColorCurves;
  89092. /**
  89093. * Serializes the current color curve instance to a json representation.
  89094. * @return a JSON representation
  89095. */
  89096. serialize(): any;
  89097. /**
  89098. * Parses the color curve from a json representation.
  89099. * @param source the JSON source to parse
  89100. * @return The parsed curves
  89101. */
  89102. static Parse(source: any): ColorCurves;
  89103. }
  89104. }
  89105. declare module BABYLON {
  89106. /**
  89107. * Interface to follow in your material defines to integrate easily the
  89108. * Image proccessing functions.
  89109. * @hidden
  89110. */
  89111. export interface IImageProcessingConfigurationDefines {
  89112. IMAGEPROCESSING: boolean;
  89113. VIGNETTE: boolean;
  89114. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89115. VIGNETTEBLENDMODEOPAQUE: boolean;
  89116. TONEMAPPING: boolean;
  89117. TONEMAPPING_ACES: boolean;
  89118. CONTRAST: boolean;
  89119. EXPOSURE: boolean;
  89120. COLORCURVES: boolean;
  89121. COLORGRADING: boolean;
  89122. COLORGRADING3D: boolean;
  89123. SAMPLER3DGREENDEPTH: boolean;
  89124. SAMPLER3DBGRMAP: boolean;
  89125. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89126. }
  89127. /**
  89128. * @hidden
  89129. */
  89130. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  89131. IMAGEPROCESSING: boolean;
  89132. VIGNETTE: boolean;
  89133. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89134. VIGNETTEBLENDMODEOPAQUE: boolean;
  89135. TONEMAPPING: boolean;
  89136. TONEMAPPING_ACES: boolean;
  89137. CONTRAST: boolean;
  89138. COLORCURVES: boolean;
  89139. COLORGRADING: boolean;
  89140. COLORGRADING3D: boolean;
  89141. SAMPLER3DGREENDEPTH: boolean;
  89142. SAMPLER3DBGRMAP: boolean;
  89143. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89144. EXPOSURE: boolean;
  89145. constructor();
  89146. }
  89147. /**
  89148. * This groups together the common properties used for image processing either in direct forward pass
  89149. * or through post processing effect depending on the use of the image processing pipeline in your scene
  89150. * or not.
  89151. */
  89152. export class ImageProcessingConfiguration {
  89153. /**
  89154. * Default tone mapping applied in BabylonJS.
  89155. */
  89156. static readonly TONEMAPPING_STANDARD: number;
  89157. /**
  89158. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  89159. * to other engines rendering to increase portability.
  89160. */
  89161. static readonly TONEMAPPING_ACES: number;
  89162. /**
  89163. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  89164. */
  89165. colorCurves: Nullable<ColorCurves>;
  89166. private _colorCurvesEnabled;
  89167. /**
  89168. * Gets wether the color curves effect is enabled.
  89169. */
  89170. /**
  89171. * Sets wether the color curves effect is enabled.
  89172. */
  89173. colorCurvesEnabled: boolean;
  89174. private _colorGradingTexture;
  89175. /**
  89176. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89177. */
  89178. /**
  89179. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89180. */
  89181. colorGradingTexture: Nullable<BaseTexture>;
  89182. private _colorGradingEnabled;
  89183. /**
  89184. * Gets wether the color grading effect is enabled.
  89185. */
  89186. /**
  89187. * Sets wether the color grading effect is enabled.
  89188. */
  89189. colorGradingEnabled: boolean;
  89190. private _colorGradingWithGreenDepth;
  89191. /**
  89192. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  89193. */
  89194. /**
  89195. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  89196. */
  89197. colorGradingWithGreenDepth: boolean;
  89198. private _colorGradingBGR;
  89199. /**
  89200. * Gets wether the color grading texture contains BGR values.
  89201. */
  89202. /**
  89203. * Sets wether the color grading texture contains BGR values.
  89204. */
  89205. colorGradingBGR: boolean;
  89206. /** @hidden */
  89207. _exposure: number;
  89208. /**
  89209. * Gets the Exposure used in the effect.
  89210. */
  89211. /**
  89212. * Sets the Exposure used in the effect.
  89213. */
  89214. exposure: number;
  89215. private _toneMappingEnabled;
  89216. /**
  89217. * Gets wether the tone mapping effect is enabled.
  89218. */
  89219. /**
  89220. * Sets wether the tone mapping effect is enabled.
  89221. */
  89222. toneMappingEnabled: boolean;
  89223. private _toneMappingType;
  89224. /**
  89225. * Gets the type of tone mapping effect.
  89226. */
  89227. /**
  89228. * Sets the type of tone mapping effect used in BabylonJS.
  89229. */
  89230. toneMappingType: number;
  89231. protected _contrast: number;
  89232. /**
  89233. * Gets the contrast used in the effect.
  89234. */
  89235. /**
  89236. * Sets the contrast used in the effect.
  89237. */
  89238. contrast: number;
  89239. /**
  89240. * Vignette stretch size.
  89241. */
  89242. vignetteStretch: number;
  89243. /**
  89244. * Vignette centre X Offset.
  89245. */
  89246. vignetteCentreX: number;
  89247. /**
  89248. * Vignette centre Y Offset.
  89249. */
  89250. vignetteCentreY: number;
  89251. /**
  89252. * Vignette weight or intensity of the vignette effect.
  89253. */
  89254. vignetteWeight: number;
  89255. /**
  89256. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  89257. * if vignetteEnabled is set to true.
  89258. */
  89259. vignetteColor: Color4;
  89260. /**
  89261. * Camera field of view used by the Vignette effect.
  89262. */
  89263. vignetteCameraFov: number;
  89264. private _vignetteBlendMode;
  89265. /**
  89266. * Gets the vignette blend mode allowing different kind of effect.
  89267. */
  89268. /**
  89269. * Sets the vignette blend mode allowing different kind of effect.
  89270. */
  89271. vignetteBlendMode: number;
  89272. private _vignetteEnabled;
  89273. /**
  89274. * Gets wether the vignette effect is enabled.
  89275. */
  89276. /**
  89277. * Sets wether the vignette effect is enabled.
  89278. */
  89279. vignetteEnabled: boolean;
  89280. private _applyByPostProcess;
  89281. /**
  89282. * Gets wether the image processing is applied through a post process or not.
  89283. */
  89284. /**
  89285. * Sets wether the image processing is applied through a post process or not.
  89286. */
  89287. applyByPostProcess: boolean;
  89288. private _isEnabled;
  89289. /**
  89290. * Gets wether the image processing is enabled or not.
  89291. */
  89292. /**
  89293. * Sets wether the image processing is enabled or not.
  89294. */
  89295. isEnabled: boolean;
  89296. /**
  89297. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  89298. */
  89299. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  89300. /**
  89301. * Method called each time the image processing information changes requires to recompile the effect.
  89302. */
  89303. protected _updateParameters(): void;
  89304. /**
  89305. * Gets the current class name.
  89306. * @return "ImageProcessingConfiguration"
  89307. */
  89308. getClassName(): string;
  89309. /**
  89310. * Prepare the list of uniforms associated with the Image Processing effects.
  89311. * @param uniforms The list of uniforms used in the effect
  89312. * @param defines the list of defines currently in use
  89313. */
  89314. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  89315. /**
  89316. * Prepare the list of samplers associated with the Image Processing effects.
  89317. * @param samplersList The list of uniforms used in the effect
  89318. * @param defines the list of defines currently in use
  89319. */
  89320. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  89321. /**
  89322. * Prepare the list of defines associated to the shader.
  89323. * @param defines the list of defines to complete
  89324. * @param forPostProcess Define if we are currently in post process mode or not
  89325. */
  89326. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  89327. /**
  89328. * Returns true if all the image processing information are ready.
  89329. * @returns True if ready, otherwise, false
  89330. */
  89331. isReady(): boolean;
  89332. /**
  89333. * Binds the image processing to the shader.
  89334. * @param effect The effect to bind to
  89335. * @param aspectRatio Define the current aspect ratio of the effect
  89336. */
  89337. bind(effect: Effect, aspectRatio?: number): void;
  89338. /**
  89339. * Clones the current image processing instance.
  89340. * @return The cloned image processing
  89341. */
  89342. clone(): ImageProcessingConfiguration;
  89343. /**
  89344. * Serializes the current image processing instance to a json representation.
  89345. * @return a JSON representation
  89346. */
  89347. serialize(): any;
  89348. /**
  89349. * Parses the image processing from a json representation.
  89350. * @param source the JSON source to parse
  89351. * @return The parsed image processing
  89352. */
  89353. static Parse(source: any): ImageProcessingConfiguration;
  89354. private static _VIGNETTEMODE_MULTIPLY;
  89355. private static _VIGNETTEMODE_OPAQUE;
  89356. /**
  89357. * Used to apply the vignette as a mix with the pixel color.
  89358. */
  89359. static readonly VIGNETTEMODE_MULTIPLY: number;
  89360. /**
  89361. * Used to apply the vignette as a replacement of the pixel color.
  89362. */
  89363. static readonly VIGNETTEMODE_OPAQUE: number;
  89364. }
  89365. }
  89366. declare module BABYLON {
  89367. /**
  89368. * This represents all the required information to add a fresnel effect on a material:
  89369. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  89370. */
  89371. export class FresnelParameters {
  89372. private _isEnabled;
  89373. /**
  89374. * Define if the fresnel effect is enable or not.
  89375. */
  89376. isEnabled: boolean;
  89377. /**
  89378. * Define the color used on edges (grazing angle)
  89379. */
  89380. leftColor: Color3;
  89381. /**
  89382. * Define the color used on center
  89383. */
  89384. rightColor: Color3;
  89385. /**
  89386. * Define bias applied to computed fresnel term
  89387. */
  89388. bias: number;
  89389. /**
  89390. * Defined the power exponent applied to fresnel term
  89391. */
  89392. power: number;
  89393. /**
  89394. * Clones the current fresnel and its valuues
  89395. * @returns a clone fresnel configuration
  89396. */
  89397. clone(): FresnelParameters;
  89398. /**
  89399. * Serializes the current fresnel parameters to a JSON representation.
  89400. * @return the JSON serialization
  89401. */
  89402. serialize(): any;
  89403. /**
  89404. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  89405. * @param parsedFresnelParameters Define the JSON representation
  89406. * @returns the parsed parameters
  89407. */
  89408. static Parse(parsedFresnelParameters: any): FresnelParameters;
  89409. }
  89410. }
  89411. declare module BABYLON {
  89412. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  89413. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89414. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89415. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89416. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89417. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89418. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89419. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89420. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89421. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89422. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89423. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89424. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89425. /**
  89426. * Decorator used to define property that can be serialized as reference to a camera
  89427. * @param sourceName defines the name of the property to decorate
  89428. */
  89429. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89430. /**
  89431. * Class used to help serialization objects
  89432. */
  89433. export class SerializationHelper {
  89434. /** hidden */
  89435. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  89436. /** hidden */
  89437. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  89438. /** hidden */
  89439. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  89440. /** hidden */
  89441. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  89442. /**
  89443. * Appends the serialized animations from the source animations
  89444. * @param source Source containing the animations
  89445. * @param destination Target to store the animations
  89446. */
  89447. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  89448. /**
  89449. * Static function used to serialized a specific entity
  89450. * @param entity defines the entity to serialize
  89451. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  89452. * @returns a JSON compatible object representing the serialization of the entity
  89453. */
  89454. static Serialize<T>(entity: T, serializationObject?: any): any;
  89455. /**
  89456. * Creates a new entity from a serialization data object
  89457. * @param creationFunction defines a function used to instanciated the new entity
  89458. * @param source defines the source serialization data
  89459. * @param scene defines the hosting scene
  89460. * @param rootUrl defines the root url for resources
  89461. * @returns a new entity
  89462. */
  89463. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  89464. /**
  89465. * Clones an object
  89466. * @param creationFunction defines the function used to instanciate the new object
  89467. * @param source defines the source object
  89468. * @returns the cloned object
  89469. */
  89470. static Clone<T>(creationFunction: () => T, source: T): T;
  89471. /**
  89472. * Instanciates a new object based on a source one (some data will be shared between both object)
  89473. * @param creationFunction defines the function used to instanciate the new object
  89474. * @param source defines the source object
  89475. * @returns the new object
  89476. */
  89477. static Instanciate<T>(creationFunction: () => T, source: T): T;
  89478. }
  89479. }
  89480. declare module BABYLON {
  89481. /**
  89482. * This is the base class of all the camera used in the application.
  89483. * @see http://doc.babylonjs.com/features/cameras
  89484. */
  89485. export class Camera extends Node {
  89486. /** @hidden */
  89487. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  89488. /**
  89489. * This is the default projection mode used by the cameras.
  89490. * It helps recreating a feeling of perspective and better appreciate depth.
  89491. * This is the best way to simulate real life cameras.
  89492. */
  89493. static readonly PERSPECTIVE_CAMERA: number;
  89494. /**
  89495. * This helps creating camera with an orthographic mode.
  89496. * 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.
  89497. */
  89498. static readonly ORTHOGRAPHIC_CAMERA: number;
  89499. /**
  89500. * This is the default FOV mode for perspective cameras.
  89501. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  89502. */
  89503. static readonly FOVMODE_VERTICAL_FIXED: number;
  89504. /**
  89505. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  89506. */
  89507. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  89508. /**
  89509. * This specifies ther is no need for a camera rig.
  89510. * Basically only one eye is rendered corresponding to the camera.
  89511. */
  89512. static readonly RIG_MODE_NONE: number;
  89513. /**
  89514. * Simulates a camera Rig with one blue eye and one red eye.
  89515. * This can be use with 3d blue and red glasses.
  89516. */
  89517. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  89518. /**
  89519. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  89520. */
  89521. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  89522. /**
  89523. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  89524. */
  89525. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  89526. /**
  89527. * Defines that both eyes of the camera will be rendered over under each other.
  89528. */
  89529. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  89530. /**
  89531. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  89532. */
  89533. static readonly RIG_MODE_VR: number;
  89534. /**
  89535. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  89536. */
  89537. static readonly RIG_MODE_WEBVR: number;
  89538. /**
  89539. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  89540. */
  89541. static readonly RIG_MODE_CUSTOM: number;
  89542. /**
  89543. * Defines if by default attaching controls should prevent the default javascript event to continue.
  89544. */
  89545. static ForceAttachControlToAlwaysPreventDefault: boolean;
  89546. /**
  89547. * Define the input manager associated with the camera.
  89548. */
  89549. inputs: CameraInputsManager<Camera>;
  89550. /** @hidden */
  89551. _position: Vector3;
  89552. /**
  89553. * Define the current local position of the camera in the scene
  89554. */
  89555. position: Vector3;
  89556. /**
  89557. * The vector the camera should consider as up.
  89558. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  89559. */
  89560. upVector: Vector3;
  89561. /**
  89562. * Define the current limit on the left side for an orthographic camera
  89563. * In scene unit
  89564. */
  89565. orthoLeft: Nullable<number>;
  89566. /**
  89567. * Define the current limit on the right side for an orthographic camera
  89568. * In scene unit
  89569. */
  89570. orthoRight: Nullable<number>;
  89571. /**
  89572. * Define the current limit on the bottom side for an orthographic camera
  89573. * In scene unit
  89574. */
  89575. orthoBottom: Nullable<number>;
  89576. /**
  89577. * Define the current limit on the top side for an orthographic camera
  89578. * In scene unit
  89579. */
  89580. orthoTop: Nullable<number>;
  89581. /**
  89582. * Field Of View is set in Radians. (default is 0.8)
  89583. */
  89584. fov: number;
  89585. /**
  89586. * Define the minimum distance the camera can see from.
  89587. * This is important to note that the depth buffer are not infinite and the closer it starts
  89588. * the more your scene might encounter depth fighting issue.
  89589. */
  89590. minZ: number;
  89591. /**
  89592. * Define the maximum distance the camera can see to.
  89593. * This is important to note that the depth buffer are not infinite and the further it end
  89594. * the more your scene might encounter depth fighting issue.
  89595. */
  89596. maxZ: number;
  89597. /**
  89598. * Define the default inertia of the camera.
  89599. * This helps giving a smooth feeling to the camera movement.
  89600. */
  89601. inertia: number;
  89602. /**
  89603. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  89604. */
  89605. mode: number;
  89606. /**
  89607. * Define wether the camera is intermediate.
  89608. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  89609. */
  89610. isIntermediate: boolean;
  89611. /**
  89612. * Define the viewport of the camera.
  89613. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  89614. */
  89615. viewport: Viewport;
  89616. /**
  89617. * Restricts the camera to viewing objects with the same layerMask.
  89618. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  89619. */
  89620. layerMask: number;
  89621. /**
  89622. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  89623. */
  89624. fovMode: number;
  89625. /**
  89626. * Rig mode of the camera.
  89627. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  89628. * This is normally controlled byt the camera themselves as internal use.
  89629. */
  89630. cameraRigMode: number;
  89631. /**
  89632. * Defines the distance between both "eyes" in case of a RIG
  89633. */
  89634. interaxialDistance: number;
  89635. /**
  89636. * Defines if stereoscopic rendering is done side by side or over under.
  89637. */
  89638. isStereoscopicSideBySide: boolean;
  89639. /**
  89640. * 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
  89641. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  89642. * else in the scene.
  89643. */
  89644. customRenderTargets: RenderTargetTexture[];
  89645. /**
  89646. * When set, the camera will render to this render target instead of the default canvas
  89647. */
  89648. outputRenderTarget: Nullable<RenderTargetTexture>;
  89649. /**
  89650. * Observable triggered when the camera view matrix has changed.
  89651. */
  89652. onViewMatrixChangedObservable: Observable<Camera>;
  89653. /**
  89654. * Observable triggered when the camera Projection matrix has changed.
  89655. */
  89656. onProjectionMatrixChangedObservable: Observable<Camera>;
  89657. /**
  89658. * Observable triggered when the inputs have been processed.
  89659. */
  89660. onAfterCheckInputsObservable: Observable<Camera>;
  89661. /**
  89662. * Observable triggered when reset has been called and applied to the camera.
  89663. */
  89664. onRestoreStateObservable: Observable<Camera>;
  89665. /** @hidden */
  89666. _cameraRigParams: any;
  89667. /** @hidden */
  89668. _rigCameras: Camera[];
  89669. /** @hidden */
  89670. _rigPostProcess: Nullable<PostProcess>;
  89671. protected _webvrViewMatrix: Matrix;
  89672. /** @hidden */
  89673. _skipRendering: boolean;
  89674. /** @hidden */
  89675. _projectionMatrix: Matrix;
  89676. /** @hidden */
  89677. _postProcesses: Nullable<PostProcess>[];
  89678. /** @hidden */
  89679. _activeMeshes: SmartArray<AbstractMesh>;
  89680. protected _globalPosition: Vector3;
  89681. /** hidden */
  89682. _computedViewMatrix: Matrix;
  89683. private _doNotComputeProjectionMatrix;
  89684. private _transformMatrix;
  89685. private _frustumPlanes;
  89686. private _refreshFrustumPlanes;
  89687. private _storedFov;
  89688. private _stateStored;
  89689. /**
  89690. * Instantiates a new camera object.
  89691. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  89692. * @see http://doc.babylonjs.com/features/cameras
  89693. * @param name Defines the name of the camera in the scene
  89694. * @param position Defines the position of the camera
  89695. * @param scene Defines the scene the camera belongs too
  89696. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  89697. */
  89698. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  89699. /**
  89700. * Store current camera state (fov, position, etc..)
  89701. * @returns the camera
  89702. */
  89703. storeState(): Camera;
  89704. /**
  89705. * Restores the camera state values if it has been stored. You must call storeState() first
  89706. */
  89707. protected _restoreStateValues(): boolean;
  89708. /**
  89709. * Restored camera state. You must call storeState() first.
  89710. * @returns true if restored and false otherwise
  89711. */
  89712. restoreState(): boolean;
  89713. /**
  89714. * Gets the class name of the camera.
  89715. * @returns the class name
  89716. */
  89717. getClassName(): string;
  89718. /** @hidden */
  89719. readonly _isCamera: boolean;
  89720. /**
  89721. * Gets a string representation of the camera useful for debug purpose.
  89722. * @param fullDetails Defines that a more verboe level of logging is required
  89723. * @returns the string representation
  89724. */
  89725. toString(fullDetails?: boolean): string;
  89726. /**
  89727. * Gets the current world space position of the camera.
  89728. */
  89729. readonly globalPosition: Vector3;
  89730. /**
  89731. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  89732. * @returns the active meshe list
  89733. */
  89734. getActiveMeshes(): SmartArray<AbstractMesh>;
  89735. /**
  89736. * Check wether a mesh is part of the current active mesh list of the camera
  89737. * @param mesh Defines the mesh to check
  89738. * @returns true if active, false otherwise
  89739. */
  89740. isActiveMesh(mesh: Mesh): boolean;
  89741. /**
  89742. * Is this camera ready to be used/rendered
  89743. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  89744. * @return true if the camera is ready
  89745. */
  89746. isReady(completeCheck?: boolean): boolean;
  89747. /** @hidden */
  89748. _initCache(): void;
  89749. /** @hidden */
  89750. _updateCache(ignoreParentClass?: boolean): void;
  89751. /** @hidden */
  89752. _isSynchronized(): boolean;
  89753. /** @hidden */
  89754. _isSynchronizedViewMatrix(): boolean;
  89755. /** @hidden */
  89756. _isSynchronizedProjectionMatrix(): boolean;
  89757. /**
  89758. * Attach the input controls to a specific dom element to get the input from.
  89759. * @param element Defines the element the controls should be listened from
  89760. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  89761. */
  89762. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  89763. /**
  89764. * Detach the current controls from the specified dom element.
  89765. * @param element Defines the element to stop listening the inputs from
  89766. */
  89767. detachControl(element: HTMLElement): void;
  89768. /**
  89769. * Update the camera state according to the different inputs gathered during the frame.
  89770. */
  89771. update(): void;
  89772. /** @hidden */
  89773. _checkInputs(): void;
  89774. /** @hidden */
  89775. readonly rigCameras: Camera[];
  89776. /**
  89777. * Gets the post process used by the rig cameras
  89778. */
  89779. readonly rigPostProcess: Nullable<PostProcess>;
  89780. /**
  89781. * Internal, gets the first post proces.
  89782. * @returns the first post process to be run on this camera.
  89783. */
  89784. _getFirstPostProcess(): Nullable<PostProcess>;
  89785. private _cascadePostProcessesToRigCams;
  89786. /**
  89787. * Attach a post process to the camera.
  89788. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  89789. * @param postProcess The post process to attach to the camera
  89790. * @param insertAt The position of the post process in case several of them are in use in the scene
  89791. * @returns the position the post process has been inserted at
  89792. */
  89793. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  89794. /**
  89795. * Detach a post process to the camera.
  89796. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  89797. * @param postProcess The post process to detach from the camera
  89798. */
  89799. detachPostProcess(postProcess: PostProcess): void;
  89800. /**
  89801. * Gets the current world matrix of the camera
  89802. */
  89803. getWorldMatrix(): Matrix;
  89804. /** @hidden */
  89805. _getViewMatrix(): Matrix;
  89806. /**
  89807. * Gets the current view matrix of the camera.
  89808. * @param force forces the camera to recompute the matrix without looking at the cached state
  89809. * @returns the view matrix
  89810. */
  89811. getViewMatrix(force?: boolean): Matrix;
  89812. /**
  89813. * Freeze the projection matrix.
  89814. * It will prevent the cache check of the camera projection compute and can speed up perf
  89815. * if no parameter of the camera are meant to change
  89816. * @param projection Defines manually a projection if necessary
  89817. */
  89818. freezeProjectionMatrix(projection?: Matrix): void;
  89819. /**
  89820. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  89821. */
  89822. unfreezeProjectionMatrix(): void;
  89823. /**
  89824. * Gets the current projection matrix of the camera.
  89825. * @param force forces the camera to recompute the matrix without looking at the cached state
  89826. * @returns the projection matrix
  89827. */
  89828. getProjectionMatrix(force?: boolean): Matrix;
  89829. /**
  89830. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  89831. * @returns a Matrix
  89832. */
  89833. getTransformationMatrix(): Matrix;
  89834. private _updateFrustumPlanes;
  89835. /**
  89836. * Checks if a cullable object (mesh...) is in the camera frustum
  89837. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  89838. * @param target The object to check
  89839. * @returns true if the object is in frustum otherwise false
  89840. */
  89841. isInFrustum(target: ICullable): boolean;
  89842. /**
  89843. * Checks if a cullable object (mesh...) is in the camera frustum
  89844. * Unlike isInFrustum this cheks the full bounding box
  89845. * @param target The object to check
  89846. * @returns true if the object is in frustum otherwise false
  89847. */
  89848. isCompletelyInFrustum(target: ICullable): boolean;
  89849. /**
  89850. * Gets a ray in the forward direction from the camera.
  89851. * @param length Defines the length of the ray to create
  89852. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  89853. * @param origin Defines the start point of the ray which defaults to the camera position
  89854. * @returns the forward ray
  89855. */
  89856. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  89857. /**
  89858. * Releases resources associated with this node.
  89859. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  89860. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  89861. */
  89862. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89863. /** @hidden */
  89864. _isLeftCamera: boolean;
  89865. /**
  89866. * Gets the left camera of a rig setup in case of Rigged Camera
  89867. */
  89868. readonly isLeftCamera: boolean;
  89869. /** @hidden */
  89870. _isRightCamera: boolean;
  89871. /**
  89872. * Gets the right camera of a rig setup in case of Rigged Camera
  89873. */
  89874. readonly isRightCamera: boolean;
  89875. /**
  89876. * Gets the left camera of a rig setup in case of Rigged Camera
  89877. */
  89878. readonly leftCamera: Nullable<FreeCamera>;
  89879. /**
  89880. * Gets the right camera of a rig setup in case of Rigged Camera
  89881. */
  89882. readonly rightCamera: Nullable<FreeCamera>;
  89883. /**
  89884. * Gets the left camera target of a rig setup in case of Rigged Camera
  89885. * @returns the target position
  89886. */
  89887. getLeftTarget(): Nullable<Vector3>;
  89888. /**
  89889. * Gets the right camera target of a rig setup in case of Rigged Camera
  89890. * @returns the target position
  89891. */
  89892. getRightTarget(): Nullable<Vector3>;
  89893. /**
  89894. * @hidden
  89895. */
  89896. setCameraRigMode(mode: number, rigParams: any): void;
  89897. /** @hidden */
  89898. static _setStereoscopicRigMode(camera: Camera): void;
  89899. /** @hidden */
  89900. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  89901. /** @hidden */
  89902. static _setVRRigMode(camera: Camera, rigParams: any): void;
  89903. /** @hidden */
  89904. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  89905. /** @hidden */
  89906. _getVRProjectionMatrix(): Matrix;
  89907. protected _updateCameraRotationMatrix(): void;
  89908. protected _updateWebVRCameraRotationMatrix(): void;
  89909. /**
  89910. * This function MUST be overwritten by the different WebVR cameras available.
  89911. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  89912. * @hidden
  89913. */
  89914. _getWebVRProjectionMatrix(): Matrix;
  89915. /**
  89916. * This function MUST be overwritten by the different WebVR cameras available.
  89917. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  89918. * @hidden
  89919. */
  89920. _getWebVRViewMatrix(): Matrix;
  89921. /** @hidden */
  89922. setCameraRigParameter(name: string, value: any): void;
  89923. /**
  89924. * needs to be overridden by children so sub has required properties to be copied
  89925. * @hidden
  89926. */
  89927. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  89928. /**
  89929. * May need to be overridden by children
  89930. * @hidden
  89931. */
  89932. _updateRigCameras(): void;
  89933. /** @hidden */
  89934. _setupInputs(): void;
  89935. /**
  89936. * Serialiaze the camera setup to a json represention
  89937. * @returns the JSON representation
  89938. */
  89939. serialize(): any;
  89940. /**
  89941. * Clones the current camera.
  89942. * @param name The cloned camera name
  89943. * @returns the cloned camera
  89944. */
  89945. clone(name: string): Camera;
  89946. /**
  89947. * Gets the direction of the camera relative to a given local axis.
  89948. * @param localAxis Defines the reference axis to provide a relative direction.
  89949. * @return the direction
  89950. */
  89951. getDirection(localAxis: Vector3): Vector3;
  89952. /**
  89953. * Gets the direction of the camera relative to a given local axis into a passed vector.
  89954. * @param localAxis Defines the reference axis to provide a relative direction.
  89955. * @param result Defines the vector to store the result in
  89956. */
  89957. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  89958. /**
  89959. * Gets a camera constructor for a given camera type
  89960. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  89961. * @param name The name of the camera the result will be able to instantiate
  89962. * @param scene The scene the result will construct the camera in
  89963. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  89964. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  89965. * @returns a factory method to construc the camera
  89966. */
  89967. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  89968. /**
  89969. * Compute the world matrix of the camera.
  89970. * @returns the camera workd matrix
  89971. */
  89972. computeWorldMatrix(): Matrix;
  89973. /**
  89974. * Parse a JSON and creates the camera from the parsed information
  89975. * @param parsedCamera The JSON to parse
  89976. * @param scene The scene to instantiate the camera in
  89977. * @returns the newly constructed camera
  89978. */
  89979. static Parse(parsedCamera: any, scene: Scene): Camera;
  89980. }
  89981. }
  89982. declare module BABYLON {
  89983. /**
  89984. * Interface for any object that can request an animation frame
  89985. */
  89986. export interface ICustomAnimationFrameRequester {
  89987. /**
  89988. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  89989. */
  89990. renderFunction?: Function;
  89991. /**
  89992. * Called to request the next frame to render to
  89993. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  89994. */
  89995. requestAnimationFrame: Function;
  89996. /**
  89997. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  89998. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  89999. */
  90000. requestID?: number;
  90001. }
  90002. /**
  90003. * Interface containing an array of animations
  90004. */
  90005. export interface IAnimatable {
  90006. /**
  90007. * Array of animations
  90008. */
  90009. animations: Array<Animation>;
  90010. }
  90011. /** Interface used by value gradients (color, factor, ...) */
  90012. export interface IValueGradient {
  90013. /**
  90014. * Gets or sets the gradient value (between 0 and 1)
  90015. */
  90016. gradient: number;
  90017. }
  90018. /** Class used to store color4 gradient */
  90019. export class ColorGradient implements IValueGradient {
  90020. /**
  90021. * Gets or sets the gradient value (between 0 and 1)
  90022. */
  90023. gradient: number;
  90024. /**
  90025. * Gets or sets first associated color
  90026. */
  90027. color1: Color4;
  90028. /**
  90029. * Gets or sets second associated color
  90030. */
  90031. color2?: Color4;
  90032. /**
  90033. * Will get a color picked randomly between color1 and color2.
  90034. * If color2 is undefined then color1 will be used
  90035. * @param result defines the target Color4 to store the result in
  90036. */
  90037. getColorToRef(result: Color4): void;
  90038. }
  90039. /** Class used to store color 3 gradient */
  90040. export class Color3Gradient implements IValueGradient {
  90041. /**
  90042. * Gets or sets the gradient value (between 0 and 1)
  90043. */
  90044. gradient: number;
  90045. /**
  90046. * Gets or sets the associated color
  90047. */
  90048. color: Color3;
  90049. }
  90050. /** Class used to store factor gradient */
  90051. export class FactorGradient implements IValueGradient {
  90052. /**
  90053. * Gets or sets the gradient value (between 0 and 1)
  90054. */
  90055. gradient: number;
  90056. /**
  90057. * Gets or sets first associated factor
  90058. */
  90059. factor1: number;
  90060. /**
  90061. * Gets or sets second associated factor
  90062. */
  90063. factor2?: number;
  90064. /**
  90065. * Will get a number picked randomly between factor1 and factor2.
  90066. * If factor2 is undefined then factor1 will be used
  90067. * @returns the picked number
  90068. */
  90069. getFactor(): number;
  90070. }
  90071. /**
  90072. * @ignore
  90073. * Application error to support additional information when loading a file
  90074. */
  90075. export class LoadFileError extends Error {
  90076. /** defines the optional web request */
  90077. request?: WebRequest | undefined;
  90078. private static _setPrototypeOf;
  90079. /**
  90080. * Creates a new LoadFileError
  90081. * @param message defines the message of the error
  90082. * @param request defines the optional web request
  90083. */
  90084. constructor(message: string,
  90085. /** defines the optional web request */
  90086. request?: WebRequest | undefined);
  90087. }
  90088. /**
  90089. * Class used to define a retry strategy when error happens while loading assets
  90090. */
  90091. export class RetryStrategy {
  90092. /**
  90093. * Function used to defines an exponential back off strategy
  90094. * @param maxRetries defines the maximum number of retries (3 by default)
  90095. * @param baseInterval defines the interval between retries
  90096. * @returns the strategy function to use
  90097. */
  90098. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  90099. }
  90100. /**
  90101. * File request interface
  90102. */
  90103. export interface IFileRequest {
  90104. /**
  90105. * Raised when the request is complete (success or error).
  90106. */
  90107. onCompleteObservable: Observable<IFileRequest>;
  90108. /**
  90109. * Aborts the request for a file.
  90110. */
  90111. abort: () => void;
  90112. }
  90113. /**
  90114. * Class containing a set of static utilities functions
  90115. */
  90116. export class Tools {
  90117. /**
  90118. * Gets or sets the base URL to use to load assets
  90119. */
  90120. static BaseUrl: string;
  90121. /**
  90122. * Enable/Disable Custom HTTP Request Headers globally.
  90123. * default = false
  90124. * @see CustomRequestHeaders
  90125. */
  90126. static UseCustomRequestHeaders: boolean;
  90127. /**
  90128. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  90129. * i.e. when loading files, where the server/service expects an Authorization header
  90130. */
  90131. static CustomRequestHeaders: {
  90132. [key: string]: string;
  90133. };
  90134. /**
  90135. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  90136. */
  90137. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  90138. /**
  90139. * Default behaviour for cors in the application.
  90140. * It can be a string if the expected behavior is identical in the entire app.
  90141. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  90142. */
  90143. static CorsBehavior: string | ((url: string | string[]) => string);
  90144. /**
  90145. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  90146. * @ignorenaming
  90147. */
  90148. static UseFallbackTexture: boolean;
  90149. /**
  90150. * Use this object to register external classes like custom textures or material
  90151. * to allow the laoders to instantiate them
  90152. */
  90153. static RegisteredExternalClasses: {
  90154. [key: string]: Object;
  90155. };
  90156. /**
  90157. * Texture content used if a texture cannot loaded
  90158. * @ignorenaming
  90159. */
  90160. static fallbackTexture: string;
  90161. /**
  90162. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  90163. * @param u defines the coordinate on X axis
  90164. * @param v defines the coordinate on Y axis
  90165. * @param width defines the width of the source data
  90166. * @param height defines the height of the source data
  90167. * @param pixels defines the source byte array
  90168. * @param color defines the output color
  90169. */
  90170. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  90171. /**
  90172. * Interpolates between a and b via alpha
  90173. * @param a The lower value (returned when alpha = 0)
  90174. * @param b The upper value (returned when alpha = 1)
  90175. * @param alpha The interpolation-factor
  90176. * @return The mixed value
  90177. */
  90178. static Mix(a: number, b: number, alpha: number): number;
  90179. /**
  90180. * Tries to instantiate a new object from a given class name
  90181. * @param className defines the class name to instantiate
  90182. * @returns the new object or null if the system was not able to do the instantiation
  90183. */
  90184. static Instantiate(className: string): any;
  90185. /**
  90186. * Provides a slice function that will work even on IE
  90187. * @param data defines the array to slice
  90188. * @param start defines the start of the data (optional)
  90189. * @param end defines the end of the data (optional)
  90190. * @returns the new sliced array
  90191. */
  90192. static Slice<T>(data: T, start?: number, end?: number): T;
  90193. /**
  90194. * Polyfill for setImmediate
  90195. * @param action defines the action to execute after the current execution block
  90196. */
  90197. static SetImmediate(action: () => void): void;
  90198. /**
  90199. * Function indicating if a number is an exponent of 2
  90200. * @param value defines the value to test
  90201. * @returns true if the value is an exponent of 2
  90202. */
  90203. static IsExponentOfTwo(value: number): boolean;
  90204. private static _tmpFloatArray;
  90205. /**
  90206. * Returns the nearest 32-bit single precision float representation of a Number
  90207. * @param value A Number. If the parameter is of a different type, it will get converted
  90208. * to a number or to NaN if it cannot be converted
  90209. * @returns number
  90210. */
  90211. static FloatRound(value: number): number;
  90212. /**
  90213. * Find the next highest power of two.
  90214. * @param x Number to start search from.
  90215. * @return Next highest power of two.
  90216. */
  90217. static CeilingPOT(x: number): number;
  90218. /**
  90219. * Find the next lowest power of two.
  90220. * @param x Number to start search from.
  90221. * @return Next lowest power of two.
  90222. */
  90223. static FloorPOT(x: number): number;
  90224. /**
  90225. * Find the nearest power of two.
  90226. * @param x Number to start search from.
  90227. * @return Next nearest power of two.
  90228. */
  90229. static NearestPOT(x: number): number;
  90230. /**
  90231. * Get the closest exponent of two
  90232. * @param value defines the value to approximate
  90233. * @param max defines the maximum value to return
  90234. * @param mode defines how to define the closest value
  90235. * @returns closest exponent of two of the given value
  90236. */
  90237. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  90238. /**
  90239. * Extracts the filename from a path
  90240. * @param path defines the path to use
  90241. * @returns the filename
  90242. */
  90243. static GetFilename(path: string): string;
  90244. /**
  90245. * Extracts the "folder" part of a path (everything before the filename).
  90246. * @param uri The URI to extract the info from
  90247. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  90248. * @returns The "folder" part of the path
  90249. */
  90250. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  90251. /**
  90252. * Extracts text content from a DOM element hierarchy
  90253. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  90254. */
  90255. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  90256. /**
  90257. * Convert an angle in radians to degrees
  90258. * @param angle defines the angle to convert
  90259. * @returns the angle in degrees
  90260. */
  90261. static ToDegrees(angle: number): number;
  90262. /**
  90263. * Convert an angle in degrees to radians
  90264. * @param angle defines the angle to convert
  90265. * @returns the angle in radians
  90266. */
  90267. static ToRadians(angle: number): number;
  90268. /**
  90269. * Encode a buffer to a base64 string
  90270. * @param buffer defines the buffer to encode
  90271. * @returns the encoded string
  90272. */
  90273. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  90274. /**
  90275. * Extracts minimum and maximum values from a list of indexed positions
  90276. * @param positions defines the positions to use
  90277. * @param indices defines the indices to the positions
  90278. * @param indexStart defines the start index
  90279. * @param indexCount defines the end index
  90280. * @param bias defines bias value to add to the result
  90281. * @return minimum and maximum values
  90282. */
  90283. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  90284. minimum: Vector3;
  90285. maximum: Vector3;
  90286. };
  90287. /**
  90288. * Extracts minimum and maximum values from a list of positions
  90289. * @param positions defines the positions to use
  90290. * @param start defines the start index in the positions array
  90291. * @param count defines the number of positions to handle
  90292. * @param bias defines bias value to add to the result
  90293. * @param stride defines the stride size to use (distance between two positions in the positions array)
  90294. * @return minimum and maximum values
  90295. */
  90296. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  90297. minimum: Vector3;
  90298. maximum: Vector3;
  90299. };
  90300. /**
  90301. * Returns an array if obj is not an array
  90302. * @param obj defines the object to evaluate as an array
  90303. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  90304. * @returns either obj directly if obj is an array or a new array containing obj
  90305. */
  90306. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  90307. /**
  90308. * Gets the pointer prefix to use
  90309. * @returns "pointer" if touch is enabled. Else returns "mouse"
  90310. */
  90311. static GetPointerPrefix(): string;
  90312. /**
  90313. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  90314. * @param func - the function to be called
  90315. * @param requester - the object that will request the next frame. Falls back to window.
  90316. * @returns frame number
  90317. */
  90318. static QueueNewFrame(func: () => void, requester?: any): number;
  90319. /**
  90320. * Ask the browser to promote the current element to fullscreen rendering mode
  90321. * @param element defines the DOM element to promote
  90322. */
  90323. static RequestFullscreen(element: HTMLElement): void;
  90324. /**
  90325. * Asks the browser to exit fullscreen mode
  90326. */
  90327. static ExitFullscreen(): void;
  90328. /**
  90329. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  90330. * @param url define the url we are trying
  90331. * @param element define the dom element where to configure the cors policy
  90332. */
  90333. static SetCorsBehavior(url: string | string[], element: {
  90334. crossOrigin: string | null;
  90335. }): void;
  90336. /**
  90337. * Removes unwanted characters from an url
  90338. * @param url defines the url to clean
  90339. * @returns the cleaned url
  90340. */
  90341. static CleanUrl(url: string): string;
  90342. /**
  90343. * Gets or sets a function used to pre-process url before using them to load assets
  90344. */
  90345. static PreprocessUrl: (url: string) => string;
  90346. /**
  90347. * Loads an image as an HTMLImageElement.
  90348. * @param input url string, ArrayBuffer, or Blob to load
  90349. * @param onLoad callback called when the image successfully loads
  90350. * @param onError callback called when the image fails to load
  90351. * @param offlineProvider offline provider for caching
  90352. * @returns the HTMLImageElement of the loaded image
  90353. */
  90354. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  90355. /**
  90356. * Loads a file
  90357. * @param url url string, ArrayBuffer, or Blob to load
  90358. * @param onSuccess callback called when the file successfully loads
  90359. * @param onProgress callback called while file is loading (if the server supports this mode)
  90360. * @param offlineProvider defines the offline provider for caching
  90361. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  90362. * @param onError callback called when the file fails to load
  90363. * @returns a file request object
  90364. */
  90365. 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;
  90366. /**
  90367. * Load a script (identified by an url). When the url returns, the
  90368. * content of this file is added into a new script element, attached to the DOM (body element)
  90369. * @param scriptUrl defines the url of the script to laod
  90370. * @param onSuccess defines the callback called when the script is loaded
  90371. * @param onError defines the callback to call if an error occurs
  90372. * @param scriptId defines the id of the script element
  90373. */
  90374. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  90375. /**
  90376. * Load an asynchronous script (identified by an url). When the url returns, the
  90377. * content of this file is added into a new script element, attached to the DOM (body element)
  90378. * @param scriptUrl defines the url of the script to laod
  90379. * @param scriptId defines the id of the script element
  90380. * @returns a promise request object
  90381. */
  90382. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  90383. /**
  90384. * Loads a file from a blob
  90385. * @param fileToLoad defines the blob to use
  90386. * @param callback defines the callback to call when data is loaded
  90387. * @param progressCallback defines the callback to call during loading process
  90388. * @returns a file request object
  90389. */
  90390. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  90391. /**
  90392. * Loads a file
  90393. * @param fileToLoad defines the file to load
  90394. * @param callback defines the callback to call when data is loaded
  90395. * @param progressCallBack defines the callback to call during loading process
  90396. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  90397. * @returns a file request object
  90398. */
  90399. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  90400. /**
  90401. * Creates a data url from a given string content
  90402. * @param content defines the content to convert
  90403. * @returns the new data url link
  90404. */
  90405. static FileAsURL(content: string): string;
  90406. /**
  90407. * Format the given number to a specific decimal format
  90408. * @param value defines the number to format
  90409. * @param decimals defines the number of decimals to use
  90410. * @returns the formatted string
  90411. */
  90412. static Format(value: number, decimals?: number): string;
  90413. /**
  90414. * Checks if a given vector is inside a specific range
  90415. * @param v defines the vector to test
  90416. * @param min defines the minimum range
  90417. * @param max defines the maximum range
  90418. */
  90419. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  90420. /**
  90421. * Tries to copy an object by duplicating every property
  90422. * @param source defines the source object
  90423. * @param destination defines the target object
  90424. * @param doNotCopyList defines a list of properties to avoid
  90425. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  90426. */
  90427. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  90428. /**
  90429. * Gets a boolean indicating if the given object has no own property
  90430. * @param obj defines the object to test
  90431. * @returns true if object has no own property
  90432. */
  90433. static IsEmpty(obj: any): boolean;
  90434. /**
  90435. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  90436. * @param str Source string
  90437. * @param suffix Suffix to search for in the source string
  90438. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  90439. */
  90440. static EndsWith(str: string, suffix: string): boolean;
  90441. /**
  90442. * Function used to register events at window level
  90443. * @param events defines the events to register
  90444. */
  90445. static RegisterTopRootEvents(events: {
  90446. name: string;
  90447. handler: Nullable<(e: FocusEvent) => any>;
  90448. }[]): void;
  90449. /**
  90450. * Function used to unregister events from window level
  90451. * @param events defines the events to unregister
  90452. */
  90453. static UnregisterTopRootEvents(events: {
  90454. name: string;
  90455. handler: Nullable<(e: FocusEvent) => any>;
  90456. }[]): void;
  90457. /**
  90458. * @ignore
  90459. */
  90460. static _ScreenshotCanvas: HTMLCanvasElement;
  90461. /**
  90462. * Dumps the current bound framebuffer
  90463. * @param width defines the rendering width
  90464. * @param height defines the rendering height
  90465. * @param engine defines the hosting engine
  90466. * @param successCallback defines the callback triggered once the data are available
  90467. * @param mimeType defines the mime type of the result
  90468. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  90469. */
  90470. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  90471. /**
  90472. * Converts the canvas data to blob.
  90473. * This acts as a polyfill for browsers not supporting the to blob function.
  90474. * @param canvas Defines the canvas to extract the data from
  90475. * @param successCallback Defines the callback triggered once the data are available
  90476. * @param mimeType Defines the mime type of the result
  90477. */
  90478. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  90479. /**
  90480. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  90481. * @param successCallback defines the callback triggered once the data are available
  90482. * @param mimeType defines the mime type of the result
  90483. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  90484. */
  90485. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  90486. /**
  90487. * Downloads a blob in the browser
  90488. * @param blob defines the blob to download
  90489. * @param fileName defines the name of the downloaded file
  90490. */
  90491. static Download(blob: Blob, fileName: string): void;
  90492. /**
  90493. * Captures a screenshot of the current rendering
  90494. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  90495. * @param engine defines the rendering engine
  90496. * @param camera defines the source camera
  90497. * @param size This parameter can be set to a single number or to an object with the
  90498. * following (optional) properties: precision, width, height. If a single number is passed,
  90499. * it will be used for both width and height. If an object is passed, the screenshot size
  90500. * will be derived from the parameters. The precision property is a multiplier allowing
  90501. * rendering at a higher or lower resolution
  90502. * @param successCallback defines the callback receives a single parameter which contains the
  90503. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  90504. * src parameter of an <img> to display it
  90505. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  90506. * Check your browser for supported MIME types
  90507. */
  90508. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  90509. /**
  90510. * Generates an image screenshot from the specified camera.
  90511. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  90512. * @param engine The engine to use for rendering
  90513. * @param camera The camera to use for rendering
  90514. * @param size This parameter can be set to a single number or to an object with the
  90515. * following (optional) properties: precision, width, height. If a single number is passed,
  90516. * it will be used for both width and height. If an object is passed, the screenshot size
  90517. * will be derived from the parameters. The precision property is a multiplier allowing
  90518. * rendering at a higher or lower resolution
  90519. * @param successCallback The callback receives a single parameter which contains the
  90520. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  90521. * src parameter of an <img> to display it
  90522. * @param mimeType The MIME type of the screenshot image (default: image/png).
  90523. * Check your browser for supported MIME types
  90524. * @param samples Texture samples (default: 1)
  90525. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  90526. * @param fileName A name for for the downloaded file.
  90527. */
  90528. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  90529. /**
  90530. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  90531. * Be aware Math.random() could cause collisions, but:
  90532. * "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"
  90533. * @returns a pseudo random id
  90534. */
  90535. static RandomId(): string;
  90536. /**
  90537. * Test if the given uri is a base64 string
  90538. * @param uri The uri to test
  90539. * @return True if the uri is a base64 string or false otherwise
  90540. */
  90541. static IsBase64(uri: string): boolean;
  90542. /**
  90543. * Decode the given base64 uri.
  90544. * @param uri The uri to decode
  90545. * @return The decoded base64 data.
  90546. */
  90547. static DecodeBase64(uri: string): ArrayBuffer;
  90548. /**
  90549. * Gets the absolute url.
  90550. * @param url the input url
  90551. * @return the absolute url
  90552. */
  90553. static GetAbsoluteUrl(url: string): string;
  90554. /**
  90555. * No log
  90556. */
  90557. static readonly NoneLogLevel: number;
  90558. /**
  90559. * Only message logs
  90560. */
  90561. static readonly MessageLogLevel: number;
  90562. /**
  90563. * Only warning logs
  90564. */
  90565. static readonly WarningLogLevel: number;
  90566. /**
  90567. * Only error logs
  90568. */
  90569. static readonly ErrorLogLevel: number;
  90570. /**
  90571. * All logs
  90572. */
  90573. static readonly AllLogLevel: number;
  90574. /**
  90575. * Gets a value indicating the number of loading errors
  90576. * @ignorenaming
  90577. */
  90578. static readonly errorsCount: number;
  90579. /**
  90580. * Callback called when a new log is added
  90581. */
  90582. static OnNewCacheEntry: (entry: string) => void;
  90583. /**
  90584. * Log a message to the console
  90585. * @param message defines the message to log
  90586. */
  90587. static Log(message: string): void;
  90588. /**
  90589. * Write a warning message to the console
  90590. * @param message defines the message to log
  90591. */
  90592. static Warn(message: string): void;
  90593. /**
  90594. * Write an error message to the console
  90595. * @param message defines the message to log
  90596. */
  90597. static Error(message: string): void;
  90598. /**
  90599. * Gets current log cache (list of logs)
  90600. */
  90601. static readonly LogCache: string;
  90602. /**
  90603. * Clears the log cache
  90604. */
  90605. static ClearLogCache(): void;
  90606. /**
  90607. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  90608. */
  90609. static LogLevels: number;
  90610. /**
  90611. * Checks if the loaded document was accessed via `file:`-Protocol.
  90612. * @returns boolean
  90613. */
  90614. static IsFileURL(): boolean;
  90615. /**
  90616. * Checks if the window object exists
  90617. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  90618. */
  90619. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  90620. /**
  90621. * No performance log
  90622. */
  90623. static readonly PerformanceNoneLogLevel: number;
  90624. /**
  90625. * Use user marks to log performance
  90626. */
  90627. static readonly PerformanceUserMarkLogLevel: number;
  90628. /**
  90629. * Log performance to the console
  90630. */
  90631. static readonly PerformanceConsoleLogLevel: number;
  90632. private static _performance;
  90633. /**
  90634. * Sets the current performance log level
  90635. */
  90636. static PerformanceLogLevel: number;
  90637. private static _StartPerformanceCounterDisabled;
  90638. private static _EndPerformanceCounterDisabled;
  90639. private static _StartUserMark;
  90640. private static _EndUserMark;
  90641. private static _StartPerformanceConsole;
  90642. private static _EndPerformanceConsole;
  90643. /**
  90644. * Starts a performance counter
  90645. */
  90646. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  90647. /**
  90648. * Ends a specific performance coutner
  90649. */
  90650. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  90651. /**
  90652. * Gets either window.performance.now() if supported or Date.now() else
  90653. */
  90654. static readonly Now: number;
  90655. /**
  90656. * This method will return the name of the class used to create the instance of the given object.
  90657. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  90658. * @param object the object to get the class name from
  90659. * @param isType defines if the object is actually a type
  90660. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  90661. */
  90662. static GetClassName(object: any, isType?: boolean): string;
  90663. /**
  90664. * Gets the first element of an array satisfying a given predicate
  90665. * @param array defines the array to browse
  90666. * @param predicate defines the predicate to use
  90667. * @returns null if not found or the element
  90668. */
  90669. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  90670. /**
  90671. * This method will return the name of the full name of the class, including its owning module (if any).
  90672. * 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).
  90673. * @param object the object to get the class name from
  90674. * @param isType defines if the object is actually a type
  90675. * @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.
  90676. * @ignorenaming
  90677. */
  90678. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  90679. /**
  90680. * Returns a promise that resolves after the given amount of time.
  90681. * @param delay Number of milliseconds to delay
  90682. * @returns Promise that resolves after the given amount of time
  90683. */
  90684. static DelayAsync(delay: number): Promise<void>;
  90685. /**
  90686. * Gets the current gradient from an array of IValueGradient
  90687. * @param ratio defines the current ratio to get
  90688. * @param gradients defines the array of IValueGradient
  90689. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  90690. */
  90691. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  90692. }
  90693. /**
  90694. * This class is used to track a performance counter which is number based.
  90695. * The user has access to many properties which give statistics of different nature.
  90696. *
  90697. * The implementer can track two kinds of Performance Counter: time and count.
  90698. * 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.
  90699. * 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.
  90700. */
  90701. export class PerfCounter {
  90702. /**
  90703. * Gets or sets a global boolean to turn on and off all the counters
  90704. */
  90705. static Enabled: boolean;
  90706. /**
  90707. * Returns the smallest value ever
  90708. */
  90709. readonly min: number;
  90710. /**
  90711. * Returns the biggest value ever
  90712. */
  90713. readonly max: number;
  90714. /**
  90715. * Returns the average value since the performance counter is running
  90716. */
  90717. readonly average: number;
  90718. /**
  90719. * Returns the average value of the last second the counter was monitored
  90720. */
  90721. readonly lastSecAverage: number;
  90722. /**
  90723. * Returns the current value
  90724. */
  90725. readonly current: number;
  90726. /**
  90727. * Gets the accumulated total
  90728. */
  90729. readonly total: number;
  90730. /**
  90731. * Gets the total value count
  90732. */
  90733. readonly count: number;
  90734. /**
  90735. * Creates a new counter
  90736. */
  90737. constructor();
  90738. /**
  90739. * Call this method to start monitoring a new frame.
  90740. * 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.
  90741. */
  90742. fetchNewFrame(): void;
  90743. /**
  90744. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  90745. * @param newCount the count value to add to the monitored count
  90746. * @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.
  90747. */
  90748. addCount(newCount: number, fetchResult: boolean): void;
  90749. /**
  90750. * Start monitoring this performance counter
  90751. */
  90752. beginMonitoring(): void;
  90753. /**
  90754. * Compute the time lapsed since the previous beginMonitoring() call.
  90755. * @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
  90756. */
  90757. endMonitoring(newFrame?: boolean): void;
  90758. private _fetchResult;
  90759. private _startMonitoringTime;
  90760. private _min;
  90761. private _max;
  90762. private _average;
  90763. private _current;
  90764. private _totalValueCount;
  90765. private _totalAccumulated;
  90766. private _lastSecAverage;
  90767. private _lastSecAccumulated;
  90768. private _lastSecTime;
  90769. private _lastSecValueCount;
  90770. }
  90771. /**
  90772. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  90773. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  90774. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  90775. * @param name The name of the class, case should be preserved
  90776. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  90777. */
  90778. export function className(name: string, module?: string): (target: Object) => void;
  90779. /**
  90780. * An implementation of a loop for asynchronous functions.
  90781. */
  90782. export class AsyncLoop {
  90783. /**
  90784. * Defines the number of iterations for the loop
  90785. */
  90786. iterations: number;
  90787. /**
  90788. * Defines the current index of the loop.
  90789. */
  90790. index: number;
  90791. private _done;
  90792. private _fn;
  90793. private _successCallback;
  90794. /**
  90795. * Constructor.
  90796. * @param iterations the number of iterations.
  90797. * @param func the function to run each iteration
  90798. * @param successCallback the callback that will be called upon succesful execution
  90799. * @param offset starting offset.
  90800. */
  90801. constructor(
  90802. /**
  90803. * Defines the number of iterations for the loop
  90804. */
  90805. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  90806. /**
  90807. * Execute the next iteration. Must be called after the last iteration was finished.
  90808. */
  90809. executeNext(): void;
  90810. /**
  90811. * Break the loop and run the success callback.
  90812. */
  90813. breakLoop(): void;
  90814. /**
  90815. * Create and run an async loop.
  90816. * @param iterations the number of iterations.
  90817. * @param fn the function to run each iteration
  90818. * @param successCallback the callback that will be called upon succesful execution
  90819. * @param offset starting offset.
  90820. * @returns the created async loop object
  90821. */
  90822. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  90823. /**
  90824. * A for-loop that will run a given number of iterations synchronous and the rest async.
  90825. * @param iterations total number of iterations
  90826. * @param syncedIterations number of synchronous iterations in each async iteration.
  90827. * @param fn the function to call each iteration.
  90828. * @param callback a success call back that will be called when iterating stops.
  90829. * @param breakFunction a break condition (optional)
  90830. * @param timeout timeout settings for the setTimeout function. default - 0.
  90831. * @returns the created async loop object
  90832. */
  90833. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  90834. }
  90835. }
  90836. declare module BABYLON {
  90837. /** @hidden */
  90838. export interface ICollisionCoordinator {
  90839. createCollider(): Collider;
  90840. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  90841. init(scene: Scene): void;
  90842. }
  90843. /** @hidden */
  90844. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  90845. private _scene;
  90846. private _scaledPosition;
  90847. private _scaledVelocity;
  90848. private _finalPosition;
  90849. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  90850. createCollider(): Collider;
  90851. init(scene: Scene): void;
  90852. private _collideWithWorld;
  90853. }
  90854. }
  90855. declare module BABYLON {
  90856. /**
  90857. * This class defines the direct association between an animation and a target
  90858. */
  90859. export class TargetedAnimation {
  90860. /**
  90861. * Animation to perform
  90862. */
  90863. animation: Animation;
  90864. /**
  90865. * Target to animate
  90866. */
  90867. target: any;
  90868. }
  90869. /**
  90870. * Use this class to create coordinated animations on multiple targets
  90871. */
  90872. export class AnimationGroup implements IDisposable {
  90873. /** The name of the animation group */
  90874. name: string;
  90875. private _scene;
  90876. private _targetedAnimations;
  90877. private _animatables;
  90878. private _from;
  90879. private _to;
  90880. private _isStarted;
  90881. private _isPaused;
  90882. private _speedRatio;
  90883. /**
  90884. * Gets or sets the unique id of the node
  90885. */
  90886. uniqueId: number;
  90887. /**
  90888. * This observable will notify when one animation have ended
  90889. */
  90890. onAnimationEndObservable: Observable<TargetedAnimation>;
  90891. /**
  90892. * Observer raised when one animation loops
  90893. */
  90894. onAnimationLoopObservable: Observable<TargetedAnimation>;
  90895. /**
  90896. * This observable will notify when all animations have ended.
  90897. */
  90898. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  90899. /**
  90900. * This observable will notify when all animations have paused.
  90901. */
  90902. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  90903. /**
  90904. * This observable will notify when all animations are playing.
  90905. */
  90906. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  90907. /**
  90908. * Gets the first frame
  90909. */
  90910. readonly from: number;
  90911. /**
  90912. * Gets the last frame
  90913. */
  90914. readonly to: number;
  90915. /**
  90916. * Define if the animations are started
  90917. */
  90918. readonly isStarted: boolean;
  90919. /**
  90920. * Gets a value indicating that the current group is playing
  90921. */
  90922. readonly isPlaying: boolean;
  90923. /**
  90924. * Gets or sets the speed ratio to use for all animations
  90925. */
  90926. /**
  90927. * Gets or sets the speed ratio to use for all animations
  90928. */
  90929. speedRatio: number;
  90930. /**
  90931. * Gets the targeted animations for this animation group
  90932. */
  90933. readonly targetedAnimations: Array<TargetedAnimation>;
  90934. /**
  90935. * returning the list of animatables controlled by this animation group.
  90936. */
  90937. readonly animatables: Array<Animatable>;
  90938. /**
  90939. * Instantiates a new Animation Group.
  90940. * This helps managing several animations at once.
  90941. * @see http://doc.babylonjs.com/how_to/group
  90942. * @param name Defines the name of the group
  90943. * @param scene Defines the scene the group belongs to
  90944. */
  90945. constructor(
  90946. /** The name of the animation group */
  90947. name: string, scene?: Nullable<Scene>);
  90948. /**
  90949. * Add an animation (with its target) in the group
  90950. * @param animation defines the animation we want to add
  90951. * @param target defines the target of the animation
  90952. * @returns the TargetedAnimation object
  90953. */
  90954. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  90955. /**
  90956. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  90957. * It can add constant keys at begin or end
  90958. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  90959. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  90960. * @returns the animation group
  90961. */
  90962. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  90963. /**
  90964. * Start all animations on given targets
  90965. * @param loop defines if animations must loop
  90966. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  90967. * @param from defines the from key (optional)
  90968. * @param to defines the to key (optional)
  90969. * @returns the current animation group
  90970. */
  90971. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  90972. /**
  90973. * Pause all animations
  90974. * @returns the animation group
  90975. */
  90976. pause(): AnimationGroup;
  90977. /**
  90978. * Play all animations to initial state
  90979. * This function will start() the animations if they were not started or will restart() them if they were paused
  90980. * @param loop defines if animations must loop
  90981. * @returns the animation group
  90982. */
  90983. play(loop?: boolean): AnimationGroup;
  90984. /**
  90985. * Reset all animations to initial state
  90986. * @returns the animation group
  90987. */
  90988. reset(): AnimationGroup;
  90989. /**
  90990. * Restart animations from key 0
  90991. * @returns the animation group
  90992. */
  90993. restart(): AnimationGroup;
  90994. /**
  90995. * Stop all animations
  90996. * @returns the animation group
  90997. */
  90998. stop(): AnimationGroup;
  90999. /**
  91000. * Set animation weight for all animatables
  91001. * @param weight defines the weight to use
  91002. * @return the animationGroup
  91003. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  91004. */
  91005. setWeightForAllAnimatables(weight: number): AnimationGroup;
  91006. /**
  91007. * Synchronize and normalize all animatables with a source animatable
  91008. * @param root defines the root animatable to synchronize with
  91009. * @return the animationGroup
  91010. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  91011. */
  91012. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  91013. /**
  91014. * Goes to a specific frame in this animation group
  91015. * @param frame the frame number to go to
  91016. * @return the animationGroup
  91017. */
  91018. goToFrame(frame: number): AnimationGroup;
  91019. /**
  91020. * Dispose all associated resources
  91021. */
  91022. dispose(): void;
  91023. private _checkAnimationGroupEnded;
  91024. /**
  91025. * Clone the current animation group and returns a copy
  91026. * @param newName defines the name of the new group
  91027. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  91028. * @returns the new aniamtion group
  91029. */
  91030. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  91031. /**
  91032. * Returns a new AnimationGroup object parsed from the source provided.
  91033. * @param parsedAnimationGroup defines the source
  91034. * @param scene defines the scene that will receive the animationGroup
  91035. * @returns a new AnimationGroup
  91036. */
  91037. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  91038. /**
  91039. * Returns the string "AnimationGroup"
  91040. * @returns "AnimationGroup"
  91041. */
  91042. getClassName(): string;
  91043. /**
  91044. * Creates a detailled string about the object
  91045. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  91046. * @returns a string representing the object
  91047. */
  91048. toString(fullDetails?: boolean): string;
  91049. }
  91050. }
  91051. declare module BABYLON {
  91052. /**
  91053. * Define an interface for all classes that will hold resources
  91054. */
  91055. export interface IDisposable {
  91056. /**
  91057. * Releases all held resources
  91058. */
  91059. dispose(): void;
  91060. }
  91061. /** Interface defining initialization parameters for Scene class */
  91062. export interface SceneOptions {
  91063. /**
  91064. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  91065. * It will improve performance when the number of geometries becomes important.
  91066. */
  91067. useGeometryUniqueIdsMap?: boolean;
  91068. /**
  91069. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  91070. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  91071. */
  91072. useMaterialMeshMap?: boolean;
  91073. /**
  91074. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  91075. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  91076. */
  91077. useClonedMeshhMap?: boolean;
  91078. }
  91079. /**
  91080. * Represents a scene to be rendered by the engine.
  91081. * @see http://doc.babylonjs.com/features/scene
  91082. */
  91083. export class Scene extends AbstractScene implements IAnimatable {
  91084. private static _uniqueIdCounter;
  91085. /** The fog is deactivated */
  91086. static readonly FOGMODE_NONE: number;
  91087. /** The fog density is following an exponential function */
  91088. static readonly FOGMODE_EXP: number;
  91089. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  91090. static readonly FOGMODE_EXP2: number;
  91091. /** The fog density is following a linear function. */
  91092. static readonly FOGMODE_LINEAR: number;
  91093. /**
  91094. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  91095. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91096. */
  91097. static MinDeltaTime: number;
  91098. /**
  91099. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  91100. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91101. */
  91102. static MaxDeltaTime: number;
  91103. /**
  91104. * Factory used to create the default material.
  91105. * @param name The name of the material to create
  91106. * @param scene The scene to create the material for
  91107. * @returns The default material
  91108. */
  91109. static DefaultMaterialFactory(scene: Scene): Material;
  91110. /**
  91111. * Factory used to create the a collision coordinator.
  91112. * @returns The collision coordinator
  91113. */
  91114. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  91115. /** @hidden */
  91116. readonly _isScene: boolean;
  91117. /**
  91118. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  91119. */
  91120. autoClear: boolean;
  91121. /**
  91122. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  91123. */
  91124. autoClearDepthAndStencil: boolean;
  91125. /**
  91126. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  91127. */
  91128. clearColor: Color4;
  91129. /**
  91130. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  91131. */
  91132. ambientColor: Color3;
  91133. /**
  91134. * This is use to store the default BRDF lookup for PBR materials in your scene.
  91135. * It should only be one of the following (if not the default embedded one):
  91136. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  91137. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  91138. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  91139. * The material properties need to be setup according to the type of texture in use.
  91140. */
  91141. environmentBRDFTexture: BaseTexture;
  91142. /** @hidden */
  91143. protected _environmentTexture: Nullable<BaseTexture>;
  91144. /**
  91145. * Texture used in all pbr material as the reflection texture.
  91146. * As in the majority of the scene they are the same (exception for multi room and so on),
  91147. * this is easier to reference from here than from all the materials.
  91148. */
  91149. /**
  91150. * Texture used in all pbr material as the reflection texture.
  91151. * As in the majority of the scene they are the same (exception for multi room and so on),
  91152. * this is easier to set here than in all the materials.
  91153. */
  91154. environmentTexture: Nullable<BaseTexture>;
  91155. /** @hidden */
  91156. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  91157. /**
  91158. * Default image processing configuration used either in the rendering
  91159. * Forward main pass or through the imageProcessingPostProcess if present.
  91160. * As in the majority of the scene they are the same (exception for multi camera),
  91161. * this is easier to reference from here than from all the materials and post process.
  91162. *
  91163. * No setter as we it is a shared configuration, you can set the values instead.
  91164. */
  91165. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  91166. private _forceWireframe;
  91167. /**
  91168. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  91169. */
  91170. forceWireframe: boolean;
  91171. private _forcePointsCloud;
  91172. /**
  91173. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  91174. */
  91175. forcePointsCloud: boolean;
  91176. /**
  91177. * Gets or sets the active clipplane 1
  91178. */
  91179. clipPlane: Nullable<Plane>;
  91180. /**
  91181. * Gets or sets the active clipplane 2
  91182. */
  91183. clipPlane2: Nullable<Plane>;
  91184. /**
  91185. * Gets or sets the active clipplane 3
  91186. */
  91187. clipPlane3: Nullable<Plane>;
  91188. /**
  91189. * Gets or sets the active clipplane 4
  91190. */
  91191. clipPlane4: Nullable<Plane>;
  91192. /**
  91193. * Gets or sets a boolean indicating if animations are enabled
  91194. */
  91195. animationsEnabled: boolean;
  91196. private _animationPropertiesOverride;
  91197. /**
  91198. * Gets or sets the animation properties override
  91199. */
  91200. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  91201. /**
  91202. * Gets or sets a boolean indicating if a constant deltatime has to be used
  91203. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  91204. */
  91205. useConstantAnimationDeltaTime: boolean;
  91206. /**
  91207. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  91208. * Please note that it requires to run a ray cast through the scene on every frame
  91209. */
  91210. constantlyUpdateMeshUnderPointer: boolean;
  91211. /**
  91212. * Defines the HTML cursor to use when hovering over interactive elements
  91213. */
  91214. hoverCursor: string;
  91215. /**
  91216. * Defines the HTML default cursor to use (empty by default)
  91217. */
  91218. defaultCursor: string;
  91219. /**
  91220. * This is used to call preventDefault() on pointer down
  91221. * in order to block unwanted artifacts like system double clicks
  91222. */
  91223. preventDefaultOnPointerDown: boolean;
  91224. /**
  91225. * This is used to call preventDefault() on pointer up
  91226. * in order to block unwanted artifacts like system double clicks
  91227. */
  91228. preventDefaultOnPointerUp: boolean;
  91229. /**
  91230. * Gets or sets user defined metadata
  91231. */
  91232. metadata: any;
  91233. /**
  91234. * For internal use only. Please do not use.
  91235. */
  91236. reservedDataStore: any;
  91237. /**
  91238. * Gets the name of the plugin used to load this scene (null by default)
  91239. */
  91240. loadingPluginName: string;
  91241. /**
  91242. * Use this array to add regular expressions used to disable offline support for specific urls
  91243. */
  91244. disableOfflineSupportExceptionRules: RegExp[];
  91245. /**
  91246. * An event triggered when the scene is disposed.
  91247. */
  91248. onDisposeObservable: Observable<Scene>;
  91249. private _onDisposeObserver;
  91250. /** Sets a function to be executed when this scene is disposed. */
  91251. onDispose: () => void;
  91252. /**
  91253. * An event triggered before rendering the scene (right after animations and physics)
  91254. */
  91255. onBeforeRenderObservable: Observable<Scene>;
  91256. private _onBeforeRenderObserver;
  91257. /** Sets a function to be executed before rendering this scene */
  91258. beforeRender: Nullable<() => void>;
  91259. /**
  91260. * An event triggered after rendering the scene
  91261. */
  91262. onAfterRenderObservable: Observable<Scene>;
  91263. private _onAfterRenderObserver;
  91264. /** Sets a function to be executed after rendering this scene */
  91265. afterRender: Nullable<() => void>;
  91266. /**
  91267. * An event triggered before animating the scene
  91268. */
  91269. onBeforeAnimationsObservable: Observable<Scene>;
  91270. /**
  91271. * An event triggered after animations processing
  91272. */
  91273. onAfterAnimationsObservable: Observable<Scene>;
  91274. /**
  91275. * An event triggered before draw calls are ready to be sent
  91276. */
  91277. onBeforeDrawPhaseObservable: Observable<Scene>;
  91278. /**
  91279. * An event triggered after draw calls have been sent
  91280. */
  91281. onAfterDrawPhaseObservable: Observable<Scene>;
  91282. /**
  91283. * An event triggered when the scene is ready
  91284. */
  91285. onReadyObservable: Observable<Scene>;
  91286. /**
  91287. * An event triggered before rendering a camera
  91288. */
  91289. onBeforeCameraRenderObservable: Observable<Camera>;
  91290. private _onBeforeCameraRenderObserver;
  91291. /** Sets a function to be executed before rendering a camera*/
  91292. beforeCameraRender: () => void;
  91293. /**
  91294. * An event triggered after rendering a camera
  91295. */
  91296. onAfterCameraRenderObservable: Observable<Camera>;
  91297. private _onAfterCameraRenderObserver;
  91298. /** Sets a function to be executed after rendering a camera*/
  91299. afterCameraRender: () => void;
  91300. /**
  91301. * An event triggered when active meshes evaluation is about to start
  91302. */
  91303. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  91304. /**
  91305. * An event triggered when active meshes evaluation is done
  91306. */
  91307. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  91308. /**
  91309. * An event triggered when particles rendering is about to start
  91310. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  91311. */
  91312. onBeforeParticlesRenderingObservable: Observable<Scene>;
  91313. /**
  91314. * An event triggered when particles rendering is done
  91315. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  91316. */
  91317. onAfterParticlesRenderingObservable: Observable<Scene>;
  91318. /**
  91319. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  91320. */
  91321. onDataLoadedObservable: Observable<Scene>;
  91322. /**
  91323. * An event triggered when a camera is created
  91324. */
  91325. onNewCameraAddedObservable: Observable<Camera>;
  91326. /**
  91327. * An event triggered when a camera is removed
  91328. */
  91329. onCameraRemovedObservable: Observable<Camera>;
  91330. /**
  91331. * An event triggered when a light is created
  91332. */
  91333. onNewLightAddedObservable: Observable<Light>;
  91334. /**
  91335. * An event triggered when a light is removed
  91336. */
  91337. onLightRemovedObservable: Observable<Light>;
  91338. /**
  91339. * An event triggered when a geometry is created
  91340. */
  91341. onNewGeometryAddedObservable: Observable<Geometry>;
  91342. /**
  91343. * An event triggered when a geometry is removed
  91344. */
  91345. onGeometryRemovedObservable: Observable<Geometry>;
  91346. /**
  91347. * An event triggered when a transform node is created
  91348. */
  91349. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  91350. /**
  91351. * An event triggered when a transform node is removed
  91352. */
  91353. onTransformNodeRemovedObservable: Observable<TransformNode>;
  91354. /**
  91355. * An event triggered when a mesh is created
  91356. */
  91357. onNewMeshAddedObservable: Observable<AbstractMesh>;
  91358. /**
  91359. * An event triggered when a mesh is removed
  91360. */
  91361. onMeshRemovedObservable: Observable<AbstractMesh>;
  91362. /**
  91363. * An event triggered when a skeleton is created
  91364. */
  91365. onNewSkeletonAddedObservable: Observable<Skeleton>;
  91366. /**
  91367. * An event triggered when a skeleton is removed
  91368. */
  91369. onSkeletonRemovedObservable: Observable<Skeleton>;
  91370. /**
  91371. * An event triggered when a material is created
  91372. */
  91373. onNewMaterialAddedObservable: Observable<Material>;
  91374. /**
  91375. * An event triggered when a material is removed
  91376. */
  91377. onMaterialRemovedObservable: Observable<Material>;
  91378. /**
  91379. * An event triggered when a texture is created
  91380. */
  91381. onNewTextureAddedObservable: Observable<BaseTexture>;
  91382. /**
  91383. * An event triggered when a texture is removed
  91384. */
  91385. onTextureRemovedObservable: Observable<BaseTexture>;
  91386. /**
  91387. * An event triggered when render targets are about to be rendered
  91388. * Can happen multiple times per frame.
  91389. */
  91390. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  91391. /**
  91392. * An event triggered when render targets were rendered.
  91393. * Can happen multiple times per frame.
  91394. */
  91395. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  91396. /**
  91397. * An event triggered before calculating deterministic simulation step
  91398. */
  91399. onBeforeStepObservable: Observable<Scene>;
  91400. /**
  91401. * An event triggered after calculating deterministic simulation step
  91402. */
  91403. onAfterStepObservable: Observable<Scene>;
  91404. /**
  91405. * An event triggered when the activeCamera property is updated
  91406. */
  91407. onActiveCameraChanged: Observable<Scene>;
  91408. /**
  91409. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  91410. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  91411. * 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)
  91412. */
  91413. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  91414. /**
  91415. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  91416. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  91417. * 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)
  91418. */
  91419. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  91420. /**
  91421. * This Observable will when a mesh has been imported into the scene.
  91422. */
  91423. onMeshImportedObservable: Observable<AbstractMesh>;
  91424. /**
  91425. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  91426. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  91427. */
  91428. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  91429. /** @hidden */
  91430. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  91431. /**
  91432. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  91433. */
  91434. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  91435. /**
  91436. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  91437. */
  91438. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  91439. /**
  91440. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  91441. */
  91442. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  91443. private _onPointerMove;
  91444. private _onPointerDown;
  91445. private _onPointerUp;
  91446. /** Callback called when a pointer move is detected */
  91447. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  91448. /** Callback called when a pointer down is detected */
  91449. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  91450. /** Callback called when a pointer up is detected */
  91451. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  91452. /** Callback called when a pointer pick is detected */
  91453. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  91454. /**
  91455. * 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).
  91456. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  91457. */
  91458. onPrePointerObservable: Observable<PointerInfoPre>;
  91459. /**
  91460. * Observable event triggered each time an input event is received from the rendering canvas
  91461. */
  91462. onPointerObservable: Observable<PointerInfo>;
  91463. /**
  91464. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  91465. */
  91466. readonly unTranslatedPointer: Vector2;
  91467. /** The distance in pixel that you have to move to prevent some events */
  91468. static DragMovementThreshold: number;
  91469. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  91470. static LongPressDelay: number;
  91471. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  91472. static DoubleClickDelay: number;
  91473. /** If you need to check double click without raising a single click at first click, enable this flag */
  91474. static ExclusiveDoubleClickMode: boolean;
  91475. private _initClickEvent;
  91476. private _initActionManager;
  91477. private _delayedSimpleClick;
  91478. private _delayedSimpleClickTimeout;
  91479. private _previousDelayedSimpleClickTimeout;
  91480. private _meshPickProceed;
  91481. private _previousButtonPressed;
  91482. private _currentPickResult;
  91483. private _previousPickResult;
  91484. private _totalPointersPressed;
  91485. private _doubleClickOccured;
  91486. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  91487. cameraToUseForPointers: Nullable<Camera>;
  91488. private _pointerX;
  91489. private _pointerY;
  91490. private _unTranslatedPointerX;
  91491. private _unTranslatedPointerY;
  91492. private _startingPointerPosition;
  91493. private _previousStartingPointerPosition;
  91494. private _startingPointerTime;
  91495. private _previousStartingPointerTime;
  91496. private _pointerCaptures;
  91497. private _timeAccumulator;
  91498. private _currentStepId;
  91499. private _currentInternalStep;
  91500. /** @hidden */
  91501. _mirroredCameraPosition: Nullable<Vector3>;
  91502. /**
  91503. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  91504. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  91505. */
  91506. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  91507. /**
  91508. * Observable event triggered each time an keyboard event is received from the hosting window
  91509. */
  91510. onKeyboardObservable: Observable<KeyboardInfo>;
  91511. private _onKeyDown;
  91512. private _onKeyUp;
  91513. private _onCanvasFocusObserver;
  91514. private _onCanvasBlurObserver;
  91515. private _useRightHandedSystem;
  91516. /**
  91517. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  91518. */
  91519. useRightHandedSystem: boolean;
  91520. /**
  91521. * Sets the step Id used by deterministic lock step
  91522. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91523. * @param newStepId defines the step Id
  91524. */
  91525. setStepId(newStepId: number): void;
  91526. /**
  91527. * Gets the step Id used by deterministic lock step
  91528. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91529. * @returns the step Id
  91530. */
  91531. getStepId(): number;
  91532. /**
  91533. * Gets the internal step used by deterministic lock step
  91534. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91535. * @returns the internal step
  91536. */
  91537. getInternalStep(): number;
  91538. private _fogEnabled;
  91539. /**
  91540. * Gets or sets a boolean indicating if fog is enabled on this scene
  91541. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91542. * (Default is true)
  91543. */
  91544. fogEnabled: boolean;
  91545. private _fogMode;
  91546. /**
  91547. * Gets or sets the fog mode to use
  91548. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91549. * | mode | value |
  91550. * | --- | --- |
  91551. * | FOGMODE_NONE | 0 |
  91552. * | FOGMODE_EXP | 1 |
  91553. * | FOGMODE_EXP2 | 2 |
  91554. * | FOGMODE_LINEAR | 3 |
  91555. */
  91556. fogMode: number;
  91557. /**
  91558. * Gets or sets the fog color to use
  91559. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91560. * (Default is Color3(0.2, 0.2, 0.3))
  91561. */
  91562. fogColor: Color3;
  91563. /**
  91564. * Gets or sets the fog density to use
  91565. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91566. * (Default is 0.1)
  91567. */
  91568. fogDensity: number;
  91569. /**
  91570. * Gets or sets the fog start distance to use
  91571. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91572. * (Default is 0)
  91573. */
  91574. fogStart: number;
  91575. /**
  91576. * Gets or sets the fog end distance to use
  91577. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91578. * (Default is 1000)
  91579. */
  91580. fogEnd: number;
  91581. private _shadowsEnabled;
  91582. /**
  91583. * Gets or sets a boolean indicating if shadows are enabled on this scene
  91584. */
  91585. shadowsEnabled: boolean;
  91586. private _lightsEnabled;
  91587. /**
  91588. * Gets or sets a boolean indicating if lights are enabled on this scene
  91589. */
  91590. lightsEnabled: boolean;
  91591. /** All of the active cameras added to this scene. */
  91592. activeCameras: Camera[];
  91593. /** @hidden */
  91594. _activeCamera: Nullable<Camera>;
  91595. /** Gets or sets the current active camera */
  91596. activeCamera: Nullable<Camera>;
  91597. private _defaultMaterial;
  91598. /** The default material used on meshes when no material is affected */
  91599. /** The default material used on meshes when no material is affected */
  91600. defaultMaterial: Material;
  91601. private _texturesEnabled;
  91602. /**
  91603. * Gets or sets a boolean indicating if textures are enabled on this scene
  91604. */
  91605. texturesEnabled: boolean;
  91606. /**
  91607. * Gets or sets a boolean indicating if particles are enabled on this scene
  91608. */
  91609. particlesEnabled: boolean;
  91610. /**
  91611. * Gets or sets a boolean indicating if sprites are enabled on this scene
  91612. */
  91613. spritesEnabled: boolean;
  91614. private _skeletonsEnabled;
  91615. /**
  91616. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  91617. */
  91618. skeletonsEnabled: boolean;
  91619. /**
  91620. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  91621. */
  91622. lensFlaresEnabled: boolean;
  91623. /**
  91624. * Gets or sets a boolean indicating if collisions are enabled on this scene
  91625. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91626. */
  91627. collisionsEnabled: boolean;
  91628. private _collisionCoordinator;
  91629. /** @hidden */
  91630. readonly collisionCoordinator: ICollisionCoordinator;
  91631. /**
  91632. * Defines the gravity applied to this scene (used only for collisions)
  91633. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91634. */
  91635. gravity: Vector3;
  91636. /**
  91637. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  91638. */
  91639. postProcessesEnabled: boolean;
  91640. /**
  91641. * The list of postprocesses added to the scene
  91642. */
  91643. postProcesses: PostProcess[];
  91644. /**
  91645. * Gets the current postprocess manager
  91646. */
  91647. postProcessManager: PostProcessManager;
  91648. /**
  91649. * Gets or sets a boolean indicating if render targets are enabled on this scene
  91650. */
  91651. renderTargetsEnabled: boolean;
  91652. /**
  91653. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  91654. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  91655. */
  91656. dumpNextRenderTargets: boolean;
  91657. /**
  91658. * The list of user defined render targets added to the scene
  91659. */
  91660. customRenderTargets: RenderTargetTexture[];
  91661. /**
  91662. * Defines if texture loading must be delayed
  91663. * If true, textures will only be loaded when they need to be rendered
  91664. */
  91665. useDelayedTextureLoading: boolean;
  91666. /**
  91667. * Gets the list of meshes imported to the scene through SceneLoader
  91668. */
  91669. importedMeshesFiles: String[];
  91670. /**
  91671. * Gets or sets a boolean indicating if probes are enabled on this scene
  91672. */
  91673. probesEnabled: boolean;
  91674. /**
  91675. * Gets or sets the current offline provider to use to store scene data
  91676. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  91677. */
  91678. offlineProvider: IOfflineProvider;
  91679. /**
  91680. * Gets or sets the action manager associated with the scene
  91681. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91682. */
  91683. actionManager: AbstractActionManager;
  91684. private _meshesForIntersections;
  91685. /**
  91686. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  91687. */
  91688. proceduralTexturesEnabled: boolean;
  91689. private _engine;
  91690. private _totalVertices;
  91691. /** @hidden */
  91692. _activeIndices: PerfCounter;
  91693. /** @hidden */
  91694. _activeParticles: PerfCounter;
  91695. /** @hidden */
  91696. _activeBones: PerfCounter;
  91697. private _animationRatio;
  91698. /** @hidden */
  91699. _animationTimeLast: number;
  91700. /** @hidden */
  91701. _animationTime: number;
  91702. /**
  91703. * Gets or sets a general scale for animation speed
  91704. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  91705. */
  91706. animationTimeScale: number;
  91707. /** @hidden */
  91708. _cachedMaterial: Nullable<Material>;
  91709. /** @hidden */
  91710. _cachedEffect: Nullable<Effect>;
  91711. /** @hidden */
  91712. _cachedVisibility: Nullable<number>;
  91713. private _renderId;
  91714. private _frameId;
  91715. private _executeWhenReadyTimeoutId;
  91716. private _intermediateRendering;
  91717. private _viewUpdateFlag;
  91718. private _projectionUpdateFlag;
  91719. /** @hidden */
  91720. _toBeDisposed: Nullable<IDisposable>[];
  91721. private _activeRequests;
  91722. /** @hidden */
  91723. _pendingData: any[];
  91724. private _isDisposed;
  91725. /**
  91726. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  91727. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  91728. */
  91729. dispatchAllSubMeshesOfActiveMeshes: boolean;
  91730. private _activeMeshes;
  91731. private _processedMaterials;
  91732. private _renderTargets;
  91733. /** @hidden */
  91734. _activeParticleSystems: SmartArray<IParticleSystem>;
  91735. private _activeSkeletons;
  91736. private _softwareSkinnedMeshes;
  91737. private _renderingManager;
  91738. /** @hidden */
  91739. _activeAnimatables: Animatable[];
  91740. private _transformMatrix;
  91741. private _sceneUbo;
  91742. /** @hidden */
  91743. _viewMatrix: Matrix;
  91744. private _projectionMatrix;
  91745. private _wheelEventName;
  91746. /** @hidden */
  91747. _forcedViewPosition: Nullable<Vector3>;
  91748. /** @hidden */
  91749. _frustumPlanes: Plane[];
  91750. /**
  91751. * Gets the list of frustum planes (built from the active camera)
  91752. */
  91753. readonly frustumPlanes: Plane[];
  91754. /**
  91755. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  91756. * This is useful if there are more lights that the maximum simulteanous authorized
  91757. */
  91758. requireLightSorting: boolean;
  91759. /** @hidden */
  91760. readonly useMaterialMeshMap: boolean;
  91761. /** @hidden */
  91762. readonly useClonedMeshhMap: boolean;
  91763. private _pointerOverMesh;
  91764. private _pickedDownMesh;
  91765. private _pickedUpMesh;
  91766. private _externalData;
  91767. private _uid;
  91768. /**
  91769. * @hidden
  91770. * Backing store of defined scene components.
  91771. */
  91772. _components: ISceneComponent[];
  91773. /**
  91774. * @hidden
  91775. * Backing store of defined scene components.
  91776. */
  91777. _serializableComponents: ISceneSerializableComponent[];
  91778. /**
  91779. * List of components to register on the next registration step.
  91780. */
  91781. private _transientComponents;
  91782. /**
  91783. * Registers the transient components if needed.
  91784. */
  91785. private _registerTransientComponents;
  91786. /**
  91787. * @hidden
  91788. * Add a component to the scene.
  91789. * Note that the ccomponent could be registered on th next frame if this is called after
  91790. * the register component stage.
  91791. * @param component Defines the component to add to the scene
  91792. */
  91793. _addComponent(component: ISceneComponent): void;
  91794. /**
  91795. * @hidden
  91796. * Gets a component from the scene.
  91797. * @param name defines the name of the component to retrieve
  91798. * @returns the component or null if not present
  91799. */
  91800. _getComponent(name: string): Nullable<ISceneComponent>;
  91801. /**
  91802. * @hidden
  91803. * Defines the actions happening before camera updates.
  91804. */
  91805. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  91806. /**
  91807. * @hidden
  91808. * Defines the actions happening before clear the canvas.
  91809. */
  91810. _beforeClearStage: Stage<SimpleStageAction>;
  91811. /**
  91812. * @hidden
  91813. * Defines the actions when collecting render targets for the frame.
  91814. */
  91815. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  91816. /**
  91817. * @hidden
  91818. * Defines the actions happening for one camera in the frame.
  91819. */
  91820. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  91821. /**
  91822. * @hidden
  91823. * Defines the actions happening during the per mesh ready checks.
  91824. */
  91825. _isReadyForMeshStage: Stage<MeshStageAction>;
  91826. /**
  91827. * @hidden
  91828. * Defines the actions happening before evaluate active mesh checks.
  91829. */
  91830. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  91831. /**
  91832. * @hidden
  91833. * Defines the actions happening during the evaluate sub mesh checks.
  91834. */
  91835. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  91836. /**
  91837. * @hidden
  91838. * Defines the actions happening during the active mesh stage.
  91839. */
  91840. _activeMeshStage: Stage<ActiveMeshStageAction>;
  91841. /**
  91842. * @hidden
  91843. * Defines the actions happening during the per camera render target step.
  91844. */
  91845. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  91846. /**
  91847. * @hidden
  91848. * Defines the actions happening just before the active camera is drawing.
  91849. */
  91850. _beforeCameraDrawStage: Stage<CameraStageAction>;
  91851. /**
  91852. * @hidden
  91853. * Defines the actions happening just before a render target is drawing.
  91854. */
  91855. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  91856. /**
  91857. * @hidden
  91858. * Defines the actions happening just before a rendering group is drawing.
  91859. */
  91860. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  91861. /**
  91862. * @hidden
  91863. * Defines the actions happening just before a mesh is drawing.
  91864. */
  91865. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  91866. /**
  91867. * @hidden
  91868. * Defines the actions happening just after a mesh has been drawn.
  91869. */
  91870. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  91871. /**
  91872. * @hidden
  91873. * Defines the actions happening just after a rendering group has been drawn.
  91874. */
  91875. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  91876. /**
  91877. * @hidden
  91878. * Defines the actions happening just after the active camera has been drawn.
  91879. */
  91880. _afterCameraDrawStage: Stage<CameraStageAction>;
  91881. /**
  91882. * @hidden
  91883. * Defines the actions happening just after a render target has been drawn.
  91884. */
  91885. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  91886. /**
  91887. * @hidden
  91888. * Defines the actions happening just after rendering all cameras and computing intersections.
  91889. */
  91890. _afterRenderStage: Stage<SimpleStageAction>;
  91891. /**
  91892. * @hidden
  91893. * Defines the actions happening when a pointer move event happens.
  91894. */
  91895. _pointerMoveStage: Stage<PointerMoveStageAction>;
  91896. /**
  91897. * @hidden
  91898. * Defines the actions happening when a pointer down event happens.
  91899. */
  91900. _pointerDownStage: Stage<PointerUpDownStageAction>;
  91901. /**
  91902. * @hidden
  91903. * Defines the actions happening when a pointer up event happens.
  91904. */
  91905. _pointerUpStage: Stage<PointerUpDownStageAction>;
  91906. /**
  91907. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  91908. */
  91909. private geometriesByUniqueId;
  91910. /**
  91911. * Creates a new Scene
  91912. * @param engine defines the engine to use to render this scene
  91913. * @param options defines the scene options
  91914. */
  91915. constructor(engine: Engine, options?: SceneOptions);
  91916. /**
  91917. * Gets a string idenfifying the name of the class
  91918. * @returns "Scene" string
  91919. */
  91920. getClassName(): string;
  91921. private _defaultMeshCandidates;
  91922. /**
  91923. * @hidden
  91924. */
  91925. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  91926. private _defaultSubMeshCandidates;
  91927. /**
  91928. * @hidden
  91929. */
  91930. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  91931. /**
  91932. * Sets the default candidate providers for the scene.
  91933. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  91934. * and getCollidingSubMeshCandidates to their default function
  91935. */
  91936. setDefaultCandidateProviders(): void;
  91937. /**
  91938. * Gets the mesh that is currently under the pointer
  91939. */
  91940. readonly meshUnderPointer: Nullable<AbstractMesh>;
  91941. /**
  91942. * Gets or sets the current on-screen X position of the pointer
  91943. */
  91944. pointerX: number;
  91945. /**
  91946. * Gets or sets the current on-screen Y position of the pointer
  91947. */
  91948. pointerY: number;
  91949. /**
  91950. * Gets the cached material (ie. the latest rendered one)
  91951. * @returns the cached material
  91952. */
  91953. getCachedMaterial(): Nullable<Material>;
  91954. /**
  91955. * Gets the cached effect (ie. the latest rendered one)
  91956. * @returns the cached effect
  91957. */
  91958. getCachedEffect(): Nullable<Effect>;
  91959. /**
  91960. * Gets the cached visibility state (ie. the latest rendered one)
  91961. * @returns the cached visibility state
  91962. */
  91963. getCachedVisibility(): Nullable<number>;
  91964. /**
  91965. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  91966. * @param material defines the current material
  91967. * @param effect defines the current effect
  91968. * @param visibility defines the current visibility state
  91969. * @returns true if one parameter is not cached
  91970. */
  91971. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  91972. /**
  91973. * Gets the engine associated with the scene
  91974. * @returns an Engine
  91975. */
  91976. getEngine(): Engine;
  91977. /**
  91978. * Gets the total number of vertices rendered per frame
  91979. * @returns the total number of vertices rendered per frame
  91980. */
  91981. getTotalVertices(): number;
  91982. /**
  91983. * Gets the performance counter for total vertices
  91984. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  91985. */
  91986. readonly totalVerticesPerfCounter: PerfCounter;
  91987. /**
  91988. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  91989. * @returns the total number of active indices rendered per frame
  91990. */
  91991. getActiveIndices(): number;
  91992. /**
  91993. * Gets the performance counter for active indices
  91994. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  91995. */
  91996. readonly totalActiveIndicesPerfCounter: PerfCounter;
  91997. /**
  91998. * Gets the total number of active particles rendered per frame
  91999. * @returns the total number of active particles rendered per frame
  92000. */
  92001. getActiveParticles(): number;
  92002. /**
  92003. * Gets the performance counter for active particles
  92004. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92005. */
  92006. readonly activeParticlesPerfCounter: PerfCounter;
  92007. /**
  92008. * Gets the total number of active bones rendered per frame
  92009. * @returns the total number of active bones rendered per frame
  92010. */
  92011. getActiveBones(): number;
  92012. /**
  92013. * Gets the performance counter for active bones
  92014. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92015. */
  92016. readonly activeBonesPerfCounter: PerfCounter;
  92017. /**
  92018. * Gets the array of active meshes
  92019. * @returns an array of AbstractMesh
  92020. */
  92021. getActiveMeshes(): SmartArray<AbstractMesh>;
  92022. /**
  92023. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  92024. * @returns a number
  92025. */
  92026. getAnimationRatio(): number;
  92027. /**
  92028. * Gets an unique Id for the current render phase
  92029. * @returns a number
  92030. */
  92031. getRenderId(): number;
  92032. /**
  92033. * Gets an unique Id for the current frame
  92034. * @returns a number
  92035. */
  92036. getFrameId(): number;
  92037. /** Call this function if you want to manually increment the render Id*/
  92038. incrementRenderId(): void;
  92039. private _updatePointerPosition;
  92040. private _createUbo;
  92041. private _setRayOnPointerInfo;
  92042. /**
  92043. * Use this method to simulate a pointer move on a mesh
  92044. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92045. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92046. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92047. * @returns the current scene
  92048. */
  92049. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  92050. private _processPointerMove;
  92051. private _checkPrePointerObservable;
  92052. /**
  92053. * Use this method to simulate a pointer down on a mesh
  92054. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92055. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92056. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92057. * @returns the current scene
  92058. */
  92059. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  92060. private _processPointerDown;
  92061. /**
  92062. * Use this method to simulate a pointer up on a mesh
  92063. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92064. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92065. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92066. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  92067. * @returns the current scene
  92068. */
  92069. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  92070. private _processPointerUp;
  92071. /**
  92072. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  92073. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  92074. * @returns true if the pointer was captured
  92075. */
  92076. isPointerCaptured(pointerId?: number): boolean;
  92077. /** @hidden */
  92078. _isPointerSwiping(): boolean;
  92079. /**
  92080. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  92081. * @param attachUp defines if you want to attach events to pointerup
  92082. * @param attachDown defines if you want to attach events to pointerdown
  92083. * @param attachMove defines if you want to attach events to pointermove
  92084. */
  92085. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  92086. /** Detaches all event handlers*/
  92087. detachControl(): void;
  92088. /**
  92089. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  92090. * Delay loaded resources are not taking in account
  92091. * @return true if all required resources are ready
  92092. */
  92093. isReady(): boolean;
  92094. /** Resets all cached information relative to material (including effect and visibility) */
  92095. resetCachedMaterial(): void;
  92096. /**
  92097. * Registers a function to be called before every frame render
  92098. * @param func defines the function to register
  92099. */
  92100. registerBeforeRender(func: () => void): void;
  92101. /**
  92102. * Unregisters a function called before every frame render
  92103. * @param func defines the function to unregister
  92104. */
  92105. unregisterBeforeRender(func: () => void): void;
  92106. /**
  92107. * Registers a function to be called after every frame render
  92108. * @param func defines the function to register
  92109. */
  92110. registerAfterRender(func: () => void): void;
  92111. /**
  92112. * Unregisters a function called after every frame render
  92113. * @param func defines the function to unregister
  92114. */
  92115. unregisterAfterRender(func: () => void): void;
  92116. private _executeOnceBeforeRender;
  92117. /**
  92118. * The provided function will run before render once and will be disposed afterwards.
  92119. * A timeout delay can be provided so that the function will be executed in N ms.
  92120. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  92121. * @param func The function to be executed.
  92122. * @param timeout optional delay in ms
  92123. */
  92124. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  92125. /** @hidden */
  92126. _addPendingData(data: any): void;
  92127. /** @hidden */
  92128. _removePendingData(data: any): void;
  92129. /**
  92130. * Returns the number of items waiting to be loaded
  92131. * @returns the number of items waiting to be loaded
  92132. */
  92133. getWaitingItemsCount(): number;
  92134. /**
  92135. * Returns a boolean indicating if the scene is still loading data
  92136. */
  92137. readonly isLoading: boolean;
  92138. /**
  92139. * Registers a function to be executed when the scene is ready
  92140. * @param {Function} func - the function to be executed
  92141. */
  92142. executeWhenReady(func: () => void): void;
  92143. /**
  92144. * Returns a promise that resolves when the scene is ready
  92145. * @returns A promise that resolves when the scene is ready
  92146. */
  92147. whenReadyAsync(): Promise<void>;
  92148. /** @hidden */
  92149. _checkIsReady(): void;
  92150. /**
  92151. * Gets all animatable attached to the scene
  92152. */
  92153. readonly animatables: Animatable[];
  92154. /**
  92155. * Resets the last animation time frame.
  92156. * Useful to override when animations start running when loading a scene for the first time.
  92157. */
  92158. resetLastAnimationTimeFrame(): void;
  92159. /**
  92160. * Gets the current view matrix
  92161. * @returns a Matrix
  92162. */
  92163. getViewMatrix(): Matrix;
  92164. /**
  92165. * Gets the current projection matrix
  92166. * @returns a Matrix
  92167. */
  92168. getProjectionMatrix(): Matrix;
  92169. /**
  92170. * Gets the current transform matrix
  92171. * @returns a Matrix made of View * Projection
  92172. */
  92173. getTransformMatrix(): Matrix;
  92174. /**
  92175. * Sets the current transform matrix
  92176. * @param viewL defines the View matrix to use
  92177. * @param projectionL defines the Projection matrix to use
  92178. * @param viewR defines the right View matrix to use (if provided)
  92179. * @param projectionR defines the right Projection matrix to use (if provided)
  92180. */
  92181. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  92182. /**
  92183. * Gets the uniform buffer used to store scene data
  92184. * @returns a UniformBuffer
  92185. */
  92186. getSceneUniformBuffer(): UniformBuffer;
  92187. /**
  92188. * Gets an unique (relatively to the current scene) Id
  92189. * @returns an unique number for the scene
  92190. */
  92191. getUniqueId(): number;
  92192. /**
  92193. * Add a mesh to the list of scene's meshes
  92194. * @param newMesh defines the mesh to add
  92195. * @param recursive if all child meshes should also be added to the scene
  92196. */
  92197. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  92198. /**
  92199. * Remove a mesh for the list of scene's meshes
  92200. * @param toRemove defines the mesh to remove
  92201. * @param recursive if all child meshes should also be removed from the scene
  92202. * @returns the index where the mesh was in the mesh list
  92203. */
  92204. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  92205. /**
  92206. * Add a transform node to the list of scene's transform nodes
  92207. * @param newTransformNode defines the transform node to add
  92208. */
  92209. addTransformNode(newTransformNode: TransformNode): void;
  92210. /**
  92211. * Remove a transform node for the list of scene's transform nodes
  92212. * @param toRemove defines the transform node to remove
  92213. * @returns the index where the transform node was in the transform node list
  92214. */
  92215. removeTransformNode(toRemove: TransformNode): number;
  92216. /**
  92217. * Remove a skeleton for the list of scene's skeletons
  92218. * @param toRemove defines the skeleton to remove
  92219. * @returns the index where the skeleton was in the skeleton list
  92220. */
  92221. removeSkeleton(toRemove: Skeleton): number;
  92222. /**
  92223. * Remove a morph target for the list of scene's morph targets
  92224. * @param toRemove defines the morph target to remove
  92225. * @returns the index where the morph target was in the morph target list
  92226. */
  92227. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  92228. /**
  92229. * Remove a light for the list of scene's lights
  92230. * @param toRemove defines the light to remove
  92231. * @returns the index where the light was in the light list
  92232. */
  92233. removeLight(toRemove: Light): number;
  92234. /**
  92235. * Remove a camera for the list of scene's cameras
  92236. * @param toRemove defines the camera to remove
  92237. * @returns the index where the camera was in the camera list
  92238. */
  92239. removeCamera(toRemove: Camera): number;
  92240. /**
  92241. * Remove a particle system for the list of scene's particle systems
  92242. * @param toRemove defines the particle system to remove
  92243. * @returns the index where the particle system was in the particle system list
  92244. */
  92245. removeParticleSystem(toRemove: IParticleSystem): number;
  92246. /**
  92247. * Remove a animation for the list of scene's animations
  92248. * @param toRemove defines the animation to remove
  92249. * @returns the index where the animation was in the animation list
  92250. */
  92251. removeAnimation(toRemove: Animation): number;
  92252. /**
  92253. * Removes the given animation group from this scene.
  92254. * @param toRemove The animation group to remove
  92255. * @returns The index of the removed animation group
  92256. */
  92257. removeAnimationGroup(toRemove: AnimationGroup): number;
  92258. /**
  92259. * Removes the given multi-material from this scene.
  92260. * @param toRemove The multi-material to remove
  92261. * @returns The index of the removed multi-material
  92262. */
  92263. removeMultiMaterial(toRemove: MultiMaterial): number;
  92264. /**
  92265. * Removes the given material from this scene.
  92266. * @param toRemove The material to remove
  92267. * @returns The index of the removed material
  92268. */
  92269. removeMaterial(toRemove: Material): number;
  92270. /**
  92271. * Removes the given action manager from this scene.
  92272. * @param toRemove The action manager to remove
  92273. * @returns The index of the removed action manager
  92274. */
  92275. removeActionManager(toRemove: AbstractActionManager): number;
  92276. /**
  92277. * Removes the given texture from this scene.
  92278. * @param toRemove The texture to remove
  92279. * @returns The index of the removed texture
  92280. */
  92281. removeTexture(toRemove: BaseTexture): number;
  92282. /**
  92283. * Adds the given light to this scene
  92284. * @param newLight The light to add
  92285. */
  92286. addLight(newLight: Light): void;
  92287. /**
  92288. * Sorts the list list based on light priorities
  92289. */
  92290. sortLightsByPriority(): void;
  92291. /**
  92292. * Adds the given camera to this scene
  92293. * @param newCamera The camera to add
  92294. */
  92295. addCamera(newCamera: Camera): void;
  92296. /**
  92297. * Adds the given skeleton to this scene
  92298. * @param newSkeleton The skeleton to add
  92299. */
  92300. addSkeleton(newSkeleton: Skeleton): void;
  92301. /**
  92302. * Adds the given particle system to this scene
  92303. * @param newParticleSystem The particle system to add
  92304. */
  92305. addParticleSystem(newParticleSystem: IParticleSystem): void;
  92306. /**
  92307. * Adds the given animation to this scene
  92308. * @param newAnimation The animation to add
  92309. */
  92310. addAnimation(newAnimation: Animation): void;
  92311. /**
  92312. * Adds the given animation group to this scene.
  92313. * @param newAnimationGroup The animation group to add
  92314. */
  92315. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  92316. /**
  92317. * Adds the given multi-material to this scene
  92318. * @param newMultiMaterial The multi-material to add
  92319. */
  92320. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  92321. /**
  92322. * Adds the given material to this scene
  92323. * @param newMaterial The material to add
  92324. */
  92325. addMaterial(newMaterial: Material): void;
  92326. /**
  92327. * Adds the given morph target to this scene
  92328. * @param newMorphTargetManager The morph target to add
  92329. */
  92330. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  92331. /**
  92332. * Adds the given geometry to this scene
  92333. * @param newGeometry The geometry to add
  92334. */
  92335. addGeometry(newGeometry: Geometry): void;
  92336. /**
  92337. * Adds the given action manager to this scene
  92338. * @param newActionManager The action manager to add
  92339. */
  92340. addActionManager(newActionManager: AbstractActionManager): void;
  92341. /**
  92342. * Adds the given texture to this scene.
  92343. * @param newTexture The texture to add
  92344. */
  92345. addTexture(newTexture: BaseTexture): void;
  92346. /**
  92347. * Switch active camera
  92348. * @param newCamera defines the new active camera
  92349. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  92350. */
  92351. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  92352. /**
  92353. * sets the active camera of the scene using its ID
  92354. * @param id defines the camera's ID
  92355. * @return the new active camera or null if none found.
  92356. */
  92357. setActiveCameraByID(id: string): Nullable<Camera>;
  92358. /**
  92359. * sets the active camera of the scene using its name
  92360. * @param name defines the camera's name
  92361. * @returns the new active camera or null if none found.
  92362. */
  92363. setActiveCameraByName(name: string): Nullable<Camera>;
  92364. /**
  92365. * get an animation group using its name
  92366. * @param name defines the material's name
  92367. * @return the animation group or null if none found.
  92368. */
  92369. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  92370. /**
  92371. * Get a material using its unique id
  92372. * @param uniqueId defines the material's unique id
  92373. * @return the material or null if none found.
  92374. */
  92375. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  92376. /**
  92377. * get a material using its id
  92378. * @param id defines the material's ID
  92379. * @return the material or null if none found.
  92380. */
  92381. getMaterialByID(id: string): Nullable<Material>;
  92382. /**
  92383. * Gets a material using its name
  92384. * @param name defines the material's name
  92385. * @return the material or null if none found.
  92386. */
  92387. getMaterialByName(name: string): Nullable<Material>;
  92388. /**
  92389. * Gets a camera using its id
  92390. * @param id defines the id to look for
  92391. * @returns the camera or null if not found
  92392. */
  92393. getCameraByID(id: string): Nullable<Camera>;
  92394. /**
  92395. * Gets a camera using its unique id
  92396. * @param uniqueId defines the unique id to look for
  92397. * @returns the camera or null if not found
  92398. */
  92399. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  92400. /**
  92401. * Gets a camera using its name
  92402. * @param name defines the camera's name
  92403. * @return the camera or null if none found.
  92404. */
  92405. getCameraByName(name: string): Nullable<Camera>;
  92406. /**
  92407. * Gets a bone using its id
  92408. * @param id defines the bone's id
  92409. * @return the bone or null if not found
  92410. */
  92411. getBoneByID(id: string): Nullable<Bone>;
  92412. /**
  92413. * Gets a bone using its id
  92414. * @param name defines the bone's name
  92415. * @return the bone or null if not found
  92416. */
  92417. getBoneByName(name: string): Nullable<Bone>;
  92418. /**
  92419. * Gets a light node using its name
  92420. * @param name defines the the light's name
  92421. * @return the light or null if none found.
  92422. */
  92423. getLightByName(name: string): Nullable<Light>;
  92424. /**
  92425. * Gets a light node using its id
  92426. * @param id defines the light's id
  92427. * @return the light or null if none found.
  92428. */
  92429. getLightByID(id: string): Nullable<Light>;
  92430. /**
  92431. * Gets a light node using its scene-generated unique ID
  92432. * @param uniqueId defines the light's unique id
  92433. * @return the light or null if none found.
  92434. */
  92435. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  92436. /**
  92437. * Gets a particle system by id
  92438. * @param id defines the particle system id
  92439. * @return the corresponding system or null if none found
  92440. */
  92441. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  92442. /**
  92443. * Gets a geometry using its ID
  92444. * @param id defines the geometry's id
  92445. * @return the geometry or null if none found.
  92446. */
  92447. getGeometryByID(id: string): Nullable<Geometry>;
  92448. private _getGeometryByUniqueID;
  92449. /**
  92450. * Add a new geometry to this scene
  92451. * @param geometry defines the geometry to be added to the scene.
  92452. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  92453. * @return a boolean defining if the geometry was added or not
  92454. */
  92455. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  92456. /**
  92457. * Removes an existing geometry
  92458. * @param geometry defines the geometry to be removed from the scene
  92459. * @return a boolean defining if the geometry was removed or not
  92460. */
  92461. removeGeometry(geometry: Geometry): boolean;
  92462. /**
  92463. * Gets the list of geometries attached to the scene
  92464. * @returns an array of Geometry
  92465. */
  92466. getGeometries(): Geometry[];
  92467. /**
  92468. * Gets the first added mesh found of a given ID
  92469. * @param id defines the id to search for
  92470. * @return the mesh found or null if not found at all
  92471. */
  92472. getMeshByID(id: string): Nullable<AbstractMesh>;
  92473. /**
  92474. * Gets a list of meshes using their id
  92475. * @param id defines the id to search for
  92476. * @returns a list of meshes
  92477. */
  92478. getMeshesByID(id: string): Array<AbstractMesh>;
  92479. /**
  92480. * Gets the first added transform node found of a given ID
  92481. * @param id defines the id to search for
  92482. * @return the found transform node or null if not found at all.
  92483. */
  92484. getTransformNodeByID(id: string): Nullable<TransformNode>;
  92485. /**
  92486. * Gets a transform node with its auto-generated unique id
  92487. * @param uniqueId efines the unique id to search for
  92488. * @return the found transform node or null if not found at all.
  92489. */
  92490. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  92491. /**
  92492. * Gets a list of transform nodes using their id
  92493. * @param id defines the id to search for
  92494. * @returns a list of transform nodes
  92495. */
  92496. getTransformNodesByID(id: string): Array<TransformNode>;
  92497. /**
  92498. * Gets a mesh with its auto-generated unique id
  92499. * @param uniqueId defines the unique id to search for
  92500. * @return the found mesh or null if not found at all.
  92501. */
  92502. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  92503. /**
  92504. * Gets a the last added mesh using a given id
  92505. * @param id defines the id to search for
  92506. * @return the found mesh or null if not found at all.
  92507. */
  92508. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  92509. /**
  92510. * Gets a the last added node (Mesh, Camera, Light) using a given id
  92511. * @param id defines the id to search for
  92512. * @return the found node or null if not found at all
  92513. */
  92514. getLastEntryByID(id: string): Nullable<Node>;
  92515. /**
  92516. * Gets a node (Mesh, Camera, Light) using a given id
  92517. * @param id defines the id to search for
  92518. * @return the found node or null if not found at all
  92519. */
  92520. getNodeByID(id: string): Nullable<Node>;
  92521. /**
  92522. * Gets a node (Mesh, Camera, Light) using a given name
  92523. * @param name defines the name to search for
  92524. * @return the found node or null if not found at all.
  92525. */
  92526. getNodeByName(name: string): Nullable<Node>;
  92527. /**
  92528. * Gets a mesh using a given name
  92529. * @param name defines the name to search for
  92530. * @return the found mesh or null if not found at all.
  92531. */
  92532. getMeshByName(name: string): Nullable<AbstractMesh>;
  92533. /**
  92534. * Gets a transform node using a given name
  92535. * @param name defines the name to search for
  92536. * @return the found transform node or null if not found at all.
  92537. */
  92538. getTransformNodeByName(name: string): Nullable<TransformNode>;
  92539. /**
  92540. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  92541. * @param id defines the id to search for
  92542. * @return the found skeleton or null if not found at all.
  92543. */
  92544. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  92545. /**
  92546. * Gets a skeleton using a given auto generated unique id
  92547. * @param uniqueId defines the unique id to search for
  92548. * @return the found skeleton or null if not found at all.
  92549. */
  92550. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  92551. /**
  92552. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  92553. * @param id defines the id to search for
  92554. * @return the found skeleton or null if not found at all.
  92555. */
  92556. getSkeletonById(id: string): Nullable<Skeleton>;
  92557. /**
  92558. * Gets a skeleton using a given name
  92559. * @param name defines the name to search for
  92560. * @return the found skeleton or null if not found at all.
  92561. */
  92562. getSkeletonByName(name: string): Nullable<Skeleton>;
  92563. /**
  92564. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  92565. * @param id defines the id to search for
  92566. * @return the found morph target manager or null if not found at all.
  92567. */
  92568. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  92569. /**
  92570. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  92571. * @param id defines the id to search for
  92572. * @return the found morph target or null if not found at all.
  92573. */
  92574. getMorphTargetById(id: string): Nullable<MorphTarget>;
  92575. /**
  92576. * Gets a boolean indicating if the given mesh is active
  92577. * @param mesh defines the mesh to look for
  92578. * @returns true if the mesh is in the active list
  92579. */
  92580. isActiveMesh(mesh: AbstractMesh): boolean;
  92581. /**
  92582. * Return a unique id as a string which can serve as an identifier for the scene
  92583. */
  92584. readonly uid: string;
  92585. /**
  92586. * Add an externaly attached data from its key.
  92587. * This method call will fail and return false, if such key already exists.
  92588. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  92589. * @param key the unique key that identifies the data
  92590. * @param data the data object to associate to the key for this Engine instance
  92591. * @return true if no such key were already present and the data was added successfully, false otherwise
  92592. */
  92593. addExternalData<T>(key: string, data: T): boolean;
  92594. /**
  92595. * Get an externaly attached data from its key
  92596. * @param key the unique key that identifies the data
  92597. * @return the associated data, if present (can be null), or undefined if not present
  92598. */
  92599. getExternalData<T>(key: string): Nullable<T>;
  92600. /**
  92601. * Get an externaly attached data from its key, create it using a factory if it's not already present
  92602. * @param key the unique key that identifies the data
  92603. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  92604. * @return the associated data, can be null if the factory returned null.
  92605. */
  92606. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  92607. /**
  92608. * Remove an externaly attached data from the Engine instance
  92609. * @param key the unique key that identifies the data
  92610. * @return true if the data was successfully removed, false if it doesn't exist
  92611. */
  92612. removeExternalData(key: string): boolean;
  92613. private _evaluateSubMesh;
  92614. /**
  92615. * Clear the processed materials smart array preventing retention point in material dispose.
  92616. */
  92617. freeProcessedMaterials(): void;
  92618. private _preventFreeActiveMeshesAndRenderingGroups;
  92619. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  92620. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  92621. * when disposing several meshes in a row or a hierarchy of meshes.
  92622. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  92623. */
  92624. blockfreeActiveMeshesAndRenderingGroups: boolean;
  92625. /**
  92626. * Clear the active meshes smart array preventing retention point in mesh dispose.
  92627. */
  92628. freeActiveMeshes(): void;
  92629. /**
  92630. * Clear the info related to rendering groups preventing retention points during dispose.
  92631. */
  92632. freeRenderingGroups(): void;
  92633. /** @hidden */
  92634. _isInIntermediateRendering(): boolean;
  92635. /**
  92636. * Lambda returning the list of potentially active meshes.
  92637. */
  92638. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  92639. /**
  92640. * Lambda returning the list of potentially active sub meshes.
  92641. */
  92642. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  92643. /**
  92644. * Lambda returning the list of potentially intersecting sub meshes.
  92645. */
  92646. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  92647. /**
  92648. * Lambda returning the list of potentially colliding sub meshes.
  92649. */
  92650. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  92651. private _activeMeshesFrozen;
  92652. /**
  92653. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  92654. * @returns the current scene
  92655. */
  92656. freezeActiveMeshes(): Scene;
  92657. /**
  92658. * Use this function to restart evaluating active meshes on every frame
  92659. * @returns the current scene
  92660. */
  92661. unfreezeActiveMeshes(): Scene;
  92662. private _evaluateActiveMeshes;
  92663. private _activeMesh;
  92664. /**
  92665. * Update the transform matrix to update from the current active camera
  92666. * @param force defines a boolean used to force the update even if cache is up to date
  92667. */
  92668. updateTransformMatrix(force?: boolean): void;
  92669. private _bindFrameBuffer;
  92670. /** @hidden */
  92671. _allowPostProcessClearColor: boolean;
  92672. /** @hidden */
  92673. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  92674. private _processSubCameras;
  92675. private _checkIntersections;
  92676. /** @hidden */
  92677. _advancePhysicsEngineStep(step: number): void;
  92678. /**
  92679. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  92680. */
  92681. getDeterministicFrameTime: () => number;
  92682. /** @hidden */
  92683. _animate(): void;
  92684. /**
  92685. * Render the scene
  92686. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  92687. */
  92688. render(updateCameras?: boolean): void;
  92689. /**
  92690. * Freeze all materials
  92691. * A frozen material will not be updatable but should be faster to render
  92692. */
  92693. freezeMaterials(): void;
  92694. /**
  92695. * Unfreeze all materials
  92696. * A frozen material will not be updatable but should be faster to render
  92697. */
  92698. unfreezeMaterials(): void;
  92699. /**
  92700. * Releases all held ressources
  92701. */
  92702. dispose(): void;
  92703. /**
  92704. * Gets if the scene is already disposed
  92705. */
  92706. readonly isDisposed: boolean;
  92707. /**
  92708. * Call this function to reduce memory footprint of the scene.
  92709. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  92710. */
  92711. clearCachedVertexData(): void;
  92712. /**
  92713. * This function will remove the local cached buffer data from texture.
  92714. * It will save memory but will prevent the texture from being rebuilt
  92715. */
  92716. cleanCachedTextureBuffer(): void;
  92717. /**
  92718. * Get the world extend vectors with an optional filter
  92719. *
  92720. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  92721. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  92722. */
  92723. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  92724. min: Vector3;
  92725. max: Vector3;
  92726. };
  92727. /**
  92728. * Creates a ray that can be used to pick in the scene
  92729. * @param x defines the x coordinate of the origin (on-screen)
  92730. * @param y defines the y coordinate of the origin (on-screen)
  92731. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  92732. * @param camera defines the camera to use for the picking
  92733. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  92734. * @returns a Ray
  92735. */
  92736. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  92737. /**
  92738. * Creates a ray that can be used to pick in the scene
  92739. * @param x defines the x coordinate of the origin (on-screen)
  92740. * @param y defines the y coordinate of the origin (on-screen)
  92741. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  92742. * @param result defines the ray where to store the picking ray
  92743. * @param camera defines the camera to use for the picking
  92744. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  92745. * @returns the current scene
  92746. */
  92747. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  92748. /**
  92749. * Creates a ray that can be used to pick in the scene
  92750. * @param x defines the x coordinate of the origin (on-screen)
  92751. * @param y defines the y coordinate of the origin (on-screen)
  92752. * @param camera defines the camera to use for the picking
  92753. * @returns a Ray
  92754. */
  92755. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  92756. /**
  92757. * Creates a ray that can be used to pick in the scene
  92758. * @param x defines the x coordinate of the origin (on-screen)
  92759. * @param y defines the y coordinate of the origin (on-screen)
  92760. * @param result defines the ray where to store the picking ray
  92761. * @param camera defines the camera to use for the picking
  92762. * @returns the current scene
  92763. */
  92764. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  92765. /** Launch a ray to try to pick a mesh in the scene
  92766. * @param x position on screen
  92767. * @param y position on screen
  92768. * @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
  92769. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  92770. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  92771. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92772. * @returns a PickingInfo
  92773. */
  92774. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  92775. /** Use the given ray to pick a mesh in the scene
  92776. * @param ray The ray to use to pick meshes
  92777. * @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
  92778. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  92779. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92780. * @returns a PickingInfo
  92781. */
  92782. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  92783. /**
  92784. * Launch a ray to try to pick a mesh in the scene
  92785. * @param x X position on screen
  92786. * @param y Y position on screen
  92787. * @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
  92788. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  92789. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92790. * @returns an array of PickingInfo
  92791. */
  92792. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  92793. /**
  92794. * Launch a ray to try to pick a mesh in the scene
  92795. * @param ray Ray to use
  92796. * @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
  92797. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92798. * @returns an array of PickingInfo
  92799. */
  92800. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  92801. /**
  92802. * Force the value of meshUnderPointer
  92803. * @param mesh defines the mesh to use
  92804. */
  92805. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  92806. /**
  92807. * Gets the mesh under the pointer
  92808. * @returns a Mesh or null if no mesh is under the pointer
  92809. */
  92810. getPointerOverMesh(): Nullable<AbstractMesh>;
  92811. /** @hidden */
  92812. _rebuildGeometries(): void;
  92813. /** @hidden */
  92814. _rebuildTextures(): void;
  92815. private _getByTags;
  92816. /**
  92817. * Get a list of meshes by tags
  92818. * @param tagsQuery defines the tags query to use
  92819. * @param forEach defines a predicate used to filter results
  92820. * @returns an array of Mesh
  92821. */
  92822. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  92823. /**
  92824. * Get a list of cameras by tags
  92825. * @param tagsQuery defines the tags query to use
  92826. * @param forEach defines a predicate used to filter results
  92827. * @returns an array of Camera
  92828. */
  92829. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  92830. /**
  92831. * Get a list of lights by tags
  92832. * @param tagsQuery defines the tags query to use
  92833. * @param forEach defines a predicate used to filter results
  92834. * @returns an array of Light
  92835. */
  92836. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  92837. /**
  92838. * Get a list of materials by tags
  92839. * @param tagsQuery defines the tags query to use
  92840. * @param forEach defines a predicate used to filter results
  92841. * @returns an array of Material
  92842. */
  92843. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  92844. /**
  92845. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  92846. * This allowed control for front to back rendering or reversly depending of the special needs.
  92847. *
  92848. * @param renderingGroupId The rendering group id corresponding to its index
  92849. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  92850. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  92851. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  92852. */
  92853. 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;
  92854. /**
  92855. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  92856. *
  92857. * @param renderingGroupId The rendering group id corresponding to its index
  92858. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  92859. * @param depth Automatically clears depth between groups if true and autoClear is true.
  92860. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  92861. */
  92862. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  92863. /**
  92864. * Gets the current auto clear configuration for one rendering group of the rendering
  92865. * manager.
  92866. * @param index the rendering group index to get the information for
  92867. * @returns The auto clear setup for the requested rendering group
  92868. */
  92869. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  92870. private _blockMaterialDirtyMechanism;
  92871. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  92872. blockMaterialDirtyMechanism: boolean;
  92873. /**
  92874. * Will flag all materials as dirty to trigger new shader compilation
  92875. * @param flag defines the flag used to specify which material part must be marked as dirty
  92876. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  92877. */
  92878. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  92879. /** @hidden */
  92880. _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;
  92881. /** @hidden */
  92882. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  92883. }
  92884. }
  92885. declare module BABYLON {
  92886. /**
  92887. * Set of assets to keep when moving a scene into an asset container.
  92888. */
  92889. export class KeepAssets extends AbstractScene {
  92890. }
  92891. /**
  92892. * Container with a set of assets that can be added or removed from a scene.
  92893. */
  92894. export class AssetContainer extends AbstractScene {
  92895. /**
  92896. * The scene the AssetContainer belongs to.
  92897. */
  92898. scene: Scene;
  92899. /**
  92900. * Instantiates an AssetContainer.
  92901. * @param scene The scene the AssetContainer belongs to.
  92902. */
  92903. constructor(scene: Scene);
  92904. /**
  92905. * Adds all the assets from the container to the scene.
  92906. */
  92907. addAllToScene(): void;
  92908. /**
  92909. * Removes all the assets in the container from the scene
  92910. */
  92911. removeAllFromScene(): void;
  92912. /**
  92913. * Disposes all the assets in the container
  92914. */
  92915. dispose(): void;
  92916. private _moveAssets;
  92917. /**
  92918. * Removes all the assets contained in the scene and adds them to the container.
  92919. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  92920. */
  92921. moveAllFromScene(keepAssets?: KeepAssets): void;
  92922. /**
  92923. * 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.
  92924. * @returns the root mesh
  92925. */
  92926. createRootMesh(): Mesh;
  92927. }
  92928. }
  92929. declare module BABYLON {
  92930. /**
  92931. * Defines how the parser contract is defined.
  92932. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  92933. */
  92934. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  92935. /**
  92936. * Defines how the individual parser contract is defined.
  92937. * These parser can parse an individual asset
  92938. */
  92939. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  92940. /**
  92941. * Base class of the scene acting as a container for the different elements composing a scene.
  92942. * This class is dynamically extended by the different components of the scene increasing
  92943. * flexibility and reducing coupling
  92944. */
  92945. export abstract class AbstractScene {
  92946. /**
  92947. * Stores the list of available parsers in the application.
  92948. */
  92949. private static _BabylonFileParsers;
  92950. /**
  92951. * Stores the list of available individual parsers in the application.
  92952. */
  92953. private static _IndividualBabylonFileParsers;
  92954. /**
  92955. * Adds a parser in the list of available ones
  92956. * @param name Defines the name of the parser
  92957. * @param parser Defines the parser to add
  92958. */
  92959. static AddParser(name: string, parser: BabylonFileParser): void;
  92960. /**
  92961. * Gets a general parser from the list of avaialble ones
  92962. * @param name Defines the name of the parser
  92963. * @returns the requested parser or null
  92964. */
  92965. static GetParser(name: string): Nullable<BabylonFileParser>;
  92966. /**
  92967. * Adds n individual parser in the list of available ones
  92968. * @param name Defines the name of the parser
  92969. * @param parser Defines the parser to add
  92970. */
  92971. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  92972. /**
  92973. * Gets an individual parser from the list of avaialble ones
  92974. * @param name Defines the name of the parser
  92975. * @returns the requested parser or null
  92976. */
  92977. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  92978. /**
  92979. * Parser json data and populate both a scene and its associated container object
  92980. * @param jsonData Defines the data to parse
  92981. * @param scene Defines the scene to parse the data for
  92982. * @param container Defines the container attached to the parsing sequence
  92983. * @param rootUrl Defines the root url of the data
  92984. */
  92985. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  92986. /**
  92987. * Gets the list of root nodes (ie. nodes with no parent)
  92988. */
  92989. rootNodes: Node[];
  92990. /** All of the cameras added to this scene
  92991. * @see http://doc.babylonjs.com/babylon101/cameras
  92992. */
  92993. cameras: Camera[];
  92994. /**
  92995. * All of the lights added to this scene
  92996. * @see http://doc.babylonjs.com/babylon101/lights
  92997. */
  92998. lights: Light[];
  92999. /**
  93000. * All of the (abstract) meshes added to this scene
  93001. */
  93002. meshes: AbstractMesh[];
  93003. /**
  93004. * The list of skeletons added to the scene
  93005. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93006. */
  93007. skeletons: Skeleton[];
  93008. /**
  93009. * All of the particle systems added to this scene
  93010. * @see http://doc.babylonjs.com/babylon101/particles
  93011. */
  93012. particleSystems: IParticleSystem[];
  93013. /**
  93014. * Gets a list of Animations associated with the scene
  93015. */
  93016. animations: Animation[];
  93017. /**
  93018. * All of the animation groups added to this scene
  93019. * @see http://doc.babylonjs.com/how_to/group
  93020. */
  93021. animationGroups: AnimationGroup[];
  93022. /**
  93023. * All of the multi-materials added to this scene
  93024. * @see http://doc.babylonjs.com/how_to/multi_materials
  93025. */
  93026. multiMaterials: MultiMaterial[];
  93027. /**
  93028. * All of the materials added to this scene
  93029. * In the context of a Scene, it is not supposed to be modified manually.
  93030. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  93031. * Note also that the order of the Material wihin the array is not significant and might change.
  93032. * @see http://doc.babylonjs.com/babylon101/materials
  93033. */
  93034. materials: Material[];
  93035. /**
  93036. * The list of morph target managers added to the scene
  93037. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  93038. */
  93039. morphTargetManagers: MorphTargetManager[];
  93040. /**
  93041. * The list of geometries used in the scene.
  93042. */
  93043. geometries: Geometry[];
  93044. /**
  93045. * All of the tranform nodes added to this scene
  93046. * In the context of a Scene, it is not supposed to be modified manually.
  93047. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  93048. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  93049. * @see http://doc.babylonjs.com/how_to/transformnode
  93050. */
  93051. transformNodes: TransformNode[];
  93052. /**
  93053. * ActionManagers available on the scene.
  93054. */
  93055. actionManagers: AbstractActionManager[];
  93056. /**
  93057. * Textures to keep.
  93058. */
  93059. textures: BaseTexture[];
  93060. /**
  93061. * Environment texture for the scene
  93062. */
  93063. environmentTexture: Nullable<BaseTexture>;
  93064. }
  93065. }
  93066. declare module BABYLON {
  93067. /**
  93068. * Defines a sound that can be played in the application.
  93069. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  93070. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93071. */
  93072. export class Sound {
  93073. /**
  93074. * The name of the sound in the scene.
  93075. */
  93076. name: string;
  93077. /**
  93078. * Does the sound autoplay once loaded.
  93079. */
  93080. autoplay: boolean;
  93081. /**
  93082. * Does the sound loop after it finishes playing once.
  93083. */
  93084. loop: boolean;
  93085. /**
  93086. * Does the sound use a custom attenuation curve to simulate the falloff
  93087. * happening when the source gets further away from the camera.
  93088. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  93089. */
  93090. useCustomAttenuation: boolean;
  93091. /**
  93092. * The sound track id this sound belongs to.
  93093. */
  93094. soundTrackId: number;
  93095. /**
  93096. * Is this sound currently played.
  93097. */
  93098. isPlaying: boolean;
  93099. /**
  93100. * Is this sound currently paused.
  93101. */
  93102. isPaused: boolean;
  93103. /**
  93104. * Does this sound enables spatial sound.
  93105. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93106. */
  93107. spatialSound: boolean;
  93108. /**
  93109. * Define the reference distance the sound should be heard perfectly.
  93110. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93111. */
  93112. refDistance: number;
  93113. /**
  93114. * Define the roll off factor of spatial sounds.
  93115. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93116. */
  93117. rolloffFactor: number;
  93118. /**
  93119. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  93120. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93121. */
  93122. maxDistance: number;
  93123. /**
  93124. * Define the distance attenuation model the sound will follow.
  93125. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93126. */
  93127. distanceModel: string;
  93128. /**
  93129. * @hidden
  93130. * Back Compat
  93131. **/
  93132. onended: () => any;
  93133. /**
  93134. * Observable event when the current playing sound finishes.
  93135. */
  93136. onEndedObservable: Observable<Sound>;
  93137. private _panningModel;
  93138. private _playbackRate;
  93139. private _streaming;
  93140. private _startTime;
  93141. private _startOffset;
  93142. private _position;
  93143. /** @hidden */
  93144. _positionInEmitterSpace: boolean;
  93145. private _localDirection;
  93146. private _volume;
  93147. private _isReadyToPlay;
  93148. private _isDirectional;
  93149. private _readyToPlayCallback;
  93150. private _audioBuffer;
  93151. private _soundSource;
  93152. private _streamingSource;
  93153. private _soundPanner;
  93154. private _soundGain;
  93155. private _inputAudioNode;
  93156. private _outputAudioNode;
  93157. private _coneInnerAngle;
  93158. private _coneOuterAngle;
  93159. private _coneOuterGain;
  93160. private _scene;
  93161. private _connectedTransformNode;
  93162. private _customAttenuationFunction;
  93163. private _registerFunc;
  93164. private _isOutputConnected;
  93165. private _htmlAudioElement;
  93166. private _urlType;
  93167. /** @hidden */
  93168. static _SceneComponentInitialization: (scene: Scene) => void;
  93169. /**
  93170. * Create a sound and attach it to a scene
  93171. * @param name Name of your sound
  93172. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  93173. * @param scene defines the scene the sound belongs to
  93174. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  93175. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  93176. */
  93177. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  93178. /**
  93179. * Release the sound and its associated resources
  93180. */
  93181. dispose(): void;
  93182. /**
  93183. * Gets if the sounds is ready to be played or not.
  93184. * @returns true if ready, otherwise false
  93185. */
  93186. isReady(): boolean;
  93187. private _soundLoaded;
  93188. /**
  93189. * Sets the data of the sound from an audiobuffer
  93190. * @param audioBuffer The audioBuffer containing the data
  93191. */
  93192. setAudioBuffer(audioBuffer: AudioBuffer): void;
  93193. /**
  93194. * Updates the current sounds options such as maxdistance, loop...
  93195. * @param options A JSON object containing values named as the object properties
  93196. */
  93197. updateOptions(options: any): void;
  93198. private _createSpatialParameters;
  93199. private _updateSpatialParameters;
  93200. /**
  93201. * Switch the panning model to HRTF:
  93202. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  93203. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93204. */
  93205. switchPanningModelToHRTF(): void;
  93206. /**
  93207. * Switch the panning model to Equal Power:
  93208. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  93209. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93210. */
  93211. switchPanningModelToEqualPower(): void;
  93212. private _switchPanningModel;
  93213. /**
  93214. * Connect this sound to a sound track audio node like gain...
  93215. * @param soundTrackAudioNode the sound track audio node to connect to
  93216. */
  93217. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  93218. /**
  93219. * Transform this sound into a directional source
  93220. * @param coneInnerAngle Size of the inner cone in degree
  93221. * @param coneOuterAngle Size of the outer cone in degree
  93222. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  93223. */
  93224. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  93225. /**
  93226. * Gets or sets the inner angle for the directional cone.
  93227. */
  93228. /**
  93229. * Gets or sets the inner angle for the directional cone.
  93230. */
  93231. directionalConeInnerAngle: number;
  93232. /**
  93233. * Gets or sets the outer angle for the directional cone.
  93234. */
  93235. /**
  93236. * Gets or sets the outer angle for the directional cone.
  93237. */
  93238. directionalConeOuterAngle: number;
  93239. /**
  93240. * Sets the position of the emitter if spatial sound is enabled
  93241. * @param newPosition Defines the new posisiton
  93242. */
  93243. setPosition(newPosition: Vector3): void;
  93244. /**
  93245. * Sets the local direction of the emitter if spatial sound is enabled
  93246. * @param newLocalDirection Defines the new local direction
  93247. */
  93248. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  93249. private _updateDirection;
  93250. /** @hidden */
  93251. updateDistanceFromListener(): void;
  93252. /**
  93253. * Sets a new custom attenuation function for the sound.
  93254. * @param callback Defines the function used for the attenuation
  93255. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  93256. */
  93257. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  93258. /**
  93259. * Play the sound
  93260. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  93261. * @param offset (optional) Start the sound setting it at a specific time
  93262. */
  93263. play(time?: number, offset?: number): void;
  93264. private _onended;
  93265. /**
  93266. * Stop the sound
  93267. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  93268. */
  93269. stop(time?: number): void;
  93270. /**
  93271. * Put the sound in pause
  93272. */
  93273. pause(): void;
  93274. /**
  93275. * Sets a dedicated volume for this sounds
  93276. * @param newVolume Define the new volume of the sound
  93277. * @param time Define in how long the sound should be at this value
  93278. */
  93279. setVolume(newVolume: number, time?: number): void;
  93280. /**
  93281. * Set the sound play back rate
  93282. * @param newPlaybackRate Define the playback rate the sound should be played at
  93283. */
  93284. setPlaybackRate(newPlaybackRate: number): void;
  93285. /**
  93286. * Gets the volume of the sound.
  93287. * @returns the volume of the sound
  93288. */
  93289. getVolume(): number;
  93290. /**
  93291. * Attach the sound to a dedicated mesh
  93292. * @param transformNode The transform node to connect the sound with
  93293. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  93294. */
  93295. attachToMesh(transformNode: TransformNode): void;
  93296. /**
  93297. * Detach the sound from the previously attached mesh
  93298. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  93299. */
  93300. detachFromMesh(): void;
  93301. private _onRegisterAfterWorldMatrixUpdate;
  93302. /**
  93303. * Clone the current sound in the scene.
  93304. * @returns the new sound clone
  93305. */
  93306. clone(): Nullable<Sound>;
  93307. /**
  93308. * Gets the current underlying audio buffer containing the data
  93309. * @returns the audio buffer
  93310. */
  93311. getAudioBuffer(): Nullable<AudioBuffer>;
  93312. /**
  93313. * Serializes the Sound in a JSON representation
  93314. * @returns the JSON representation of the sound
  93315. */
  93316. serialize(): any;
  93317. /**
  93318. * Parse a JSON representation of a sound to innstantiate in a given scene
  93319. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  93320. * @param scene Define the scene the new parsed sound should be created in
  93321. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  93322. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  93323. * @returns the newly parsed sound
  93324. */
  93325. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  93326. }
  93327. }
  93328. declare module BABYLON {
  93329. /**
  93330. * This defines an action helpful to play a defined sound on a triggered action.
  93331. */
  93332. export class PlaySoundAction extends Action {
  93333. private _sound;
  93334. /**
  93335. * Instantiate the action
  93336. * @param triggerOptions defines the trigger options
  93337. * @param sound defines the sound to play
  93338. * @param condition defines the trigger related conditions
  93339. */
  93340. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  93341. /** @hidden */
  93342. _prepare(): void;
  93343. /**
  93344. * Execute the action and play the sound.
  93345. */
  93346. execute(): void;
  93347. /**
  93348. * Serializes the actions and its related information.
  93349. * @param parent defines the object to serialize in
  93350. * @returns the serialized object
  93351. */
  93352. serialize(parent: any): any;
  93353. }
  93354. /**
  93355. * This defines an action helpful to stop a defined sound on a triggered action.
  93356. */
  93357. export class StopSoundAction extends Action {
  93358. private _sound;
  93359. /**
  93360. * Instantiate the action
  93361. * @param triggerOptions defines the trigger options
  93362. * @param sound defines the sound to stop
  93363. * @param condition defines the trigger related conditions
  93364. */
  93365. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  93366. /** @hidden */
  93367. _prepare(): void;
  93368. /**
  93369. * Execute the action and stop the sound.
  93370. */
  93371. execute(): void;
  93372. /**
  93373. * Serializes the actions and its related information.
  93374. * @param parent defines the object to serialize in
  93375. * @returns the serialized object
  93376. */
  93377. serialize(parent: any): any;
  93378. }
  93379. }
  93380. declare module BABYLON {
  93381. /**
  93382. * This defines an action responsible to change the value of a property
  93383. * by interpolating between its current value and the newly set one once triggered.
  93384. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93385. */
  93386. export class InterpolateValueAction extends Action {
  93387. /**
  93388. * Defines the path of the property where the value should be interpolated
  93389. */
  93390. propertyPath: string;
  93391. /**
  93392. * Defines the target value at the end of the interpolation.
  93393. */
  93394. value: any;
  93395. /**
  93396. * Defines the time it will take for the property to interpolate to the value.
  93397. */
  93398. duration: number;
  93399. /**
  93400. * Defines if the other scene animations should be stopped when the action has been triggered
  93401. */
  93402. stopOtherAnimations?: boolean;
  93403. /**
  93404. * Defines a callback raised once the interpolation animation has been done.
  93405. */
  93406. onInterpolationDone?: () => void;
  93407. /**
  93408. * Observable triggered once the interpolation animation has been done.
  93409. */
  93410. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  93411. private _target;
  93412. private _effectiveTarget;
  93413. private _property;
  93414. /**
  93415. * Instantiate the action
  93416. * @param triggerOptions defines the trigger options
  93417. * @param target defines the object containing the value to interpolate
  93418. * @param propertyPath defines the path to the property in the target object
  93419. * @param value defines the target value at the end of the interpolation
  93420. * @param duration deines the time it will take for the property to interpolate to the value.
  93421. * @param condition defines the trigger related conditions
  93422. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  93423. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  93424. */
  93425. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  93426. /** @hidden */
  93427. _prepare(): void;
  93428. /**
  93429. * Execute the action starts the value interpolation.
  93430. */
  93431. execute(): void;
  93432. /**
  93433. * Serializes the actions and its related information.
  93434. * @param parent defines the object to serialize in
  93435. * @returns the serialized object
  93436. */
  93437. serialize(parent: any): any;
  93438. }
  93439. }
  93440. declare module BABYLON {
  93441. /**
  93442. * Options allowed during the creation of a sound track.
  93443. */
  93444. export interface ISoundTrackOptions {
  93445. /**
  93446. * The volume the sound track should take during creation
  93447. */
  93448. volume?: number;
  93449. /**
  93450. * Define if the sound track is the main sound track of the scene
  93451. */
  93452. mainTrack?: boolean;
  93453. }
  93454. /**
  93455. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  93456. * It will be also used in a future release to apply effects on a specific track.
  93457. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  93458. */
  93459. export class SoundTrack {
  93460. /**
  93461. * The unique identifier of the sound track in the scene.
  93462. */
  93463. id: number;
  93464. /**
  93465. * The list of sounds included in the sound track.
  93466. */
  93467. soundCollection: Array<Sound>;
  93468. private _outputAudioNode;
  93469. private _scene;
  93470. private _isMainTrack;
  93471. private _connectedAnalyser;
  93472. private _options;
  93473. private _isInitialized;
  93474. /**
  93475. * Creates a new sound track.
  93476. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  93477. * @param scene Define the scene the sound track belongs to
  93478. * @param options
  93479. */
  93480. constructor(scene: Scene, options?: ISoundTrackOptions);
  93481. private _initializeSoundTrackAudioGraph;
  93482. /**
  93483. * Release the sound track and its associated resources
  93484. */
  93485. dispose(): void;
  93486. /**
  93487. * Adds a sound to this sound track
  93488. * @param sound define the cound to add
  93489. * @ignoreNaming
  93490. */
  93491. AddSound(sound: Sound): void;
  93492. /**
  93493. * Removes a sound to this sound track
  93494. * @param sound define the cound to remove
  93495. * @ignoreNaming
  93496. */
  93497. RemoveSound(sound: Sound): void;
  93498. /**
  93499. * Set a global volume for the full sound track.
  93500. * @param newVolume Define the new volume of the sound track
  93501. */
  93502. setVolume(newVolume: number): void;
  93503. /**
  93504. * Switch the panning model to HRTF:
  93505. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  93506. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93507. */
  93508. switchPanningModelToHRTF(): void;
  93509. /**
  93510. * Switch the panning model to Equal Power:
  93511. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  93512. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93513. */
  93514. switchPanningModelToEqualPower(): void;
  93515. /**
  93516. * Connect the sound track to an audio analyser allowing some amazing
  93517. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  93518. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  93519. * @param analyser The analyser to connect to the engine
  93520. */
  93521. connectToAnalyser(analyser: Analyser): void;
  93522. }
  93523. }
  93524. declare module BABYLON {
  93525. interface AbstractScene {
  93526. /**
  93527. * The list of sounds used in the scene.
  93528. */
  93529. sounds: Nullable<Array<Sound>>;
  93530. }
  93531. interface Scene {
  93532. /**
  93533. * @hidden
  93534. * Backing field
  93535. */
  93536. _mainSoundTrack: SoundTrack;
  93537. /**
  93538. * The main sound track played by the scene.
  93539. * It cotains your primary collection of sounds.
  93540. */
  93541. mainSoundTrack: SoundTrack;
  93542. /**
  93543. * The list of sound tracks added to the scene
  93544. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93545. */
  93546. soundTracks: Nullable<Array<SoundTrack>>;
  93547. /**
  93548. * Gets a sound using a given name
  93549. * @param name defines the name to search for
  93550. * @return the found sound or null if not found at all.
  93551. */
  93552. getSoundByName(name: string): Nullable<Sound>;
  93553. /**
  93554. * Gets or sets if audio support is enabled
  93555. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93556. */
  93557. audioEnabled: boolean;
  93558. /**
  93559. * Gets or sets if audio will be output to headphones
  93560. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93561. */
  93562. headphone: boolean;
  93563. }
  93564. /**
  93565. * Defines the sound scene component responsible to manage any sounds
  93566. * in a given scene.
  93567. */
  93568. export class AudioSceneComponent implements ISceneSerializableComponent {
  93569. /**
  93570. * The component name helpfull to identify the component in the list of scene components.
  93571. */
  93572. readonly name: string;
  93573. /**
  93574. * The scene the component belongs to.
  93575. */
  93576. scene: Scene;
  93577. private _audioEnabled;
  93578. /**
  93579. * Gets whether audio is enabled or not.
  93580. * Please use related enable/disable method to switch state.
  93581. */
  93582. readonly audioEnabled: boolean;
  93583. private _headphone;
  93584. /**
  93585. * Gets whether audio is outputing to headphone or not.
  93586. * Please use the according Switch methods to change output.
  93587. */
  93588. readonly headphone: boolean;
  93589. /**
  93590. * Creates a new instance of the component for the given scene
  93591. * @param scene Defines the scene to register the component in
  93592. */
  93593. constructor(scene: Scene);
  93594. /**
  93595. * Registers the component in a given scene
  93596. */
  93597. register(): void;
  93598. /**
  93599. * Rebuilds the elements related to this component in case of
  93600. * context lost for instance.
  93601. */
  93602. rebuild(): void;
  93603. /**
  93604. * Serializes the component data to the specified json object
  93605. * @param serializationObject The object to serialize to
  93606. */
  93607. serialize(serializationObject: any): void;
  93608. /**
  93609. * Adds all the element from the container to the scene
  93610. * @param container the container holding the elements
  93611. */
  93612. addFromContainer(container: AbstractScene): void;
  93613. /**
  93614. * Removes all the elements in the container from the scene
  93615. * @param container contains the elements to remove
  93616. * @param dispose if the removed element should be disposed (default: false)
  93617. */
  93618. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  93619. /**
  93620. * Disposes the component and the associated ressources.
  93621. */
  93622. dispose(): void;
  93623. /**
  93624. * Disables audio in the associated scene.
  93625. */
  93626. disableAudio(): void;
  93627. /**
  93628. * Enables audio in the associated scene.
  93629. */
  93630. enableAudio(): void;
  93631. /**
  93632. * Switch audio to headphone output.
  93633. */
  93634. switchAudioModeForHeadphones(): void;
  93635. /**
  93636. * Switch audio to normal speakers.
  93637. */
  93638. switchAudioModeForNormalSpeakers(): void;
  93639. private _afterRender;
  93640. }
  93641. }
  93642. declare module BABYLON {
  93643. /**
  93644. * Wraps one or more Sound objects and selects one with random weight for playback.
  93645. */
  93646. export class WeightedSound {
  93647. /** When true a Sound will be selected and played when the current playing Sound completes. */
  93648. loop: boolean;
  93649. private _coneInnerAngle;
  93650. private _coneOuterAngle;
  93651. private _volume;
  93652. /** A Sound is currently playing. */
  93653. isPlaying: boolean;
  93654. /** A Sound is currently paused. */
  93655. isPaused: boolean;
  93656. private _sounds;
  93657. private _weights;
  93658. private _currentIndex?;
  93659. /**
  93660. * Creates a new WeightedSound from the list of sounds given.
  93661. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  93662. * @param sounds Array of Sounds that will be selected from.
  93663. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  93664. */
  93665. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  93666. /**
  93667. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  93668. */
  93669. /**
  93670. * The size of cone in degress for a directional sound in which there will be no attenuation.
  93671. */
  93672. directionalConeInnerAngle: number;
  93673. /**
  93674. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  93675. * Listener angles between innerAngle and outerAngle will falloff linearly.
  93676. */
  93677. /**
  93678. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  93679. * Listener angles between innerAngle and outerAngle will falloff linearly.
  93680. */
  93681. directionalConeOuterAngle: number;
  93682. /**
  93683. * Playback volume.
  93684. */
  93685. /**
  93686. * Playback volume.
  93687. */
  93688. volume: number;
  93689. private _onended;
  93690. /**
  93691. * Suspend playback
  93692. */
  93693. pause(): void;
  93694. /**
  93695. * Stop playback
  93696. */
  93697. stop(): void;
  93698. /**
  93699. * Start playback.
  93700. * @param startOffset Position the clip head at a specific time in seconds.
  93701. */
  93702. play(startOffset?: number): void;
  93703. }
  93704. }
  93705. declare module BABYLON {
  93706. /**
  93707. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  93708. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  93709. */
  93710. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  93711. /**
  93712. * Gets the name of the behavior.
  93713. */
  93714. readonly name: string;
  93715. /**
  93716. * The easing function used by animations
  93717. */
  93718. static EasingFunction: BackEase;
  93719. /**
  93720. * The easing mode used by animations
  93721. */
  93722. static EasingMode: number;
  93723. /**
  93724. * The duration of the animation, in milliseconds
  93725. */
  93726. transitionDuration: number;
  93727. /**
  93728. * Length of the distance animated by the transition when lower radius is reached
  93729. */
  93730. lowerRadiusTransitionRange: number;
  93731. /**
  93732. * Length of the distance animated by the transition when upper radius is reached
  93733. */
  93734. upperRadiusTransitionRange: number;
  93735. private _autoTransitionRange;
  93736. /**
  93737. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  93738. */
  93739. /**
  93740. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  93741. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  93742. */
  93743. autoTransitionRange: boolean;
  93744. private _attachedCamera;
  93745. private _onAfterCheckInputsObserver;
  93746. private _onMeshTargetChangedObserver;
  93747. /**
  93748. * Initializes the behavior.
  93749. */
  93750. init(): void;
  93751. /**
  93752. * Attaches the behavior to its arc rotate camera.
  93753. * @param camera Defines the camera to attach the behavior to
  93754. */
  93755. attach(camera: ArcRotateCamera): void;
  93756. /**
  93757. * Detaches the behavior from its current arc rotate camera.
  93758. */
  93759. detach(): void;
  93760. private _radiusIsAnimating;
  93761. private _radiusBounceTransition;
  93762. private _animatables;
  93763. private _cachedWheelPrecision;
  93764. /**
  93765. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  93766. * @param radiusLimit The limit to check against.
  93767. * @return Bool to indicate if at limit.
  93768. */
  93769. private _isRadiusAtLimit;
  93770. /**
  93771. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  93772. * @param radiusDelta The delta by which to animate to. Can be negative.
  93773. */
  93774. private _applyBoundRadiusAnimation;
  93775. /**
  93776. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  93777. */
  93778. protected _clearAnimationLocks(): void;
  93779. /**
  93780. * Stops and removes all animations that have been applied to the camera
  93781. */
  93782. stopAllAnimations(): void;
  93783. }
  93784. }
  93785. declare module BABYLON {
  93786. /**
  93787. * 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.
  93788. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  93789. */
  93790. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  93791. /**
  93792. * Gets the name of the behavior.
  93793. */
  93794. readonly name: string;
  93795. private _mode;
  93796. private _radiusScale;
  93797. private _positionScale;
  93798. private _defaultElevation;
  93799. private _elevationReturnTime;
  93800. private _elevationReturnWaitTime;
  93801. private _zoomStopsAnimation;
  93802. private _framingTime;
  93803. /**
  93804. * The easing function used by animations
  93805. */
  93806. static EasingFunction: ExponentialEase;
  93807. /**
  93808. * The easing mode used by animations
  93809. */
  93810. static EasingMode: number;
  93811. /**
  93812. * Sets the current mode used by the behavior
  93813. */
  93814. /**
  93815. * Gets current mode used by the behavior.
  93816. */
  93817. mode: number;
  93818. /**
  93819. * Sets the scale applied to the radius (1 by default)
  93820. */
  93821. /**
  93822. * Gets the scale applied to the radius
  93823. */
  93824. radiusScale: number;
  93825. /**
  93826. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  93827. */
  93828. /**
  93829. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  93830. */
  93831. positionScale: number;
  93832. /**
  93833. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  93834. * behaviour is triggered, in radians.
  93835. */
  93836. /**
  93837. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  93838. * behaviour is triggered, in radians.
  93839. */
  93840. defaultElevation: number;
  93841. /**
  93842. * Sets the time (in milliseconds) taken to return to the default beta position.
  93843. * Negative value indicates camera should not return to default.
  93844. */
  93845. /**
  93846. * Gets the time (in milliseconds) taken to return to the default beta position.
  93847. * Negative value indicates camera should not return to default.
  93848. */
  93849. elevationReturnTime: number;
  93850. /**
  93851. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  93852. */
  93853. /**
  93854. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  93855. */
  93856. elevationReturnWaitTime: number;
  93857. /**
  93858. * Sets the flag that indicates if user zooming should stop animation.
  93859. */
  93860. /**
  93861. * Gets the flag that indicates if user zooming should stop animation.
  93862. */
  93863. zoomStopsAnimation: boolean;
  93864. /**
  93865. * Sets the transition time when framing the mesh, in milliseconds
  93866. */
  93867. /**
  93868. * Gets the transition time when framing the mesh, in milliseconds
  93869. */
  93870. framingTime: number;
  93871. /**
  93872. * Define if the behavior should automatically change the configured
  93873. * camera limits and sensibilities.
  93874. */
  93875. autoCorrectCameraLimitsAndSensibility: boolean;
  93876. private _onPrePointerObservableObserver;
  93877. private _onAfterCheckInputsObserver;
  93878. private _onMeshTargetChangedObserver;
  93879. private _attachedCamera;
  93880. private _isPointerDown;
  93881. private _lastInteractionTime;
  93882. /**
  93883. * Initializes the behavior.
  93884. */
  93885. init(): void;
  93886. /**
  93887. * Attaches the behavior to its arc rotate camera.
  93888. * @param camera Defines the camera to attach the behavior to
  93889. */
  93890. attach(camera: ArcRotateCamera): void;
  93891. /**
  93892. * Detaches the behavior from its current arc rotate camera.
  93893. */
  93894. detach(): void;
  93895. private _animatables;
  93896. private _betaIsAnimating;
  93897. private _betaTransition;
  93898. private _radiusTransition;
  93899. private _vectorTransition;
  93900. /**
  93901. * Targets the given mesh and updates zoom level accordingly.
  93902. * @param mesh The mesh to target.
  93903. * @param radius Optional. If a cached radius position already exists, overrides default.
  93904. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  93905. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  93906. * @param onAnimationEnd Callback triggered at the end of the framing animation
  93907. */
  93908. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  93909. /**
  93910. * Targets the given mesh with its children and updates zoom level accordingly.
  93911. * @param mesh The mesh to target.
  93912. * @param radius Optional. If a cached radius position already exists, overrides default.
  93913. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  93914. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  93915. * @param onAnimationEnd Callback triggered at the end of the framing animation
  93916. */
  93917. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  93918. /**
  93919. * Targets the given meshes with their children and updates zoom level accordingly.
  93920. * @param meshes The mesh to target.
  93921. * @param radius Optional. If a cached radius position already exists, overrides default.
  93922. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  93923. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  93924. * @param onAnimationEnd Callback triggered at the end of the framing animation
  93925. */
  93926. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  93927. /**
  93928. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  93929. * @param minimumWorld Determines the smaller position of the bounding box extend
  93930. * @param maximumWorld Determines the bigger position of the bounding box extend
  93931. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  93932. * @param onAnimationEnd Callback triggered at the end of the framing animation
  93933. */
  93934. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  93935. /**
  93936. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  93937. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  93938. * frustum width.
  93939. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  93940. * to fully enclose the mesh in the viewing frustum.
  93941. */
  93942. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  93943. /**
  93944. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  93945. * is automatically returned to its default position (expected to be above ground plane).
  93946. */
  93947. private _maintainCameraAboveGround;
  93948. /**
  93949. * Returns the frustum slope based on the canvas ratio and camera FOV
  93950. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  93951. */
  93952. private _getFrustumSlope;
  93953. /**
  93954. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  93955. */
  93956. private _clearAnimationLocks;
  93957. /**
  93958. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  93959. */
  93960. private _applyUserInteraction;
  93961. /**
  93962. * Stops and removes all animations that have been applied to the camera
  93963. */
  93964. stopAllAnimations(): void;
  93965. /**
  93966. * Gets a value indicating if the user is moving the camera
  93967. */
  93968. readonly isUserIsMoving: boolean;
  93969. /**
  93970. * The camera can move all the way towards the mesh.
  93971. */
  93972. static IgnoreBoundsSizeMode: number;
  93973. /**
  93974. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  93975. */
  93976. static FitFrustumSidesMode: number;
  93977. }
  93978. }
  93979. declare module BABYLON {
  93980. /**
  93981. * Base class for Camera Pointer Inputs.
  93982. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  93983. * for example usage.
  93984. */
  93985. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  93986. /**
  93987. * Defines the camera the input is attached to.
  93988. */
  93989. abstract camera: Camera;
  93990. /**
  93991. * Whether keyboard modifier keys are pressed at time of last mouse event.
  93992. */
  93993. protected _altKey: boolean;
  93994. protected _ctrlKey: boolean;
  93995. protected _metaKey: boolean;
  93996. protected _shiftKey: boolean;
  93997. /**
  93998. * Which mouse buttons were pressed at time of last mouse event.
  93999. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  94000. */
  94001. protected _buttonsPressed: number;
  94002. /**
  94003. * Defines the buttons associated with the input to handle camera move.
  94004. */
  94005. buttons: number[];
  94006. /**
  94007. * Attach the input controls to a specific dom element to get the input from.
  94008. * @param element Defines the element the controls should be listened from
  94009. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94010. */
  94011. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94012. /**
  94013. * Detach the current controls from the specified dom element.
  94014. * @param element Defines the element to stop listening the inputs from
  94015. */
  94016. detachControl(element: Nullable<HTMLElement>): void;
  94017. /**
  94018. * Gets the class name of the current input.
  94019. * @returns the class name
  94020. */
  94021. getClassName(): string;
  94022. /**
  94023. * Get the friendly name associated with the input class.
  94024. * @returns the input friendly name
  94025. */
  94026. getSimpleName(): string;
  94027. /**
  94028. * Called on pointer POINTERDOUBLETAP event.
  94029. * Override this method to provide functionality on POINTERDOUBLETAP event.
  94030. */
  94031. protected onDoubleTap(type: string): void;
  94032. /**
  94033. * Called on pointer POINTERMOVE event if only a single touch is active.
  94034. * Override this method to provide functionality.
  94035. */
  94036. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  94037. /**
  94038. * Called on pointer POINTERMOVE event if multiple touches are active.
  94039. * Override this method to provide functionality.
  94040. */
  94041. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  94042. /**
  94043. * Called on JS contextmenu event.
  94044. * Override this method to provide functionality.
  94045. */
  94046. protected onContextMenu(evt: PointerEvent): void;
  94047. /**
  94048. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  94049. * press.
  94050. * Override this method to provide functionality.
  94051. */
  94052. protected onButtonDown(evt: PointerEvent): void;
  94053. /**
  94054. * Called each time a new POINTERUP event occurs. Ie, for each button
  94055. * release.
  94056. * Override this method to provide functionality.
  94057. */
  94058. protected onButtonUp(evt: PointerEvent): void;
  94059. /**
  94060. * Called when window becomes inactive.
  94061. * Override this method to provide functionality.
  94062. */
  94063. protected onLostFocus(): void;
  94064. private _pointerInput;
  94065. private _observer;
  94066. private _onLostFocus;
  94067. private pointA;
  94068. private pointB;
  94069. }
  94070. }
  94071. declare module BABYLON {
  94072. /**
  94073. * Manage the pointers inputs to control an arc rotate camera.
  94074. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94075. */
  94076. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  94077. /**
  94078. * Defines the camera the input is attached to.
  94079. */
  94080. camera: ArcRotateCamera;
  94081. /**
  94082. * Gets the class name of the current input.
  94083. * @returns the class name
  94084. */
  94085. getClassName(): string;
  94086. /**
  94087. * Defines the buttons associated with the input to handle camera move.
  94088. */
  94089. buttons: number[];
  94090. /**
  94091. * Defines the pointer angular sensibility along the X axis or how fast is
  94092. * the camera rotating.
  94093. */
  94094. angularSensibilityX: number;
  94095. /**
  94096. * Defines the pointer angular sensibility along the Y axis or how fast is
  94097. * the camera rotating.
  94098. */
  94099. angularSensibilityY: number;
  94100. /**
  94101. * Defines the pointer pinch precision or how fast is the camera zooming.
  94102. */
  94103. pinchPrecision: number;
  94104. /**
  94105. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  94106. * from 0.
  94107. * It defines the percentage of current camera.radius to use as delta when
  94108. * pinch zoom is used.
  94109. */
  94110. pinchDeltaPercentage: number;
  94111. /**
  94112. * Defines the pointer panning sensibility or how fast is the camera moving.
  94113. */
  94114. panningSensibility: number;
  94115. /**
  94116. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  94117. */
  94118. multiTouchPanning: boolean;
  94119. /**
  94120. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  94121. * zoom (pinch) through multitouch.
  94122. */
  94123. multiTouchPanAndZoom: boolean;
  94124. /**
  94125. * Revers pinch action direction.
  94126. */
  94127. pinchInwards: boolean;
  94128. private _isPanClick;
  94129. private _twoFingerActivityCount;
  94130. private _isPinching;
  94131. /**
  94132. * Called on pointer POINTERMOVE event if only a single touch is active.
  94133. */
  94134. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  94135. /**
  94136. * Called on pointer POINTERDOUBLETAP event.
  94137. */
  94138. protected onDoubleTap(type: string): void;
  94139. /**
  94140. * Called on pointer POINTERMOVE event if multiple touches are active.
  94141. */
  94142. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  94143. /**
  94144. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  94145. * press.
  94146. */
  94147. protected onButtonDown(evt: PointerEvent): void;
  94148. /**
  94149. * Called each time a new POINTERUP event occurs. Ie, for each button
  94150. * release.
  94151. */
  94152. protected onButtonUp(evt: PointerEvent): void;
  94153. /**
  94154. * Called when window becomes inactive.
  94155. */
  94156. protected onLostFocus(): void;
  94157. }
  94158. }
  94159. declare module BABYLON {
  94160. /**
  94161. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  94162. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94163. */
  94164. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  94165. /**
  94166. * Defines the camera the input is attached to.
  94167. */
  94168. camera: ArcRotateCamera;
  94169. /**
  94170. * Defines the list of key codes associated with the up action (increase alpha)
  94171. */
  94172. keysUp: number[];
  94173. /**
  94174. * Defines the list of key codes associated with the down action (decrease alpha)
  94175. */
  94176. keysDown: number[];
  94177. /**
  94178. * Defines the list of key codes associated with the left action (increase beta)
  94179. */
  94180. keysLeft: number[];
  94181. /**
  94182. * Defines the list of key codes associated with the right action (decrease beta)
  94183. */
  94184. keysRight: number[];
  94185. /**
  94186. * Defines the list of key codes associated with the reset action.
  94187. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  94188. */
  94189. keysReset: number[];
  94190. /**
  94191. * Defines the panning sensibility of the inputs.
  94192. * (How fast is the camera paning)
  94193. */
  94194. panningSensibility: number;
  94195. /**
  94196. * Defines the zooming sensibility of the inputs.
  94197. * (How fast is the camera zooming)
  94198. */
  94199. zoomingSensibility: number;
  94200. /**
  94201. * Defines wether maintaining the alt key down switch the movement mode from
  94202. * orientation to zoom.
  94203. */
  94204. useAltToZoom: boolean;
  94205. /**
  94206. * Rotation speed of the camera
  94207. */
  94208. angularSpeed: number;
  94209. private _keys;
  94210. private _ctrlPressed;
  94211. private _altPressed;
  94212. private _onCanvasBlurObserver;
  94213. private _onKeyboardObserver;
  94214. private _engine;
  94215. private _scene;
  94216. /**
  94217. * Attach the input controls to a specific dom element to get the input from.
  94218. * @param element Defines the element the controls should be listened from
  94219. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94220. */
  94221. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94222. /**
  94223. * Detach the current controls from the specified dom element.
  94224. * @param element Defines the element to stop listening the inputs from
  94225. */
  94226. detachControl(element: Nullable<HTMLElement>): void;
  94227. /**
  94228. * Update the current camera state depending on the inputs that have been used this frame.
  94229. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94230. */
  94231. checkInputs(): void;
  94232. /**
  94233. * Gets the class name of the current intput.
  94234. * @returns the class name
  94235. */
  94236. getClassName(): string;
  94237. /**
  94238. * Get the friendly name associated with the input class.
  94239. * @returns the input friendly name
  94240. */
  94241. getSimpleName(): string;
  94242. }
  94243. }
  94244. declare module BABYLON {
  94245. /**
  94246. * Manage the mouse wheel inputs to control an arc rotate camera.
  94247. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94248. */
  94249. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  94250. /**
  94251. * Defines the camera the input is attached to.
  94252. */
  94253. camera: ArcRotateCamera;
  94254. /**
  94255. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  94256. */
  94257. wheelPrecision: number;
  94258. /**
  94259. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  94260. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  94261. */
  94262. wheelDeltaPercentage: number;
  94263. private _wheel;
  94264. private _observer;
  94265. /**
  94266. * Attach the input controls to a specific dom element to get the input from.
  94267. * @param element Defines the element the controls should be listened from
  94268. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94269. */
  94270. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94271. /**
  94272. * Detach the current controls from the specified dom element.
  94273. * @param element Defines the element to stop listening the inputs from
  94274. */
  94275. detachControl(element: Nullable<HTMLElement>): void;
  94276. /**
  94277. * Gets the class name of the current intput.
  94278. * @returns the class name
  94279. */
  94280. getClassName(): string;
  94281. /**
  94282. * Get the friendly name associated with the input class.
  94283. * @returns the input friendly name
  94284. */
  94285. getSimpleName(): string;
  94286. }
  94287. }
  94288. declare module BABYLON {
  94289. /**
  94290. * Default Inputs manager for the ArcRotateCamera.
  94291. * It groups all the default supported inputs for ease of use.
  94292. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94293. */
  94294. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  94295. /**
  94296. * Instantiates a new ArcRotateCameraInputsManager.
  94297. * @param camera Defines the camera the inputs belong to
  94298. */
  94299. constructor(camera: ArcRotateCamera);
  94300. /**
  94301. * Add mouse wheel input support to the input manager.
  94302. * @returns the current input manager
  94303. */
  94304. addMouseWheel(): ArcRotateCameraInputsManager;
  94305. /**
  94306. * Add pointers input support to the input manager.
  94307. * @returns the current input manager
  94308. */
  94309. addPointers(): ArcRotateCameraInputsManager;
  94310. /**
  94311. * Add keyboard input support to the input manager.
  94312. * @returns the current input manager
  94313. */
  94314. addKeyboard(): ArcRotateCameraInputsManager;
  94315. }
  94316. }
  94317. declare module BABYLON {
  94318. /**
  94319. * This represents an orbital type of camera.
  94320. *
  94321. * 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.
  94322. * 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.
  94323. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  94324. */
  94325. export class ArcRotateCamera extends TargetCamera {
  94326. /**
  94327. * Defines the rotation angle of the camera along the longitudinal axis.
  94328. */
  94329. alpha: number;
  94330. /**
  94331. * Defines the rotation angle of the camera along the latitudinal axis.
  94332. */
  94333. beta: number;
  94334. /**
  94335. * Defines the radius of the camera from it s target point.
  94336. */
  94337. radius: number;
  94338. protected _target: Vector3;
  94339. protected _targetHost: Nullable<AbstractMesh>;
  94340. /**
  94341. * Defines the target point of the camera.
  94342. * The camera looks towards it form the radius distance.
  94343. */
  94344. target: Vector3;
  94345. /**
  94346. * Define the current local position of the camera in the scene
  94347. */
  94348. position: Vector3;
  94349. protected _upVector: Vector3;
  94350. protected _upToYMatrix: Matrix;
  94351. protected _YToUpMatrix: Matrix;
  94352. /**
  94353. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  94354. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  94355. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  94356. */
  94357. upVector: Vector3;
  94358. /**
  94359. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  94360. */
  94361. setMatUp(): void;
  94362. /**
  94363. * Current inertia value on the longitudinal axis.
  94364. * The bigger this number the longer it will take for the camera to stop.
  94365. */
  94366. inertialAlphaOffset: number;
  94367. /**
  94368. * Current inertia value on the latitudinal axis.
  94369. * The bigger this number the longer it will take for the camera to stop.
  94370. */
  94371. inertialBetaOffset: number;
  94372. /**
  94373. * Current inertia value on the radius axis.
  94374. * The bigger this number the longer it will take for the camera to stop.
  94375. */
  94376. inertialRadiusOffset: number;
  94377. /**
  94378. * Minimum allowed angle on the longitudinal axis.
  94379. * This can help limiting how the Camera is able to move in the scene.
  94380. */
  94381. lowerAlphaLimit: Nullable<number>;
  94382. /**
  94383. * Maximum allowed angle on the longitudinal axis.
  94384. * This can help limiting how the Camera is able to move in the scene.
  94385. */
  94386. upperAlphaLimit: Nullable<number>;
  94387. /**
  94388. * Minimum allowed angle on the latitudinal axis.
  94389. * This can help limiting how the Camera is able to move in the scene.
  94390. */
  94391. lowerBetaLimit: number;
  94392. /**
  94393. * Maximum allowed angle on the latitudinal axis.
  94394. * This can help limiting how the Camera is able to move in the scene.
  94395. */
  94396. upperBetaLimit: number;
  94397. /**
  94398. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  94399. * This can help limiting how the Camera is able to move in the scene.
  94400. */
  94401. lowerRadiusLimit: Nullable<number>;
  94402. /**
  94403. * Maximum allowed distance of the camera to the target (The camera can not get further).
  94404. * This can help limiting how the Camera is able to move in the scene.
  94405. */
  94406. upperRadiusLimit: Nullable<number>;
  94407. /**
  94408. * Defines the current inertia value used during panning of the camera along the X axis.
  94409. */
  94410. inertialPanningX: number;
  94411. /**
  94412. * Defines the current inertia value used during panning of the camera along the Y axis.
  94413. */
  94414. inertialPanningY: number;
  94415. /**
  94416. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  94417. * Basically if your fingers moves away from more than this distance you will be considered
  94418. * in pinch mode.
  94419. */
  94420. pinchToPanMaxDistance: number;
  94421. /**
  94422. * Defines the maximum distance the camera can pan.
  94423. * This could help keeping the cammera always in your scene.
  94424. */
  94425. panningDistanceLimit: Nullable<number>;
  94426. /**
  94427. * Defines the target of the camera before paning.
  94428. */
  94429. panningOriginTarget: Vector3;
  94430. /**
  94431. * Defines the value of the inertia used during panning.
  94432. * 0 would mean stop inertia and one would mean no decelleration at all.
  94433. */
  94434. panningInertia: number;
  94435. /**
  94436. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  94437. */
  94438. angularSensibilityX: number;
  94439. /**
  94440. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  94441. */
  94442. angularSensibilityY: number;
  94443. /**
  94444. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  94445. */
  94446. pinchPrecision: number;
  94447. /**
  94448. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  94449. * It will be used instead of pinchDeltaPrecision if different from 0.
  94450. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  94451. */
  94452. pinchDeltaPercentage: number;
  94453. /**
  94454. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  94455. */
  94456. panningSensibility: number;
  94457. /**
  94458. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  94459. */
  94460. keysUp: number[];
  94461. /**
  94462. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  94463. */
  94464. keysDown: number[];
  94465. /**
  94466. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  94467. */
  94468. keysLeft: number[];
  94469. /**
  94470. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  94471. */
  94472. keysRight: number[];
  94473. /**
  94474. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  94475. */
  94476. wheelPrecision: number;
  94477. /**
  94478. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  94479. * It will be used instead of pinchDeltaPrecision if different from 0.
  94480. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  94481. */
  94482. wheelDeltaPercentage: number;
  94483. /**
  94484. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  94485. */
  94486. zoomOnFactor: number;
  94487. /**
  94488. * Defines a screen offset for the camera position.
  94489. */
  94490. targetScreenOffset: Vector2;
  94491. /**
  94492. * Allows the camera to be completely reversed.
  94493. * If false the camera can not arrive upside down.
  94494. */
  94495. allowUpsideDown: boolean;
  94496. /**
  94497. * Define if double tap/click is used to restore the previously saved state of the camera.
  94498. */
  94499. useInputToRestoreState: boolean;
  94500. /** @hidden */
  94501. _viewMatrix: Matrix;
  94502. /** @hidden */
  94503. _useCtrlForPanning: boolean;
  94504. /** @hidden */
  94505. _panningMouseButton: number;
  94506. /**
  94507. * Defines the input associated to the camera.
  94508. */
  94509. inputs: ArcRotateCameraInputsManager;
  94510. /** @hidden */
  94511. _reset: () => void;
  94512. /**
  94513. * Defines the allowed panning axis.
  94514. */
  94515. panningAxis: Vector3;
  94516. protected _localDirection: Vector3;
  94517. protected _transformedDirection: Vector3;
  94518. private _bouncingBehavior;
  94519. /**
  94520. * Gets the bouncing behavior of the camera if it has been enabled.
  94521. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  94522. */
  94523. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  94524. /**
  94525. * Defines if the bouncing behavior of the camera is enabled on the camera.
  94526. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  94527. */
  94528. useBouncingBehavior: boolean;
  94529. private _framingBehavior;
  94530. /**
  94531. * Gets the framing behavior of the camera if it has been enabled.
  94532. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  94533. */
  94534. readonly framingBehavior: Nullable<FramingBehavior>;
  94535. /**
  94536. * Defines if the framing behavior of the camera is enabled on the camera.
  94537. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  94538. */
  94539. useFramingBehavior: boolean;
  94540. private _autoRotationBehavior;
  94541. /**
  94542. * Gets the auto rotation behavior of the camera if it has been enabled.
  94543. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  94544. */
  94545. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  94546. /**
  94547. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  94548. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  94549. */
  94550. useAutoRotationBehavior: boolean;
  94551. /**
  94552. * Observable triggered when the mesh target has been changed on the camera.
  94553. */
  94554. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  94555. /**
  94556. * Event raised when the camera is colliding with a mesh.
  94557. */
  94558. onCollide: (collidedMesh: AbstractMesh) => void;
  94559. /**
  94560. * Defines whether the camera should check collision with the objects oh the scene.
  94561. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  94562. */
  94563. checkCollisions: boolean;
  94564. /**
  94565. * Defines the collision radius of the camera.
  94566. * This simulates a sphere around the camera.
  94567. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  94568. */
  94569. collisionRadius: Vector3;
  94570. protected _collider: Collider;
  94571. protected _previousPosition: Vector3;
  94572. protected _collisionVelocity: Vector3;
  94573. protected _newPosition: Vector3;
  94574. protected _previousAlpha: number;
  94575. protected _previousBeta: number;
  94576. protected _previousRadius: number;
  94577. protected _collisionTriggered: boolean;
  94578. protected _targetBoundingCenter: Nullable<Vector3>;
  94579. private _computationVector;
  94580. /**
  94581. * Instantiates a new ArcRotateCamera in a given scene
  94582. * @param name Defines the name of the camera
  94583. * @param alpha Defines the camera rotation along the logitudinal axis
  94584. * @param beta Defines the camera rotation along the latitudinal axis
  94585. * @param radius Defines the camera distance from its target
  94586. * @param target Defines the camera target
  94587. * @param scene Defines the scene the camera belongs to
  94588. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  94589. */
  94590. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  94591. /** @hidden */
  94592. _initCache(): void;
  94593. /** @hidden */
  94594. _updateCache(ignoreParentClass?: boolean): void;
  94595. protected _getTargetPosition(): Vector3;
  94596. private _storedAlpha;
  94597. private _storedBeta;
  94598. private _storedRadius;
  94599. private _storedTarget;
  94600. /**
  94601. * Stores the current state of the camera (alpha, beta, radius and target)
  94602. * @returns the camera itself
  94603. */
  94604. storeState(): Camera;
  94605. /**
  94606. * @hidden
  94607. * Restored camera state. You must call storeState() first
  94608. */
  94609. _restoreStateValues(): boolean;
  94610. /** @hidden */
  94611. _isSynchronizedViewMatrix(): boolean;
  94612. /**
  94613. * Attached controls to the current camera.
  94614. * @param element Defines the element the controls should be listened from
  94615. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94616. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  94617. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  94618. */
  94619. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  94620. /**
  94621. * Detach the current controls from the camera.
  94622. * The camera will stop reacting to inputs.
  94623. * @param element Defines the element to stop listening the inputs from
  94624. */
  94625. detachControl(element: HTMLElement): void;
  94626. /** @hidden */
  94627. _checkInputs(): void;
  94628. protected _checkLimits(): void;
  94629. /**
  94630. * Rebuilds angles (alpha, beta) and radius from the give position and target
  94631. */
  94632. rebuildAnglesAndRadius(): void;
  94633. /**
  94634. * Use a position to define the current camera related information like aplha, beta and radius
  94635. * @param position Defines the position to set the camera at
  94636. */
  94637. setPosition(position: Vector3): void;
  94638. /**
  94639. * Defines the target the camera should look at.
  94640. * This will automatically adapt alpha beta and radius to fit within the new target.
  94641. * @param target Defines the new target as a Vector or a mesh
  94642. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  94643. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  94644. */
  94645. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  94646. /** @hidden */
  94647. _getViewMatrix(): Matrix;
  94648. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  94649. /**
  94650. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  94651. * @param meshes Defines the mesh to zoom on
  94652. * @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)
  94653. */
  94654. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  94655. /**
  94656. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  94657. * The target will be changed but the radius
  94658. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  94659. * @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)
  94660. */
  94661. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  94662. min: Vector3;
  94663. max: Vector3;
  94664. distance: number;
  94665. }, doNotUpdateMaxZ?: boolean): void;
  94666. /**
  94667. * @override
  94668. * Override Camera.createRigCamera
  94669. */
  94670. createRigCamera(name: string, cameraIndex: number): Camera;
  94671. /**
  94672. * @hidden
  94673. * @override
  94674. * Override Camera._updateRigCameras
  94675. */
  94676. _updateRigCameras(): void;
  94677. /**
  94678. * Destroy the camera and release the current resources hold by it.
  94679. */
  94680. dispose(): void;
  94681. /**
  94682. * Gets the current object class name.
  94683. * @return the class name
  94684. */
  94685. getClassName(): string;
  94686. }
  94687. }
  94688. declare module BABYLON {
  94689. /**
  94690. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  94691. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  94692. */
  94693. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  94694. /**
  94695. * Gets the name of the behavior.
  94696. */
  94697. readonly name: string;
  94698. private _zoomStopsAnimation;
  94699. private _idleRotationSpeed;
  94700. private _idleRotationWaitTime;
  94701. private _idleRotationSpinupTime;
  94702. /**
  94703. * Sets the flag that indicates if user zooming should stop animation.
  94704. */
  94705. /**
  94706. * Gets the flag that indicates if user zooming should stop animation.
  94707. */
  94708. zoomStopsAnimation: boolean;
  94709. /**
  94710. * Sets the default speed at which the camera rotates around the model.
  94711. */
  94712. /**
  94713. * Gets the default speed at which the camera rotates around the model.
  94714. */
  94715. idleRotationSpeed: number;
  94716. /**
  94717. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  94718. */
  94719. /**
  94720. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  94721. */
  94722. idleRotationWaitTime: number;
  94723. /**
  94724. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  94725. */
  94726. /**
  94727. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  94728. */
  94729. idleRotationSpinupTime: number;
  94730. /**
  94731. * Gets a value indicating if the camera is currently rotating because of this behavior
  94732. */
  94733. readonly rotationInProgress: boolean;
  94734. private _onPrePointerObservableObserver;
  94735. private _onAfterCheckInputsObserver;
  94736. private _attachedCamera;
  94737. private _isPointerDown;
  94738. private _lastFrameTime;
  94739. private _lastInteractionTime;
  94740. private _cameraRotationSpeed;
  94741. /**
  94742. * Initializes the behavior.
  94743. */
  94744. init(): void;
  94745. /**
  94746. * Attaches the behavior to its arc rotate camera.
  94747. * @param camera Defines the camera to attach the behavior to
  94748. */
  94749. attach(camera: ArcRotateCamera): void;
  94750. /**
  94751. * Detaches the behavior from its current arc rotate camera.
  94752. */
  94753. detach(): void;
  94754. /**
  94755. * Returns true if user is scrolling.
  94756. * @return true if user is scrolling.
  94757. */
  94758. private _userIsZooming;
  94759. private _lastFrameRadius;
  94760. private _shouldAnimationStopForInteraction;
  94761. /**
  94762. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  94763. */
  94764. private _applyUserInteraction;
  94765. private _userIsMoving;
  94766. }
  94767. }
  94768. declare module BABYLON {
  94769. /**
  94770. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  94771. */
  94772. export class AttachToBoxBehavior implements Behavior<Mesh> {
  94773. private ui;
  94774. /**
  94775. * The name of the behavior
  94776. */
  94777. name: string;
  94778. /**
  94779. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  94780. */
  94781. distanceAwayFromFace: number;
  94782. /**
  94783. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  94784. */
  94785. distanceAwayFromBottomOfFace: number;
  94786. private _faceVectors;
  94787. private _target;
  94788. private _scene;
  94789. private _onRenderObserver;
  94790. private _tmpMatrix;
  94791. private _tmpVector;
  94792. /**
  94793. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  94794. * @param ui The transform node that should be attched to the mesh
  94795. */
  94796. constructor(ui: TransformNode);
  94797. /**
  94798. * Initializes the behavior
  94799. */
  94800. init(): void;
  94801. private _closestFace;
  94802. private _zeroVector;
  94803. private _lookAtTmpMatrix;
  94804. private _lookAtToRef;
  94805. /**
  94806. * Attaches the AttachToBoxBehavior to the passed in mesh
  94807. * @param target The mesh that the specified node will be attached to
  94808. */
  94809. attach(target: Mesh): void;
  94810. /**
  94811. * Detaches the behavior from the mesh
  94812. */
  94813. detach(): void;
  94814. }
  94815. }
  94816. declare module BABYLON {
  94817. /**
  94818. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  94819. */
  94820. export class FadeInOutBehavior implements Behavior<Mesh> {
  94821. /**
  94822. * Time in milliseconds to delay before fading in (Default: 0)
  94823. */
  94824. delay: number;
  94825. /**
  94826. * Time in milliseconds for the mesh to fade in (Default: 300)
  94827. */
  94828. fadeInTime: number;
  94829. private _millisecondsPerFrame;
  94830. private _hovered;
  94831. private _hoverValue;
  94832. private _ownerNode;
  94833. /**
  94834. * Instatiates the FadeInOutBehavior
  94835. */
  94836. constructor();
  94837. /**
  94838. * The name of the behavior
  94839. */
  94840. readonly name: string;
  94841. /**
  94842. * Initializes the behavior
  94843. */
  94844. init(): void;
  94845. /**
  94846. * Attaches the fade behavior on the passed in mesh
  94847. * @param ownerNode The mesh that will be faded in/out once attached
  94848. */
  94849. attach(ownerNode: Mesh): void;
  94850. /**
  94851. * Detaches the behavior from the mesh
  94852. */
  94853. detach(): void;
  94854. /**
  94855. * Triggers the mesh to begin fading in or out
  94856. * @param value if the object should fade in or out (true to fade in)
  94857. */
  94858. fadeIn(value: boolean): void;
  94859. private _update;
  94860. private _setAllVisibility;
  94861. }
  94862. }
  94863. declare module BABYLON {
  94864. /**
  94865. * Class containing a set of static utilities functions for managing Pivots
  94866. * @hidden
  94867. */
  94868. export class PivotTools {
  94869. private static _PivotCached;
  94870. private static _OldPivotPoint;
  94871. private static _PivotTranslation;
  94872. private static _PivotTmpVector;
  94873. /** @hidden */
  94874. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  94875. /** @hidden */
  94876. static _RestorePivotPoint(mesh: AbstractMesh): void;
  94877. }
  94878. }
  94879. declare module BABYLON {
  94880. /**
  94881. * Class containing static functions to help procedurally build meshes
  94882. */
  94883. export class PlaneBuilder {
  94884. /**
  94885. * Creates a plane mesh
  94886. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  94887. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  94888. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  94889. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  94890. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  94891. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  94892. * @param name defines the name of the mesh
  94893. * @param options defines the options used to create the mesh
  94894. * @param scene defines the hosting scene
  94895. * @returns the plane mesh
  94896. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  94897. */
  94898. static CreatePlane(name: string, options: {
  94899. size?: number;
  94900. width?: number;
  94901. height?: number;
  94902. sideOrientation?: number;
  94903. frontUVs?: Vector4;
  94904. backUVs?: Vector4;
  94905. updatable?: boolean;
  94906. sourcePlane?: Plane;
  94907. }, scene?: Nullable<Scene>): Mesh;
  94908. }
  94909. }
  94910. declare module BABYLON {
  94911. /**
  94912. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  94913. */
  94914. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  94915. private static _AnyMouseID;
  94916. private _attachedNode;
  94917. private _dragPlane;
  94918. private _scene;
  94919. private _pointerObserver;
  94920. private _beforeRenderObserver;
  94921. private static _planeScene;
  94922. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  94923. /**
  94924. * 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)
  94925. */
  94926. maxDragAngle: number;
  94927. /**
  94928. * @hidden
  94929. */
  94930. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  94931. /**
  94932. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  94933. */
  94934. currentDraggingPointerID: number;
  94935. /**
  94936. * The last position where the pointer hit the drag plane in world space
  94937. */
  94938. lastDragPosition: Vector3;
  94939. /**
  94940. * If the behavior is currently in a dragging state
  94941. */
  94942. dragging: boolean;
  94943. /**
  94944. * 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)
  94945. */
  94946. dragDeltaRatio: number;
  94947. /**
  94948. * If the drag plane orientation should be updated during the dragging (Default: true)
  94949. */
  94950. updateDragPlane: boolean;
  94951. private _debugMode;
  94952. private _moving;
  94953. /**
  94954. * Fires each time the attached mesh is dragged with the pointer
  94955. * * delta between last drag position and current drag position in world space
  94956. * * dragDistance along the drag axis
  94957. * * dragPlaneNormal normal of the current drag plane used during the drag
  94958. * * dragPlanePoint in world space where the drag intersects the drag plane
  94959. */
  94960. onDragObservable: Observable<{
  94961. delta: Vector3;
  94962. dragPlanePoint: Vector3;
  94963. dragPlaneNormal: Vector3;
  94964. dragDistance: number;
  94965. pointerId: number;
  94966. }>;
  94967. /**
  94968. * Fires each time a drag begins (eg. mouse down on mesh)
  94969. */
  94970. onDragStartObservable: Observable<{
  94971. dragPlanePoint: Vector3;
  94972. pointerId: number;
  94973. }>;
  94974. /**
  94975. * Fires each time a drag ends (eg. mouse release after drag)
  94976. */
  94977. onDragEndObservable: Observable<{
  94978. dragPlanePoint: Vector3;
  94979. pointerId: number;
  94980. }>;
  94981. /**
  94982. * If the attached mesh should be moved when dragged
  94983. */
  94984. moveAttached: boolean;
  94985. /**
  94986. * If the drag behavior will react to drag events (Default: true)
  94987. */
  94988. enabled: boolean;
  94989. /**
  94990. * If camera controls should be detached during the drag
  94991. */
  94992. detachCameraControls: boolean;
  94993. /**
  94994. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  94995. */
  94996. useObjectOrienationForDragging: boolean;
  94997. private _options;
  94998. /**
  94999. * Creates a pointer drag behavior that can be attached to a mesh
  95000. * @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)
  95001. */
  95002. constructor(options?: {
  95003. dragAxis?: Vector3;
  95004. dragPlaneNormal?: Vector3;
  95005. });
  95006. /**
  95007. * Predicate to determine if it is valid to move the object to a new position when it is moved
  95008. */
  95009. validateDrag: (targetPosition: Vector3) => boolean;
  95010. /**
  95011. * The name of the behavior
  95012. */
  95013. readonly name: string;
  95014. /**
  95015. * Initializes the behavior
  95016. */
  95017. init(): void;
  95018. private _tmpVector;
  95019. private _alternatePickedPoint;
  95020. private _worldDragAxis;
  95021. private _targetPosition;
  95022. private _attachedElement;
  95023. /**
  95024. * Attaches the drag behavior the passed in mesh
  95025. * @param ownerNode The mesh that will be dragged around once attached
  95026. */
  95027. attach(ownerNode: AbstractMesh): void;
  95028. /**
  95029. * Force relase the drag action by code.
  95030. */
  95031. releaseDrag(): void;
  95032. private _startDragRay;
  95033. private _lastPointerRay;
  95034. /**
  95035. * Simulates the start of a pointer drag event on the behavior
  95036. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  95037. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  95038. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  95039. */
  95040. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  95041. private _startDrag;
  95042. private _dragDelta;
  95043. private _moveDrag;
  95044. private _pickWithRayOnDragPlane;
  95045. private _pointA;
  95046. private _pointB;
  95047. private _pointC;
  95048. private _lineA;
  95049. private _lineB;
  95050. private _localAxis;
  95051. private _lookAt;
  95052. private _updateDragPlanePosition;
  95053. /**
  95054. * Detaches the behavior from the mesh
  95055. */
  95056. detach(): void;
  95057. }
  95058. }
  95059. declare module BABYLON {
  95060. /**
  95061. * A behavior that when attached to a mesh will allow the mesh to be scaled
  95062. */
  95063. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  95064. private _dragBehaviorA;
  95065. private _dragBehaviorB;
  95066. private _startDistance;
  95067. private _initialScale;
  95068. private _targetScale;
  95069. private _ownerNode;
  95070. private _sceneRenderObserver;
  95071. /**
  95072. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  95073. */
  95074. constructor();
  95075. /**
  95076. * The name of the behavior
  95077. */
  95078. readonly name: string;
  95079. /**
  95080. * Initializes the behavior
  95081. */
  95082. init(): void;
  95083. private _getCurrentDistance;
  95084. /**
  95085. * Attaches the scale behavior the passed in mesh
  95086. * @param ownerNode The mesh that will be scaled around once attached
  95087. */
  95088. attach(ownerNode: Mesh): void;
  95089. /**
  95090. * Detaches the behavior from the mesh
  95091. */
  95092. detach(): void;
  95093. }
  95094. }
  95095. declare module BABYLON {
  95096. /**
  95097. * 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
  95098. */
  95099. export class SixDofDragBehavior implements Behavior<Mesh> {
  95100. private static _virtualScene;
  95101. private _ownerNode;
  95102. private _sceneRenderObserver;
  95103. private _scene;
  95104. private _targetPosition;
  95105. private _virtualOriginMesh;
  95106. private _virtualDragMesh;
  95107. private _pointerObserver;
  95108. private _moving;
  95109. private _startingOrientation;
  95110. /**
  95111. * 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)
  95112. */
  95113. private zDragFactor;
  95114. /**
  95115. * If the object should rotate to face the drag origin
  95116. */
  95117. rotateDraggedObject: boolean;
  95118. /**
  95119. * If the behavior is currently in a dragging state
  95120. */
  95121. dragging: boolean;
  95122. /**
  95123. * 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)
  95124. */
  95125. dragDeltaRatio: number;
  95126. /**
  95127. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  95128. */
  95129. currentDraggingPointerID: number;
  95130. /**
  95131. * If camera controls should be detached during the drag
  95132. */
  95133. detachCameraControls: boolean;
  95134. /**
  95135. * Fires each time a drag starts
  95136. */
  95137. onDragStartObservable: Observable<{}>;
  95138. /**
  95139. * Fires each time a drag ends (eg. mouse release after drag)
  95140. */
  95141. onDragEndObservable: Observable<{}>;
  95142. /**
  95143. * 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
  95144. */
  95145. constructor();
  95146. /**
  95147. * The name of the behavior
  95148. */
  95149. readonly name: string;
  95150. /**
  95151. * Initializes the behavior
  95152. */
  95153. init(): void;
  95154. /**
  95155. * Attaches the scale behavior the passed in mesh
  95156. * @param ownerNode The mesh that will be scaled around once attached
  95157. */
  95158. attach(ownerNode: Mesh): void;
  95159. /**
  95160. * Detaches the behavior from the mesh
  95161. */
  95162. detach(): void;
  95163. }
  95164. }
  95165. declare module BABYLON {
  95166. /**
  95167. * Class used to apply inverse kinematics to bones
  95168. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  95169. */
  95170. export class BoneIKController {
  95171. private static _tmpVecs;
  95172. private static _tmpQuat;
  95173. private static _tmpMats;
  95174. /**
  95175. * Gets or sets the target mesh
  95176. */
  95177. targetMesh: AbstractMesh;
  95178. /** Gets or sets the mesh used as pole */
  95179. poleTargetMesh: AbstractMesh;
  95180. /**
  95181. * Gets or sets the bone used as pole
  95182. */
  95183. poleTargetBone: Nullable<Bone>;
  95184. /**
  95185. * Gets or sets the target position
  95186. */
  95187. targetPosition: Vector3;
  95188. /**
  95189. * Gets or sets the pole target position
  95190. */
  95191. poleTargetPosition: Vector3;
  95192. /**
  95193. * Gets or sets the pole target local offset
  95194. */
  95195. poleTargetLocalOffset: Vector3;
  95196. /**
  95197. * Gets or sets the pole angle
  95198. */
  95199. poleAngle: number;
  95200. /**
  95201. * Gets or sets the mesh associated with the controller
  95202. */
  95203. mesh: AbstractMesh;
  95204. /**
  95205. * 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)
  95206. */
  95207. slerpAmount: number;
  95208. private _bone1Quat;
  95209. private _bone1Mat;
  95210. private _bone2Ang;
  95211. private _bone1;
  95212. private _bone2;
  95213. private _bone1Length;
  95214. private _bone2Length;
  95215. private _maxAngle;
  95216. private _maxReach;
  95217. private _rightHandedSystem;
  95218. private _bendAxis;
  95219. private _slerping;
  95220. private _adjustRoll;
  95221. /**
  95222. * Gets or sets maximum allowed angle
  95223. */
  95224. maxAngle: number;
  95225. /**
  95226. * Creates a new BoneIKController
  95227. * @param mesh defines the mesh to control
  95228. * @param bone defines the bone to control
  95229. * @param options defines options to set up the controller
  95230. */
  95231. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  95232. targetMesh?: AbstractMesh;
  95233. poleTargetMesh?: AbstractMesh;
  95234. poleTargetBone?: Bone;
  95235. poleTargetLocalOffset?: Vector3;
  95236. poleAngle?: number;
  95237. bendAxis?: Vector3;
  95238. maxAngle?: number;
  95239. slerpAmount?: number;
  95240. });
  95241. private _setMaxAngle;
  95242. /**
  95243. * Force the controller to update the bones
  95244. */
  95245. update(): void;
  95246. }
  95247. }
  95248. declare module BABYLON {
  95249. /**
  95250. * Class used to make a bone look toward a point in space
  95251. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  95252. */
  95253. export class BoneLookController {
  95254. private static _tmpVecs;
  95255. private static _tmpQuat;
  95256. private static _tmpMats;
  95257. /**
  95258. * The target Vector3 that the bone will look at
  95259. */
  95260. target: Vector3;
  95261. /**
  95262. * The mesh that the bone is attached to
  95263. */
  95264. mesh: AbstractMesh;
  95265. /**
  95266. * The bone that will be looking to the target
  95267. */
  95268. bone: Bone;
  95269. /**
  95270. * The up axis of the coordinate system that is used when the bone is rotated
  95271. */
  95272. upAxis: Vector3;
  95273. /**
  95274. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  95275. */
  95276. upAxisSpace: Space;
  95277. /**
  95278. * Used to make an adjustment to the yaw of the bone
  95279. */
  95280. adjustYaw: number;
  95281. /**
  95282. * Used to make an adjustment to the pitch of the bone
  95283. */
  95284. adjustPitch: number;
  95285. /**
  95286. * Used to make an adjustment to the roll of the bone
  95287. */
  95288. adjustRoll: number;
  95289. /**
  95290. * 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)
  95291. */
  95292. slerpAmount: number;
  95293. private _minYaw;
  95294. private _maxYaw;
  95295. private _minPitch;
  95296. private _maxPitch;
  95297. private _minYawSin;
  95298. private _minYawCos;
  95299. private _maxYawSin;
  95300. private _maxYawCos;
  95301. private _midYawConstraint;
  95302. private _minPitchTan;
  95303. private _maxPitchTan;
  95304. private _boneQuat;
  95305. private _slerping;
  95306. private _transformYawPitch;
  95307. private _transformYawPitchInv;
  95308. private _firstFrameSkipped;
  95309. private _yawRange;
  95310. private _fowardAxis;
  95311. /**
  95312. * Gets or sets the minimum yaw angle that the bone can look to
  95313. */
  95314. minYaw: number;
  95315. /**
  95316. * Gets or sets the maximum yaw angle that the bone can look to
  95317. */
  95318. maxYaw: number;
  95319. /**
  95320. * Gets or sets the minimum pitch angle that the bone can look to
  95321. */
  95322. minPitch: number;
  95323. /**
  95324. * Gets or sets the maximum pitch angle that the bone can look to
  95325. */
  95326. maxPitch: number;
  95327. /**
  95328. * Create a BoneLookController
  95329. * @param mesh the mesh that the bone belongs to
  95330. * @param bone the bone that will be looking to the target
  95331. * @param target the target Vector3 to look at
  95332. * @param options optional settings:
  95333. * * maxYaw: the maximum angle the bone will yaw to
  95334. * * minYaw: the minimum angle the bone will yaw to
  95335. * * maxPitch: the maximum angle the bone will pitch to
  95336. * * minPitch: the minimum angle the bone will yaw to
  95337. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  95338. * * upAxis: the up axis of the coordinate system
  95339. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  95340. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  95341. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  95342. * * adjustYaw: used to make an adjustment to the yaw of the bone
  95343. * * adjustPitch: used to make an adjustment to the pitch of the bone
  95344. * * adjustRoll: used to make an adjustment to the roll of the bone
  95345. **/
  95346. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  95347. maxYaw?: number;
  95348. minYaw?: number;
  95349. maxPitch?: number;
  95350. minPitch?: number;
  95351. slerpAmount?: number;
  95352. upAxis?: Vector3;
  95353. upAxisSpace?: Space;
  95354. yawAxis?: Vector3;
  95355. pitchAxis?: Vector3;
  95356. adjustYaw?: number;
  95357. adjustPitch?: number;
  95358. adjustRoll?: number;
  95359. });
  95360. /**
  95361. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  95362. */
  95363. update(): void;
  95364. private _getAngleDiff;
  95365. private _getAngleBetween;
  95366. private _isAngleBetween;
  95367. }
  95368. }
  95369. declare module BABYLON {
  95370. /**
  95371. * Manage the gamepad inputs to control an arc rotate camera.
  95372. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95373. */
  95374. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  95375. /**
  95376. * Defines the camera the input is attached to.
  95377. */
  95378. camera: ArcRotateCamera;
  95379. /**
  95380. * Defines the gamepad the input is gathering event from.
  95381. */
  95382. gamepad: Nullable<Gamepad>;
  95383. /**
  95384. * Defines the gamepad rotation sensiblity.
  95385. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  95386. */
  95387. gamepadRotationSensibility: number;
  95388. /**
  95389. * Defines the gamepad move sensiblity.
  95390. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  95391. */
  95392. gamepadMoveSensibility: number;
  95393. private _onGamepadConnectedObserver;
  95394. private _onGamepadDisconnectedObserver;
  95395. /**
  95396. * Attach the input controls to a specific dom element to get the input from.
  95397. * @param element Defines the element the controls should be listened from
  95398. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95399. */
  95400. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95401. /**
  95402. * Detach the current controls from the specified dom element.
  95403. * @param element Defines the element to stop listening the inputs from
  95404. */
  95405. detachControl(element: Nullable<HTMLElement>): void;
  95406. /**
  95407. * Update the current camera state depending on the inputs that have been used this frame.
  95408. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95409. */
  95410. checkInputs(): void;
  95411. /**
  95412. * Gets the class name of the current intput.
  95413. * @returns the class name
  95414. */
  95415. getClassName(): string;
  95416. /**
  95417. * Get the friendly name associated with the input class.
  95418. * @returns the input friendly name
  95419. */
  95420. getSimpleName(): string;
  95421. }
  95422. }
  95423. declare module BABYLON {
  95424. interface ArcRotateCameraInputsManager {
  95425. /**
  95426. * Add orientation input support to the input manager.
  95427. * @returns the current input manager
  95428. */
  95429. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  95430. }
  95431. /**
  95432. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  95433. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95434. */
  95435. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  95436. /**
  95437. * Defines the camera the input is attached to.
  95438. */
  95439. camera: ArcRotateCamera;
  95440. /**
  95441. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  95442. */
  95443. alphaCorrection: number;
  95444. /**
  95445. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  95446. */
  95447. gammaCorrection: number;
  95448. private _alpha;
  95449. private _gamma;
  95450. private _dirty;
  95451. private _deviceOrientationHandler;
  95452. /**
  95453. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  95454. */
  95455. constructor();
  95456. /**
  95457. * Attach the input controls to a specific dom element to get the input from.
  95458. * @param element Defines the element the controls should be listened from
  95459. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95460. */
  95461. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95462. /** @hidden */
  95463. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  95464. /**
  95465. * Update the current camera state depending on the inputs that have been used this frame.
  95466. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95467. */
  95468. checkInputs(): void;
  95469. /**
  95470. * Detach the current controls from the specified dom element.
  95471. * @param element Defines the element to stop listening the inputs from
  95472. */
  95473. detachControl(element: Nullable<HTMLElement>): void;
  95474. /**
  95475. * Gets the class name of the current intput.
  95476. * @returns the class name
  95477. */
  95478. getClassName(): string;
  95479. /**
  95480. * Get the friendly name associated with the input class.
  95481. * @returns the input friendly name
  95482. */
  95483. getSimpleName(): string;
  95484. }
  95485. }
  95486. declare module BABYLON {
  95487. /**
  95488. * Listen to mouse events to control the camera.
  95489. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95490. */
  95491. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  95492. /**
  95493. * Defines the camera the input is attached to.
  95494. */
  95495. camera: FlyCamera;
  95496. /**
  95497. * Defines if touch is enabled. (Default is true.)
  95498. */
  95499. touchEnabled: boolean;
  95500. /**
  95501. * Defines the buttons associated with the input to handle camera rotation.
  95502. */
  95503. buttons: number[];
  95504. /**
  95505. * Assign buttons for Yaw control.
  95506. */
  95507. buttonsYaw: number[];
  95508. /**
  95509. * Assign buttons for Pitch control.
  95510. */
  95511. buttonsPitch: number[];
  95512. /**
  95513. * Assign buttons for Roll control.
  95514. */
  95515. buttonsRoll: number[];
  95516. /**
  95517. * Detect if any button is being pressed while mouse is moved.
  95518. * -1 = Mouse locked.
  95519. * 0 = Left button.
  95520. * 1 = Middle Button.
  95521. * 2 = Right Button.
  95522. */
  95523. activeButton: number;
  95524. /**
  95525. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  95526. * Higher values reduce its sensitivity.
  95527. */
  95528. angularSensibility: number;
  95529. private _mousemoveCallback;
  95530. private _observer;
  95531. private _rollObserver;
  95532. private previousPosition;
  95533. private noPreventDefault;
  95534. private element;
  95535. /**
  95536. * Listen to mouse events to control the camera.
  95537. * @param touchEnabled Define if touch is enabled. (Default is true.)
  95538. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95539. */
  95540. constructor(touchEnabled?: boolean);
  95541. /**
  95542. * Attach the mouse control to the HTML DOM element.
  95543. * @param element Defines the element that listens to the input events.
  95544. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  95545. */
  95546. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95547. /**
  95548. * Detach the current controls from the specified dom element.
  95549. * @param element Defines the element to stop listening the inputs from
  95550. */
  95551. detachControl(element: Nullable<HTMLElement>): void;
  95552. /**
  95553. * Gets the class name of the current input.
  95554. * @returns the class name.
  95555. */
  95556. getClassName(): string;
  95557. /**
  95558. * Get the friendly name associated with the input class.
  95559. * @returns the input's friendly name.
  95560. */
  95561. getSimpleName(): string;
  95562. private _pointerInput;
  95563. private _onMouseMove;
  95564. /**
  95565. * Rotate camera by mouse offset.
  95566. */
  95567. private rotateCamera;
  95568. }
  95569. }
  95570. declare module BABYLON {
  95571. /**
  95572. * Default Inputs manager for the FlyCamera.
  95573. * It groups all the default supported inputs for ease of use.
  95574. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95575. */
  95576. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  95577. /**
  95578. * Instantiates a new FlyCameraInputsManager.
  95579. * @param camera Defines the camera the inputs belong to.
  95580. */
  95581. constructor(camera: FlyCamera);
  95582. /**
  95583. * Add keyboard input support to the input manager.
  95584. * @returns the new FlyCameraKeyboardMoveInput().
  95585. */
  95586. addKeyboard(): FlyCameraInputsManager;
  95587. /**
  95588. * Add mouse input support to the input manager.
  95589. * @param touchEnabled Enable touch screen support.
  95590. * @returns the new FlyCameraMouseInput().
  95591. */
  95592. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  95593. }
  95594. }
  95595. declare module BABYLON {
  95596. /**
  95597. * This is a flying camera, designed for 3D movement and rotation in all directions,
  95598. * such as in a 3D Space Shooter or a Flight Simulator.
  95599. */
  95600. export class FlyCamera extends TargetCamera {
  95601. /**
  95602. * Define the collision ellipsoid of the camera.
  95603. * This is helpful for simulating a camera body, like a player's body.
  95604. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  95605. */
  95606. ellipsoid: Vector3;
  95607. /**
  95608. * Define an offset for the position of the ellipsoid around the camera.
  95609. * This can be helpful if the camera is attached away from the player's body center,
  95610. * such as at its head.
  95611. */
  95612. ellipsoidOffset: Vector3;
  95613. /**
  95614. * Enable or disable collisions of the camera with the rest of the scene objects.
  95615. */
  95616. checkCollisions: boolean;
  95617. /**
  95618. * Enable or disable gravity on the camera.
  95619. */
  95620. applyGravity: boolean;
  95621. /**
  95622. * Define the current direction the camera is moving to.
  95623. */
  95624. cameraDirection: Vector3;
  95625. /**
  95626. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  95627. * This overrides and empties cameraRotation.
  95628. */
  95629. rotationQuaternion: Quaternion;
  95630. /**
  95631. * Track Roll to maintain the wanted Rolling when looking around.
  95632. */
  95633. _trackRoll: number;
  95634. /**
  95635. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  95636. */
  95637. rollCorrect: number;
  95638. /**
  95639. * Mimic a banked turn, Rolling the camera when Yawing.
  95640. * It's recommended to use rollCorrect = 10 for faster banking correction.
  95641. */
  95642. bankedTurn: boolean;
  95643. /**
  95644. * Limit in radians for how much Roll banking will add. (Default: 90°)
  95645. */
  95646. bankedTurnLimit: number;
  95647. /**
  95648. * Value of 0 disables the banked Roll.
  95649. * Value of 1 is equal to the Yaw angle in radians.
  95650. */
  95651. bankedTurnMultiplier: number;
  95652. /**
  95653. * The inputs manager loads all the input sources, such as keyboard and mouse.
  95654. */
  95655. inputs: FlyCameraInputsManager;
  95656. /**
  95657. * Gets the input sensibility for mouse input.
  95658. * Higher values reduce sensitivity.
  95659. */
  95660. /**
  95661. * Sets the input sensibility for a mouse input.
  95662. * Higher values reduce sensitivity.
  95663. */
  95664. angularSensibility: number;
  95665. /**
  95666. * Get the keys for camera movement forward.
  95667. */
  95668. /**
  95669. * Set the keys for camera movement forward.
  95670. */
  95671. keysForward: number[];
  95672. /**
  95673. * Get the keys for camera movement backward.
  95674. */
  95675. keysBackward: number[];
  95676. /**
  95677. * Get the keys for camera movement up.
  95678. */
  95679. /**
  95680. * Set the keys for camera movement up.
  95681. */
  95682. keysUp: number[];
  95683. /**
  95684. * Get the keys for camera movement down.
  95685. */
  95686. /**
  95687. * Set the keys for camera movement down.
  95688. */
  95689. keysDown: number[];
  95690. /**
  95691. * Get the keys for camera movement left.
  95692. */
  95693. /**
  95694. * Set the keys for camera movement left.
  95695. */
  95696. keysLeft: number[];
  95697. /**
  95698. * Set the keys for camera movement right.
  95699. */
  95700. /**
  95701. * Set the keys for camera movement right.
  95702. */
  95703. keysRight: number[];
  95704. /**
  95705. * Event raised when the camera collides with a mesh in the scene.
  95706. */
  95707. onCollide: (collidedMesh: AbstractMesh) => void;
  95708. private _collider;
  95709. private _needMoveForGravity;
  95710. private _oldPosition;
  95711. private _diffPosition;
  95712. private _newPosition;
  95713. /** @hidden */
  95714. _localDirection: Vector3;
  95715. /** @hidden */
  95716. _transformedDirection: Vector3;
  95717. /**
  95718. * Instantiates a FlyCamera.
  95719. * This is a flying camera, designed for 3D movement and rotation in all directions,
  95720. * such as in a 3D Space Shooter or a Flight Simulator.
  95721. * @param name Define the name of the camera in the scene.
  95722. * @param position Define the starting position of the camera in the scene.
  95723. * @param scene Define the scene the camera belongs to.
  95724. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  95725. */
  95726. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  95727. /**
  95728. * Attach a control to the HTML DOM element.
  95729. * @param element Defines the element that listens to the input events.
  95730. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  95731. */
  95732. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95733. /**
  95734. * Detach a control from the HTML DOM element.
  95735. * The camera will stop reacting to that input.
  95736. * @param element Defines the element that listens to the input events.
  95737. */
  95738. detachControl(element: HTMLElement): void;
  95739. private _collisionMask;
  95740. /**
  95741. * Get the mask that the camera ignores in collision events.
  95742. */
  95743. /**
  95744. * Set the mask that the camera ignores in collision events.
  95745. */
  95746. collisionMask: number;
  95747. /** @hidden */
  95748. _collideWithWorld(displacement: Vector3): void;
  95749. /** @hidden */
  95750. private _onCollisionPositionChange;
  95751. /** @hidden */
  95752. _checkInputs(): void;
  95753. /** @hidden */
  95754. _decideIfNeedsToMove(): boolean;
  95755. /** @hidden */
  95756. _updatePosition(): void;
  95757. /**
  95758. * Restore the Roll to its target value at the rate specified.
  95759. * @param rate - Higher means slower restoring.
  95760. * @hidden
  95761. */
  95762. restoreRoll(rate: number): void;
  95763. /**
  95764. * Destroy the camera and release the current resources held by it.
  95765. */
  95766. dispose(): void;
  95767. /**
  95768. * Get the current object class name.
  95769. * @returns the class name.
  95770. */
  95771. getClassName(): string;
  95772. }
  95773. }
  95774. declare module BABYLON {
  95775. /**
  95776. * Listen to keyboard events to control the camera.
  95777. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95778. */
  95779. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  95780. /**
  95781. * Defines the camera the input is attached to.
  95782. */
  95783. camera: FlyCamera;
  95784. /**
  95785. * The list of keyboard keys used to control the forward move of the camera.
  95786. */
  95787. keysForward: number[];
  95788. /**
  95789. * The list of keyboard keys used to control the backward move of the camera.
  95790. */
  95791. keysBackward: number[];
  95792. /**
  95793. * The list of keyboard keys used to control the forward move of the camera.
  95794. */
  95795. keysUp: number[];
  95796. /**
  95797. * The list of keyboard keys used to control the backward move of the camera.
  95798. */
  95799. keysDown: number[];
  95800. /**
  95801. * The list of keyboard keys used to control the right strafe move of the camera.
  95802. */
  95803. keysRight: number[];
  95804. /**
  95805. * The list of keyboard keys used to control the left strafe move of the camera.
  95806. */
  95807. keysLeft: number[];
  95808. private _keys;
  95809. private _onCanvasBlurObserver;
  95810. private _onKeyboardObserver;
  95811. private _engine;
  95812. private _scene;
  95813. /**
  95814. * Attach the input controls to a specific dom element to get the input from.
  95815. * @param element Defines the element the controls should be listened from
  95816. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95817. */
  95818. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95819. /**
  95820. * Detach the current controls from the specified dom element.
  95821. * @param element Defines the element to stop listening the inputs from
  95822. */
  95823. detachControl(element: Nullable<HTMLElement>): void;
  95824. /**
  95825. * Gets the class name of the current intput.
  95826. * @returns the class name
  95827. */
  95828. getClassName(): string;
  95829. /** @hidden */
  95830. _onLostFocus(e: FocusEvent): void;
  95831. /**
  95832. * Get the friendly name associated with the input class.
  95833. * @returns the input friendly name
  95834. */
  95835. getSimpleName(): string;
  95836. /**
  95837. * Update the current camera state depending on the inputs that have been used this frame.
  95838. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95839. */
  95840. checkInputs(): void;
  95841. }
  95842. }
  95843. declare module BABYLON {
  95844. /**
  95845. * Manage the mouse wheel inputs to control a follow camera.
  95846. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95847. */
  95848. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  95849. /**
  95850. * Defines the camera the input is attached to.
  95851. */
  95852. camera: FollowCamera;
  95853. /**
  95854. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  95855. */
  95856. axisControlRadius: boolean;
  95857. /**
  95858. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  95859. */
  95860. axisControlHeight: boolean;
  95861. /**
  95862. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  95863. */
  95864. axisControlRotation: boolean;
  95865. /**
  95866. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  95867. * relation to mouseWheel events.
  95868. */
  95869. wheelPrecision: number;
  95870. /**
  95871. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  95872. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  95873. */
  95874. wheelDeltaPercentage: number;
  95875. private _wheel;
  95876. private _observer;
  95877. /**
  95878. * Attach the input controls to a specific dom element to get the input from.
  95879. * @param element Defines the element the controls should be listened from
  95880. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95881. */
  95882. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95883. /**
  95884. * Detach the current controls from the specified dom element.
  95885. * @param element Defines the element to stop listening the inputs from
  95886. */
  95887. detachControl(element: Nullable<HTMLElement>): void;
  95888. /**
  95889. * Gets the class name of the current intput.
  95890. * @returns the class name
  95891. */
  95892. getClassName(): string;
  95893. /**
  95894. * Get the friendly name associated with the input class.
  95895. * @returns the input friendly name
  95896. */
  95897. getSimpleName(): string;
  95898. }
  95899. }
  95900. declare module BABYLON {
  95901. /**
  95902. * Manage the pointers inputs to control an follow camera.
  95903. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95904. */
  95905. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  95906. /**
  95907. * Defines the camera the input is attached to.
  95908. */
  95909. camera: FollowCamera;
  95910. /**
  95911. * Gets the class name of the current input.
  95912. * @returns the class name
  95913. */
  95914. getClassName(): string;
  95915. /**
  95916. * Defines the pointer angular sensibility along the X axis or how fast is
  95917. * the camera rotating.
  95918. * A negative number will reverse the axis direction.
  95919. */
  95920. angularSensibilityX: number;
  95921. /**
  95922. * Defines the pointer angular sensibility along the Y axis or how fast is
  95923. * the camera rotating.
  95924. * A negative number will reverse the axis direction.
  95925. */
  95926. angularSensibilityY: number;
  95927. /**
  95928. * Defines the pointer pinch precision or how fast is the camera zooming.
  95929. * A negative number will reverse the axis direction.
  95930. */
  95931. pinchPrecision: number;
  95932. /**
  95933. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  95934. * from 0.
  95935. * It defines the percentage of current camera.radius to use as delta when
  95936. * pinch zoom is used.
  95937. */
  95938. pinchDeltaPercentage: number;
  95939. /**
  95940. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  95941. */
  95942. axisXControlRadius: boolean;
  95943. /**
  95944. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  95945. */
  95946. axisXControlHeight: boolean;
  95947. /**
  95948. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  95949. */
  95950. axisXControlRotation: boolean;
  95951. /**
  95952. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  95953. */
  95954. axisYControlRadius: boolean;
  95955. /**
  95956. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  95957. */
  95958. axisYControlHeight: boolean;
  95959. /**
  95960. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  95961. */
  95962. axisYControlRotation: boolean;
  95963. /**
  95964. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  95965. */
  95966. axisPinchControlRadius: boolean;
  95967. /**
  95968. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  95969. */
  95970. axisPinchControlHeight: boolean;
  95971. /**
  95972. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  95973. */
  95974. axisPinchControlRotation: boolean;
  95975. /**
  95976. * Log error messages if basic misconfiguration has occurred.
  95977. */
  95978. warningEnable: boolean;
  95979. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  95980. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  95981. private _warningCounter;
  95982. private _warning;
  95983. }
  95984. }
  95985. declare module BABYLON {
  95986. /**
  95987. * Default Inputs manager for the FollowCamera.
  95988. * It groups all the default supported inputs for ease of use.
  95989. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95990. */
  95991. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  95992. /**
  95993. * Instantiates a new FollowCameraInputsManager.
  95994. * @param camera Defines the camera the inputs belong to
  95995. */
  95996. constructor(camera: FollowCamera);
  95997. /**
  95998. * Add keyboard input support to the input manager.
  95999. * @returns the current input manager
  96000. */
  96001. addKeyboard(): FollowCameraInputsManager;
  96002. /**
  96003. * Add mouse wheel input support to the input manager.
  96004. * @returns the current input manager
  96005. */
  96006. addMouseWheel(): FollowCameraInputsManager;
  96007. /**
  96008. * Add pointers input support to the input manager.
  96009. * @returns the current input manager
  96010. */
  96011. addPointers(): FollowCameraInputsManager;
  96012. /**
  96013. * Add orientation input support to the input manager.
  96014. * @returns the current input manager
  96015. */
  96016. addVRDeviceOrientation(): FollowCameraInputsManager;
  96017. }
  96018. }
  96019. declare module BABYLON {
  96020. /**
  96021. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  96022. * an arc rotate version arcFollowCamera are available.
  96023. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96024. */
  96025. export class FollowCamera extends TargetCamera {
  96026. /**
  96027. * Distance the follow camera should follow an object at
  96028. */
  96029. radius: number;
  96030. /**
  96031. * Minimum allowed distance of the camera to the axis of rotation
  96032. * (The camera can not get closer).
  96033. * This can help limiting how the Camera is able to move in the scene.
  96034. */
  96035. lowerRadiusLimit: Nullable<number>;
  96036. /**
  96037. * Maximum allowed distance of the camera to the axis of rotation
  96038. * (The camera can not get further).
  96039. * This can help limiting how the Camera is able to move in the scene.
  96040. */
  96041. upperRadiusLimit: Nullable<number>;
  96042. /**
  96043. * Define a rotation offset between the camera and the object it follows
  96044. */
  96045. rotationOffset: number;
  96046. /**
  96047. * Minimum allowed angle to camera position relative to target object.
  96048. * This can help limiting how the Camera is able to move in the scene.
  96049. */
  96050. lowerRotationOffsetLimit: Nullable<number>;
  96051. /**
  96052. * Maximum allowed angle to camera position relative to target object.
  96053. * This can help limiting how the Camera is able to move in the scene.
  96054. */
  96055. upperRotationOffsetLimit: Nullable<number>;
  96056. /**
  96057. * Define a height offset between the camera and the object it follows.
  96058. * It can help following an object from the top (like a car chaing a plane)
  96059. */
  96060. heightOffset: number;
  96061. /**
  96062. * Minimum allowed height of camera position relative to target object.
  96063. * This can help limiting how the Camera is able to move in the scene.
  96064. */
  96065. lowerHeightOffsetLimit: Nullable<number>;
  96066. /**
  96067. * Maximum allowed height of camera position relative to target object.
  96068. * This can help limiting how the Camera is able to move in the scene.
  96069. */
  96070. upperHeightOffsetLimit: Nullable<number>;
  96071. /**
  96072. * Define how fast the camera can accelerate to follow it s target.
  96073. */
  96074. cameraAcceleration: number;
  96075. /**
  96076. * Define the speed limit of the camera following an object.
  96077. */
  96078. maxCameraSpeed: number;
  96079. /**
  96080. * Define the target of the camera.
  96081. */
  96082. lockedTarget: Nullable<AbstractMesh>;
  96083. /**
  96084. * Defines the input associated with the camera.
  96085. */
  96086. inputs: FollowCameraInputsManager;
  96087. /**
  96088. * Instantiates the follow camera.
  96089. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96090. * @param name Define the name of the camera in the scene
  96091. * @param position Define the position of the camera
  96092. * @param scene Define the scene the camera belong to
  96093. * @param lockedTarget Define the target of the camera
  96094. */
  96095. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  96096. private _follow;
  96097. /**
  96098. * Attached controls to the current camera.
  96099. * @param element Defines the element the controls should be listened from
  96100. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96101. */
  96102. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96103. /**
  96104. * Detach the current controls from the camera.
  96105. * The camera will stop reacting to inputs.
  96106. * @param element Defines the element to stop listening the inputs from
  96107. */
  96108. detachControl(element: HTMLElement): void;
  96109. /** @hidden */
  96110. _checkInputs(): void;
  96111. private _checkLimits;
  96112. /**
  96113. * Gets the camera class name.
  96114. * @returns the class name
  96115. */
  96116. getClassName(): string;
  96117. }
  96118. /**
  96119. * Arc Rotate version of the follow camera.
  96120. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  96121. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96122. */
  96123. export class ArcFollowCamera extends TargetCamera {
  96124. /** The longitudinal angle of the camera */
  96125. alpha: number;
  96126. /** The latitudinal angle of the camera */
  96127. beta: number;
  96128. /** The radius of the camera from its target */
  96129. radius: number;
  96130. /** Define the camera target (the messh it should follow) */
  96131. target: Nullable<AbstractMesh>;
  96132. private _cartesianCoordinates;
  96133. /**
  96134. * Instantiates a new ArcFollowCamera
  96135. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96136. * @param name Define the name of the camera
  96137. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  96138. * @param beta Define the rotation angle of the camera around the elevation axis
  96139. * @param radius Define the radius of the camera from its target point
  96140. * @param target Define the target of the camera
  96141. * @param scene Define the scene the camera belongs to
  96142. */
  96143. constructor(name: string,
  96144. /** The longitudinal angle of the camera */
  96145. alpha: number,
  96146. /** The latitudinal angle of the camera */
  96147. beta: number,
  96148. /** The radius of the camera from its target */
  96149. radius: number,
  96150. /** Define the camera target (the messh it should follow) */
  96151. target: Nullable<AbstractMesh>, scene: Scene);
  96152. private _follow;
  96153. /** @hidden */
  96154. _checkInputs(): void;
  96155. /**
  96156. * Returns the class name of the object.
  96157. * It is mostly used internally for serialization purposes.
  96158. */
  96159. getClassName(): string;
  96160. }
  96161. }
  96162. declare module BABYLON {
  96163. /**
  96164. * Manage the keyboard inputs to control the movement of a follow camera.
  96165. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96166. */
  96167. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  96168. /**
  96169. * Defines the camera the input is attached to.
  96170. */
  96171. camera: FollowCamera;
  96172. /**
  96173. * Defines the list of key codes associated with the up action (increase heightOffset)
  96174. */
  96175. keysHeightOffsetIncr: number[];
  96176. /**
  96177. * Defines the list of key codes associated with the down action (decrease heightOffset)
  96178. */
  96179. keysHeightOffsetDecr: number[];
  96180. /**
  96181. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  96182. */
  96183. keysHeightOffsetModifierAlt: boolean;
  96184. /**
  96185. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  96186. */
  96187. keysHeightOffsetModifierCtrl: boolean;
  96188. /**
  96189. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  96190. */
  96191. keysHeightOffsetModifierShift: boolean;
  96192. /**
  96193. * Defines the list of key codes associated with the left action (increase rotationOffset)
  96194. */
  96195. keysRotationOffsetIncr: number[];
  96196. /**
  96197. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  96198. */
  96199. keysRotationOffsetDecr: number[];
  96200. /**
  96201. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  96202. */
  96203. keysRotationOffsetModifierAlt: boolean;
  96204. /**
  96205. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  96206. */
  96207. keysRotationOffsetModifierCtrl: boolean;
  96208. /**
  96209. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  96210. */
  96211. keysRotationOffsetModifierShift: boolean;
  96212. /**
  96213. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  96214. */
  96215. keysRadiusIncr: number[];
  96216. /**
  96217. * Defines the list of key codes associated with the zoom-out action (increase radius)
  96218. */
  96219. keysRadiusDecr: number[];
  96220. /**
  96221. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  96222. */
  96223. keysRadiusModifierAlt: boolean;
  96224. /**
  96225. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  96226. */
  96227. keysRadiusModifierCtrl: boolean;
  96228. /**
  96229. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  96230. */
  96231. keysRadiusModifierShift: boolean;
  96232. /**
  96233. * Defines the rate of change of heightOffset.
  96234. */
  96235. heightSensibility: number;
  96236. /**
  96237. * Defines the rate of change of rotationOffset.
  96238. */
  96239. rotationSensibility: number;
  96240. /**
  96241. * Defines the rate of change of radius.
  96242. */
  96243. radiusSensibility: number;
  96244. private _keys;
  96245. private _ctrlPressed;
  96246. private _altPressed;
  96247. private _shiftPressed;
  96248. private _onCanvasBlurObserver;
  96249. private _onKeyboardObserver;
  96250. private _engine;
  96251. private _scene;
  96252. /**
  96253. * Attach the input controls to a specific dom element to get the input from.
  96254. * @param element Defines the element the controls should be listened from
  96255. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96256. */
  96257. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96258. /**
  96259. * Detach the current controls from the specified dom element.
  96260. * @param element Defines the element to stop listening the inputs from
  96261. */
  96262. detachControl(element: Nullable<HTMLElement>): void;
  96263. /**
  96264. * Update the current camera state depending on the inputs that have been used this frame.
  96265. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96266. */
  96267. checkInputs(): void;
  96268. /**
  96269. * Gets the class name of the current input.
  96270. * @returns the class name
  96271. */
  96272. getClassName(): string;
  96273. /**
  96274. * Get the friendly name associated with the input class.
  96275. * @returns the input friendly name
  96276. */
  96277. getSimpleName(): string;
  96278. /**
  96279. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  96280. * allow modification of the heightOffset value.
  96281. */
  96282. private _modifierHeightOffset;
  96283. /**
  96284. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  96285. * allow modification of the rotationOffset value.
  96286. */
  96287. private _modifierRotationOffset;
  96288. /**
  96289. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  96290. * allow modification of the radius value.
  96291. */
  96292. private _modifierRadius;
  96293. }
  96294. }
  96295. declare module BABYLON {
  96296. interface FreeCameraInputsManager {
  96297. /**
  96298. * @hidden
  96299. */
  96300. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  96301. /**
  96302. * Add orientation input support to the input manager.
  96303. * @returns the current input manager
  96304. */
  96305. addDeviceOrientation(): FreeCameraInputsManager;
  96306. }
  96307. /**
  96308. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  96309. * Screen rotation is taken into account.
  96310. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96311. */
  96312. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  96313. private _camera;
  96314. private _screenOrientationAngle;
  96315. private _constantTranform;
  96316. private _screenQuaternion;
  96317. private _alpha;
  96318. private _beta;
  96319. private _gamma;
  96320. /**
  96321. * @hidden
  96322. */
  96323. _onDeviceOrientationChangedObservable: Observable<void>;
  96324. /**
  96325. * Instantiates a new input
  96326. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96327. */
  96328. constructor();
  96329. /**
  96330. * Define the camera controlled by the input.
  96331. */
  96332. camera: FreeCamera;
  96333. /**
  96334. * Attach the input controls to a specific dom element to get the input from.
  96335. * @param element Defines the element the controls should be listened from
  96336. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96337. */
  96338. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96339. private _orientationChanged;
  96340. private _deviceOrientation;
  96341. /**
  96342. * Detach the current controls from the specified dom element.
  96343. * @param element Defines the element to stop listening the inputs from
  96344. */
  96345. detachControl(element: Nullable<HTMLElement>): void;
  96346. /**
  96347. * Update the current camera state depending on the inputs that have been used this frame.
  96348. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96349. */
  96350. checkInputs(): void;
  96351. /**
  96352. * Gets the class name of the current intput.
  96353. * @returns the class name
  96354. */
  96355. getClassName(): string;
  96356. /**
  96357. * Get the friendly name associated with the input class.
  96358. * @returns the input friendly name
  96359. */
  96360. getSimpleName(): string;
  96361. }
  96362. }
  96363. declare module BABYLON {
  96364. /**
  96365. * Manage the gamepad inputs to control a free camera.
  96366. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96367. */
  96368. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  96369. /**
  96370. * Define the camera the input is attached to.
  96371. */
  96372. camera: FreeCamera;
  96373. /**
  96374. * Define the Gamepad controlling the input
  96375. */
  96376. gamepad: Nullable<Gamepad>;
  96377. /**
  96378. * Defines the gamepad rotation sensiblity.
  96379. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  96380. */
  96381. gamepadAngularSensibility: number;
  96382. /**
  96383. * Defines the gamepad move sensiblity.
  96384. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  96385. */
  96386. gamepadMoveSensibility: number;
  96387. private _onGamepadConnectedObserver;
  96388. private _onGamepadDisconnectedObserver;
  96389. private _cameraTransform;
  96390. private _deltaTransform;
  96391. private _vector3;
  96392. private _vector2;
  96393. /**
  96394. * Attach the input controls to a specific dom element to get the input from.
  96395. * @param element Defines the element the controls should be listened from
  96396. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96397. */
  96398. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96399. /**
  96400. * Detach the current controls from the specified dom element.
  96401. * @param element Defines the element to stop listening the inputs from
  96402. */
  96403. detachControl(element: Nullable<HTMLElement>): void;
  96404. /**
  96405. * Update the current camera state depending on the inputs that have been used this frame.
  96406. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96407. */
  96408. checkInputs(): void;
  96409. /**
  96410. * Gets the class name of the current intput.
  96411. * @returns the class name
  96412. */
  96413. getClassName(): string;
  96414. /**
  96415. * Get the friendly name associated with the input class.
  96416. * @returns the input friendly name
  96417. */
  96418. getSimpleName(): string;
  96419. }
  96420. }
  96421. declare module BABYLON {
  96422. /**
  96423. * Defines the potential axis of a Joystick
  96424. */
  96425. export enum JoystickAxis {
  96426. /** X axis */
  96427. X = 0,
  96428. /** Y axis */
  96429. Y = 1,
  96430. /** Z axis */
  96431. Z = 2
  96432. }
  96433. /**
  96434. * Class used to define virtual joystick (used in touch mode)
  96435. */
  96436. export class VirtualJoystick {
  96437. /**
  96438. * Gets or sets a boolean indicating that left and right values must be inverted
  96439. */
  96440. reverseLeftRight: boolean;
  96441. /**
  96442. * Gets or sets a boolean indicating that up and down values must be inverted
  96443. */
  96444. reverseUpDown: boolean;
  96445. /**
  96446. * Gets the offset value for the position (ie. the change of the position value)
  96447. */
  96448. deltaPosition: Vector3;
  96449. /**
  96450. * Gets a boolean indicating if the virtual joystick was pressed
  96451. */
  96452. pressed: boolean;
  96453. /**
  96454. * Canvas the virtual joystick will render onto, default z-index of this is 5
  96455. */
  96456. static Canvas: Nullable<HTMLCanvasElement>;
  96457. private static _globalJoystickIndex;
  96458. private static vjCanvasContext;
  96459. private static vjCanvasWidth;
  96460. private static vjCanvasHeight;
  96461. private static halfWidth;
  96462. private _action;
  96463. private _axisTargetedByLeftAndRight;
  96464. private _axisTargetedByUpAndDown;
  96465. private _joystickSensibility;
  96466. private _inversedSensibility;
  96467. private _joystickPointerID;
  96468. private _joystickColor;
  96469. private _joystickPointerPos;
  96470. private _joystickPreviousPointerPos;
  96471. private _joystickPointerStartPos;
  96472. private _deltaJoystickVector;
  96473. private _leftJoystick;
  96474. private _touches;
  96475. private _onPointerDownHandlerRef;
  96476. private _onPointerMoveHandlerRef;
  96477. private _onPointerUpHandlerRef;
  96478. private _onResize;
  96479. /**
  96480. * Creates a new virtual joystick
  96481. * @param leftJoystick defines that the joystick is for left hand (false by default)
  96482. */
  96483. constructor(leftJoystick?: boolean);
  96484. /**
  96485. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  96486. * @param newJoystickSensibility defines the new sensibility
  96487. */
  96488. setJoystickSensibility(newJoystickSensibility: number): void;
  96489. private _onPointerDown;
  96490. private _onPointerMove;
  96491. private _onPointerUp;
  96492. /**
  96493. * Change the color of the virtual joystick
  96494. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  96495. */
  96496. setJoystickColor(newColor: string): void;
  96497. /**
  96498. * Defines a callback to call when the joystick is touched
  96499. * @param action defines the callback
  96500. */
  96501. setActionOnTouch(action: () => any): void;
  96502. /**
  96503. * Defines which axis you'd like to control for left & right
  96504. * @param axis defines the axis to use
  96505. */
  96506. setAxisForLeftRight(axis: JoystickAxis): void;
  96507. /**
  96508. * Defines which axis you'd like to control for up & down
  96509. * @param axis defines the axis to use
  96510. */
  96511. setAxisForUpDown(axis: JoystickAxis): void;
  96512. private _drawVirtualJoystick;
  96513. /**
  96514. * Release internal HTML canvas
  96515. */
  96516. releaseCanvas(): void;
  96517. }
  96518. }
  96519. declare module BABYLON {
  96520. interface FreeCameraInputsManager {
  96521. /**
  96522. * Add virtual joystick input support to the input manager.
  96523. * @returns the current input manager
  96524. */
  96525. addVirtualJoystick(): FreeCameraInputsManager;
  96526. }
  96527. /**
  96528. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  96529. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96530. */
  96531. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  96532. /**
  96533. * Defines the camera the input is attached to.
  96534. */
  96535. camera: FreeCamera;
  96536. private _leftjoystick;
  96537. private _rightjoystick;
  96538. /**
  96539. * Gets the left stick of the virtual joystick.
  96540. * @returns The virtual Joystick
  96541. */
  96542. getLeftJoystick(): VirtualJoystick;
  96543. /**
  96544. * Gets the right stick of the virtual joystick.
  96545. * @returns The virtual Joystick
  96546. */
  96547. getRightJoystick(): VirtualJoystick;
  96548. /**
  96549. * Update the current camera state depending on the inputs that have been used this frame.
  96550. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96551. */
  96552. checkInputs(): void;
  96553. /**
  96554. * Attach the input controls to a specific dom element to get the input from.
  96555. * @param element Defines the element the controls should be listened from
  96556. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96557. */
  96558. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96559. /**
  96560. * Detach the current controls from the specified dom element.
  96561. * @param element Defines the element to stop listening the inputs from
  96562. */
  96563. detachControl(element: Nullable<HTMLElement>): void;
  96564. /**
  96565. * Gets the class name of the current intput.
  96566. * @returns the class name
  96567. */
  96568. getClassName(): string;
  96569. /**
  96570. * Get the friendly name associated with the input class.
  96571. * @returns the input friendly name
  96572. */
  96573. getSimpleName(): string;
  96574. }
  96575. }
  96576. declare module BABYLON {
  96577. /**
  96578. * This represents a FPS type of camera controlled by touch.
  96579. * This is like a universal camera minus the Gamepad controls.
  96580. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96581. */
  96582. export class TouchCamera extends FreeCamera {
  96583. /**
  96584. * Defines the touch sensibility for rotation.
  96585. * The higher the faster.
  96586. */
  96587. touchAngularSensibility: number;
  96588. /**
  96589. * Defines the touch sensibility for move.
  96590. * The higher the faster.
  96591. */
  96592. touchMoveSensibility: number;
  96593. /**
  96594. * Instantiates a new touch camera.
  96595. * This represents a FPS type of camera controlled by touch.
  96596. * This is like a universal camera minus the Gamepad controls.
  96597. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96598. * @param name Define the name of the camera in the scene
  96599. * @param position Define the start position of the camera in the scene
  96600. * @param scene Define the scene the camera belongs to
  96601. */
  96602. constructor(name: string, position: Vector3, scene: Scene);
  96603. /**
  96604. * Gets the current object class name.
  96605. * @return the class name
  96606. */
  96607. getClassName(): string;
  96608. /** @hidden */
  96609. _setupInputs(): void;
  96610. }
  96611. }
  96612. declare module BABYLON {
  96613. /**
  96614. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  96615. * being tilted forward or back and left or right.
  96616. */
  96617. export class DeviceOrientationCamera extends FreeCamera {
  96618. private _initialQuaternion;
  96619. private _quaternionCache;
  96620. private _tmpDragQuaternion;
  96621. /**
  96622. * Creates a new device orientation camera
  96623. * @param name The name of the camera
  96624. * @param position The start position camera
  96625. * @param scene The scene the camera belongs to
  96626. */
  96627. constructor(name: string, position: Vector3, scene: Scene);
  96628. /**
  96629. * Disabled pointer input on first orientation sensor update (Default: true)
  96630. */
  96631. disablePointerInputWhenUsingDeviceOrientation: boolean;
  96632. private _dragFactor;
  96633. /**
  96634. * Enabled turning on the y axis when the orientation sensor is active
  96635. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  96636. */
  96637. enableHorizontalDragging(dragFactor?: number): void;
  96638. /**
  96639. * Gets the current instance class name ("DeviceOrientationCamera").
  96640. * This helps avoiding instanceof at run time.
  96641. * @returns the class name
  96642. */
  96643. getClassName(): string;
  96644. /**
  96645. * @hidden
  96646. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  96647. */
  96648. _checkInputs(): void;
  96649. /**
  96650. * Reset the camera to its default orientation on the specified axis only.
  96651. * @param axis The axis to reset
  96652. */
  96653. resetToCurrentRotation(axis?: Axis): void;
  96654. }
  96655. }
  96656. declare module BABYLON {
  96657. /**
  96658. * 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,
  96659. * which still works and will still be found in many Playgrounds.
  96660. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96661. */
  96662. export class UniversalCamera extends TouchCamera {
  96663. /**
  96664. * Defines the gamepad rotation sensiblity.
  96665. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  96666. */
  96667. gamepadAngularSensibility: number;
  96668. /**
  96669. * Defines the gamepad move sensiblity.
  96670. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  96671. */
  96672. gamepadMoveSensibility: number;
  96673. /**
  96674. * 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,
  96675. * which still works and will still be found in many Playgrounds.
  96676. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96677. * @param name Define the name of the camera in the scene
  96678. * @param position Define the start position of the camera in the scene
  96679. * @param scene Define the scene the camera belongs to
  96680. */
  96681. constructor(name: string, position: Vector3, scene: Scene);
  96682. /**
  96683. * Gets the current object class name.
  96684. * @return the class name
  96685. */
  96686. getClassName(): string;
  96687. }
  96688. }
  96689. declare module BABYLON {
  96690. /**
  96691. * This represents a FPS type of camera. This is only here for back compat purpose.
  96692. * Please use the UniversalCamera instead as both are identical.
  96693. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96694. */
  96695. export class GamepadCamera extends UniversalCamera {
  96696. /**
  96697. * Instantiates a new Gamepad Camera
  96698. * This represents a FPS type of camera. This is only here for back compat purpose.
  96699. * Please use the UniversalCamera instead as both are identical.
  96700. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96701. * @param name Define the name of the camera in the scene
  96702. * @param position Define the start position of the camera in the scene
  96703. * @param scene Define the scene the camera belongs to
  96704. */
  96705. constructor(name: string, position: Vector3, scene: Scene);
  96706. /**
  96707. * Gets the current object class name.
  96708. * @return the class name
  96709. */
  96710. getClassName(): string;
  96711. }
  96712. }
  96713. declare module BABYLON {
  96714. /** @hidden */
  96715. export var passPixelShader: {
  96716. name: string;
  96717. shader: string;
  96718. };
  96719. }
  96720. declare module BABYLON {
  96721. /** @hidden */
  96722. export var passCubePixelShader: {
  96723. name: string;
  96724. shader: string;
  96725. };
  96726. }
  96727. declare module BABYLON {
  96728. /**
  96729. * PassPostProcess which produces an output the same as it's input
  96730. */
  96731. export class PassPostProcess extends PostProcess {
  96732. /**
  96733. * Creates the PassPostProcess
  96734. * @param name The name of the effect.
  96735. * @param options The required width/height ratio to downsize to before computing the render pass.
  96736. * @param camera The camera to apply the render pass to.
  96737. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  96738. * @param engine The engine which the post process will be applied. (default: current engine)
  96739. * @param reusable If the post process can be reused on the same frame. (default: false)
  96740. * @param textureType The type of texture to be used when performing the post processing.
  96741. * @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)
  96742. */
  96743. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  96744. }
  96745. /**
  96746. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  96747. */
  96748. export class PassCubePostProcess extends PostProcess {
  96749. private _face;
  96750. /**
  96751. * Gets or sets the cube face to display.
  96752. * * 0 is +X
  96753. * * 1 is -X
  96754. * * 2 is +Y
  96755. * * 3 is -Y
  96756. * * 4 is +Z
  96757. * * 5 is -Z
  96758. */
  96759. face: number;
  96760. /**
  96761. * Creates the PassCubePostProcess
  96762. * @param name The name of the effect.
  96763. * @param options The required width/height ratio to downsize to before computing the render pass.
  96764. * @param camera The camera to apply the render pass to.
  96765. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  96766. * @param engine The engine which the post process will be applied. (default: current engine)
  96767. * @param reusable If the post process can be reused on the same frame. (default: false)
  96768. * @param textureType The type of texture to be used when performing the post processing.
  96769. * @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)
  96770. */
  96771. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  96772. }
  96773. }
  96774. declare module BABYLON {
  96775. /** @hidden */
  96776. export var anaglyphPixelShader: {
  96777. name: string;
  96778. shader: string;
  96779. };
  96780. }
  96781. declare module BABYLON {
  96782. /**
  96783. * Postprocess used to generate anaglyphic rendering
  96784. */
  96785. export class AnaglyphPostProcess extends PostProcess {
  96786. private _passedProcess;
  96787. /**
  96788. * Creates a new AnaglyphPostProcess
  96789. * @param name defines postprocess name
  96790. * @param options defines creation options or target ratio scale
  96791. * @param rigCameras defines cameras using this postprocess
  96792. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  96793. * @param engine defines hosting engine
  96794. * @param reusable defines if the postprocess will be reused multiple times per frame
  96795. */
  96796. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  96797. }
  96798. }
  96799. declare module BABYLON {
  96800. /**
  96801. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  96802. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  96803. */
  96804. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  96805. /**
  96806. * Creates a new AnaglyphArcRotateCamera
  96807. * @param name defines camera name
  96808. * @param alpha defines alpha angle (in radians)
  96809. * @param beta defines beta angle (in radians)
  96810. * @param radius defines radius
  96811. * @param target defines camera target
  96812. * @param interaxialDistance defines distance between each color axis
  96813. * @param scene defines the hosting scene
  96814. */
  96815. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  96816. /**
  96817. * Gets camera class name
  96818. * @returns AnaglyphArcRotateCamera
  96819. */
  96820. getClassName(): string;
  96821. }
  96822. }
  96823. declare module BABYLON {
  96824. /**
  96825. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  96826. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  96827. */
  96828. export class AnaglyphFreeCamera extends FreeCamera {
  96829. /**
  96830. * Creates a new AnaglyphFreeCamera
  96831. * @param name defines camera name
  96832. * @param position defines initial position
  96833. * @param interaxialDistance defines distance between each color axis
  96834. * @param scene defines the hosting scene
  96835. */
  96836. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  96837. /**
  96838. * Gets camera class name
  96839. * @returns AnaglyphFreeCamera
  96840. */
  96841. getClassName(): string;
  96842. }
  96843. }
  96844. declare module BABYLON {
  96845. /**
  96846. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  96847. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  96848. */
  96849. export class AnaglyphGamepadCamera extends GamepadCamera {
  96850. /**
  96851. * Creates a new AnaglyphGamepadCamera
  96852. * @param name defines camera name
  96853. * @param position defines initial position
  96854. * @param interaxialDistance defines distance between each color axis
  96855. * @param scene defines the hosting scene
  96856. */
  96857. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  96858. /**
  96859. * Gets camera class name
  96860. * @returns AnaglyphGamepadCamera
  96861. */
  96862. getClassName(): string;
  96863. }
  96864. }
  96865. declare module BABYLON {
  96866. /**
  96867. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  96868. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  96869. */
  96870. export class AnaglyphUniversalCamera extends UniversalCamera {
  96871. /**
  96872. * Creates a new AnaglyphUniversalCamera
  96873. * @param name defines camera name
  96874. * @param position defines initial position
  96875. * @param interaxialDistance defines distance between each color axis
  96876. * @param scene defines the hosting scene
  96877. */
  96878. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  96879. /**
  96880. * Gets camera class name
  96881. * @returns AnaglyphUniversalCamera
  96882. */
  96883. getClassName(): string;
  96884. }
  96885. }
  96886. declare module BABYLON {
  96887. /** @hidden */
  96888. export var stereoscopicInterlacePixelShader: {
  96889. name: string;
  96890. shader: string;
  96891. };
  96892. }
  96893. declare module BABYLON {
  96894. /**
  96895. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  96896. */
  96897. export class StereoscopicInterlacePostProcess extends PostProcess {
  96898. private _stepSize;
  96899. private _passedProcess;
  96900. /**
  96901. * Initializes a StereoscopicInterlacePostProcess
  96902. * @param name The name of the effect.
  96903. * @param rigCameras The rig cameras to be appled to the post process
  96904. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  96905. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  96906. * @param engine The engine which the post process will be applied. (default: current engine)
  96907. * @param reusable If the post process can be reused on the same frame. (default: false)
  96908. */
  96909. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  96910. }
  96911. }
  96912. declare module BABYLON {
  96913. /**
  96914. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  96915. * @see http://doc.babylonjs.com/features/cameras
  96916. */
  96917. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  96918. /**
  96919. * Creates a new StereoscopicArcRotateCamera
  96920. * @param name defines camera name
  96921. * @param alpha defines alpha angle (in radians)
  96922. * @param beta defines beta angle (in radians)
  96923. * @param radius defines radius
  96924. * @param target defines camera target
  96925. * @param interaxialDistance defines distance between each color axis
  96926. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  96927. * @param scene defines the hosting scene
  96928. */
  96929. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  96930. /**
  96931. * Gets camera class name
  96932. * @returns StereoscopicArcRotateCamera
  96933. */
  96934. getClassName(): string;
  96935. }
  96936. }
  96937. declare module BABYLON {
  96938. /**
  96939. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  96940. * @see http://doc.babylonjs.com/features/cameras
  96941. */
  96942. export class StereoscopicFreeCamera extends FreeCamera {
  96943. /**
  96944. * Creates a new StereoscopicFreeCamera
  96945. * @param name defines camera name
  96946. * @param position defines initial position
  96947. * @param interaxialDistance defines distance between each color axis
  96948. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  96949. * @param scene defines the hosting scene
  96950. */
  96951. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  96952. /**
  96953. * Gets camera class name
  96954. * @returns StereoscopicFreeCamera
  96955. */
  96956. getClassName(): string;
  96957. }
  96958. }
  96959. declare module BABYLON {
  96960. /**
  96961. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  96962. * @see http://doc.babylonjs.com/features/cameras
  96963. */
  96964. export class StereoscopicGamepadCamera extends GamepadCamera {
  96965. /**
  96966. * Creates a new StereoscopicGamepadCamera
  96967. * @param name defines camera name
  96968. * @param position defines initial position
  96969. * @param interaxialDistance defines distance between each color axis
  96970. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  96971. * @param scene defines the hosting scene
  96972. */
  96973. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  96974. /**
  96975. * Gets camera class name
  96976. * @returns StereoscopicGamepadCamera
  96977. */
  96978. getClassName(): string;
  96979. }
  96980. }
  96981. declare module BABYLON {
  96982. /**
  96983. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  96984. * @see http://doc.babylonjs.com/features/cameras
  96985. */
  96986. export class StereoscopicUniversalCamera extends UniversalCamera {
  96987. /**
  96988. * Creates a new StereoscopicUniversalCamera
  96989. * @param name defines camera name
  96990. * @param position defines initial position
  96991. * @param interaxialDistance defines distance between each color axis
  96992. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  96993. * @param scene defines the hosting scene
  96994. */
  96995. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  96996. /**
  96997. * Gets camera class name
  96998. * @returns StereoscopicUniversalCamera
  96999. */
  97000. getClassName(): string;
  97001. }
  97002. }
  97003. declare module BABYLON {
  97004. /**
  97005. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  97006. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  97007. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  97008. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  97009. */
  97010. export class VirtualJoysticksCamera extends FreeCamera {
  97011. /**
  97012. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  97013. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  97014. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  97015. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  97016. * @param name Define the name of the camera in the scene
  97017. * @param position Define the start position of the camera in the scene
  97018. * @param scene Define the scene the camera belongs to
  97019. */
  97020. constructor(name: string, position: Vector3, scene: Scene);
  97021. /**
  97022. * Gets the current object class name.
  97023. * @return the class name
  97024. */
  97025. getClassName(): string;
  97026. }
  97027. }
  97028. declare module BABYLON {
  97029. /**
  97030. * This represents all the required metrics to create a VR camera.
  97031. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  97032. */
  97033. export class VRCameraMetrics {
  97034. /**
  97035. * Define the horizontal resolution off the screen.
  97036. */
  97037. hResolution: number;
  97038. /**
  97039. * Define the vertical resolution off the screen.
  97040. */
  97041. vResolution: number;
  97042. /**
  97043. * Define the horizontal screen size.
  97044. */
  97045. hScreenSize: number;
  97046. /**
  97047. * Define the vertical screen size.
  97048. */
  97049. vScreenSize: number;
  97050. /**
  97051. * Define the vertical screen center position.
  97052. */
  97053. vScreenCenter: number;
  97054. /**
  97055. * Define the distance of the eyes to the screen.
  97056. */
  97057. eyeToScreenDistance: number;
  97058. /**
  97059. * Define the distance between both lenses
  97060. */
  97061. lensSeparationDistance: number;
  97062. /**
  97063. * Define the distance between both viewer's eyes.
  97064. */
  97065. interpupillaryDistance: number;
  97066. /**
  97067. * Define the distortion factor of the VR postprocess.
  97068. * Please, touch with care.
  97069. */
  97070. distortionK: number[];
  97071. /**
  97072. * Define the chromatic aberration correction factors for the VR post process.
  97073. */
  97074. chromaAbCorrection: number[];
  97075. /**
  97076. * Define the scale factor of the post process.
  97077. * The smaller the better but the slower.
  97078. */
  97079. postProcessScaleFactor: number;
  97080. /**
  97081. * Define an offset for the lens center.
  97082. */
  97083. lensCenterOffset: number;
  97084. /**
  97085. * Define if the current vr camera should compensate the distortion of the lense or not.
  97086. */
  97087. compensateDistortion: boolean;
  97088. /**
  97089. * Defines if multiview should be enabled when rendering (Default: false)
  97090. */
  97091. multiviewEnabled: boolean;
  97092. /**
  97093. * Gets the rendering aspect ratio based on the provided resolutions.
  97094. */
  97095. readonly aspectRatio: number;
  97096. /**
  97097. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  97098. */
  97099. readonly aspectRatioFov: number;
  97100. /**
  97101. * @hidden
  97102. */
  97103. readonly leftHMatrix: Matrix;
  97104. /**
  97105. * @hidden
  97106. */
  97107. readonly rightHMatrix: Matrix;
  97108. /**
  97109. * @hidden
  97110. */
  97111. readonly leftPreViewMatrix: Matrix;
  97112. /**
  97113. * @hidden
  97114. */
  97115. readonly rightPreViewMatrix: Matrix;
  97116. /**
  97117. * Get the default VRMetrics based on the most generic setup.
  97118. * @returns the default vr metrics
  97119. */
  97120. static GetDefault(): VRCameraMetrics;
  97121. }
  97122. }
  97123. declare module BABYLON {
  97124. /** @hidden */
  97125. export var vrDistortionCorrectionPixelShader: {
  97126. name: string;
  97127. shader: string;
  97128. };
  97129. }
  97130. declare module BABYLON {
  97131. /**
  97132. * VRDistortionCorrectionPostProcess used for mobile VR
  97133. */
  97134. export class VRDistortionCorrectionPostProcess extends PostProcess {
  97135. private _isRightEye;
  97136. private _distortionFactors;
  97137. private _postProcessScaleFactor;
  97138. private _lensCenterOffset;
  97139. private _scaleIn;
  97140. private _scaleFactor;
  97141. private _lensCenter;
  97142. /**
  97143. * Initializes the VRDistortionCorrectionPostProcess
  97144. * @param name The name of the effect.
  97145. * @param camera The camera to apply the render pass to.
  97146. * @param isRightEye If this is for the right eye distortion
  97147. * @param vrMetrics All the required metrics for the VR camera
  97148. */
  97149. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  97150. }
  97151. }
  97152. declare module BABYLON {
  97153. /**
  97154. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  97155. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97156. */
  97157. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  97158. /**
  97159. * Creates a new VRDeviceOrientationArcRotateCamera
  97160. * @param name defines camera name
  97161. * @param alpha defines the camera rotation along the logitudinal axis
  97162. * @param beta defines the camera rotation along the latitudinal axis
  97163. * @param radius defines the camera distance from its target
  97164. * @param target defines the camera target
  97165. * @param scene defines the scene the camera belongs to
  97166. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97167. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97168. */
  97169. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97170. /**
  97171. * Gets camera class name
  97172. * @returns VRDeviceOrientationArcRotateCamera
  97173. */
  97174. getClassName(): string;
  97175. }
  97176. }
  97177. declare module BABYLON {
  97178. /**
  97179. * Camera used to simulate VR rendering (based on FreeCamera)
  97180. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97181. */
  97182. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  97183. /**
  97184. * Creates a new VRDeviceOrientationFreeCamera
  97185. * @param name defines camera name
  97186. * @param position defines the start position of the camera
  97187. * @param scene defines the scene the camera belongs to
  97188. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97189. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97190. */
  97191. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97192. /**
  97193. * Gets camera class name
  97194. * @returns VRDeviceOrientationFreeCamera
  97195. */
  97196. getClassName(): string;
  97197. }
  97198. }
  97199. declare module BABYLON {
  97200. /**
  97201. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  97202. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97203. */
  97204. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  97205. /**
  97206. * Creates a new VRDeviceOrientationGamepadCamera
  97207. * @param name defines camera name
  97208. * @param position defines the start position of the camera
  97209. * @param scene defines the scene the camera belongs to
  97210. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97211. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97212. */
  97213. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97214. /**
  97215. * Gets camera class name
  97216. * @returns VRDeviceOrientationGamepadCamera
  97217. */
  97218. getClassName(): string;
  97219. }
  97220. }
  97221. declare module BABYLON {
  97222. /**
  97223. * Defines supported buttons for XBox360 compatible gamepads
  97224. */
  97225. export enum Xbox360Button {
  97226. /** A */
  97227. A = 0,
  97228. /** B */
  97229. B = 1,
  97230. /** X */
  97231. X = 2,
  97232. /** Y */
  97233. Y = 3,
  97234. /** Start */
  97235. Start = 4,
  97236. /** Back */
  97237. Back = 5,
  97238. /** Left button */
  97239. LB = 6,
  97240. /** Right button */
  97241. RB = 7,
  97242. /** Left stick */
  97243. LeftStick = 8,
  97244. /** Right stick */
  97245. RightStick = 9
  97246. }
  97247. /** Defines values for XBox360 DPad */
  97248. export enum Xbox360Dpad {
  97249. /** Up */
  97250. Up = 0,
  97251. /** Down */
  97252. Down = 1,
  97253. /** Left */
  97254. Left = 2,
  97255. /** Right */
  97256. Right = 3
  97257. }
  97258. /**
  97259. * Defines a XBox360 gamepad
  97260. */
  97261. export class Xbox360Pad extends Gamepad {
  97262. private _leftTrigger;
  97263. private _rightTrigger;
  97264. private _onlefttriggerchanged;
  97265. private _onrighttriggerchanged;
  97266. private _onbuttondown;
  97267. private _onbuttonup;
  97268. private _ondpaddown;
  97269. private _ondpadup;
  97270. /** Observable raised when a button is pressed */
  97271. onButtonDownObservable: Observable<Xbox360Button>;
  97272. /** Observable raised when a button is released */
  97273. onButtonUpObservable: Observable<Xbox360Button>;
  97274. /** Observable raised when a pad is pressed */
  97275. onPadDownObservable: Observable<Xbox360Dpad>;
  97276. /** Observable raised when a pad is released */
  97277. onPadUpObservable: Observable<Xbox360Dpad>;
  97278. private _buttonA;
  97279. private _buttonB;
  97280. private _buttonX;
  97281. private _buttonY;
  97282. private _buttonBack;
  97283. private _buttonStart;
  97284. private _buttonLB;
  97285. private _buttonRB;
  97286. private _buttonLeftStick;
  97287. private _buttonRightStick;
  97288. private _dPadUp;
  97289. private _dPadDown;
  97290. private _dPadLeft;
  97291. private _dPadRight;
  97292. private _isXboxOnePad;
  97293. /**
  97294. * Creates a new XBox360 gamepad object
  97295. * @param id defines the id of this gamepad
  97296. * @param index defines its index
  97297. * @param gamepad defines the internal HTML gamepad object
  97298. * @param xboxOne defines if it is a XBox One gamepad
  97299. */
  97300. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  97301. /**
  97302. * Defines the callback to call when left trigger is pressed
  97303. * @param callback defines the callback to use
  97304. */
  97305. onlefttriggerchanged(callback: (value: number) => void): void;
  97306. /**
  97307. * Defines the callback to call when right trigger is pressed
  97308. * @param callback defines the callback to use
  97309. */
  97310. onrighttriggerchanged(callback: (value: number) => void): void;
  97311. /**
  97312. * Gets the left trigger value
  97313. */
  97314. /**
  97315. * Sets the left trigger value
  97316. */
  97317. leftTrigger: number;
  97318. /**
  97319. * Gets the right trigger value
  97320. */
  97321. /**
  97322. * Sets the right trigger value
  97323. */
  97324. rightTrigger: number;
  97325. /**
  97326. * Defines the callback to call when a button is pressed
  97327. * @param callback defines the callback to use
  97328. */
  97329. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  97330. /**
  97331. * Defines the callback to call when a button is released
  97332. * @param callback defines the callback to use
  97333. */
  97334. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  97335. /**
  97336. * Defines the callback to call when a pad is pressed
  97337. * @param callback defines the callback to use
  97338. */
  97339. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  97340. /**
  97341. * Defines the callback to call when a pad is released
  97342. * @param callback defines the callback to use
  97343. */
  97344. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  97345. private _setButtonValue;
  97346. private _setDPadValue;
  97347. /**
  97348. * Gets the value of the `A` button
  97349. */
  97350. /**
  97351. * Sets the value of the `A` button
  97352. */
  97353. buttonA: number;
  97354. /**
  97355. * Gets the value of the `B` button
  97356. */
  97357. /**
  97358. * Sets the value of the `B` button
  97359. */
  97360. buttonB: number;
  97361. /**
  97362. * Gets the value of the `X` button
  97363. */
  97364. /**
  97365. * Sets the value of the `X` button
  97366. */
  97367. buttonX: number;
  97368. /**
  97369. * Gets the value of the `Y` button
  97370. */
  97371. /**
  97372. * Sets the value of the `Y` button
  97373. */
  97374. buttonY: number;
  97375. /**
  97376. * Gets the value of the `Start` button
  97377. */
  97378. /**
  97379. * Sets the value of the `Start` button
  97380. */
  97381. buttonStart: number;
  97382. /**
  97383. * Gets the value of the `Back` button
  97384. */
  97385. /**
  97386. * Sets the value of the `Back` button
  97387. */
  97388. buttonBack: number;
  97389. /**
  97390. * Gets the value of the `Left` button
  97391. */
  97392. /**
  97393. * Sets the value of the `Left` button
  97394. */
  97395. buttonLB: number;
  97396. /**
  97397. * Gets the value of the `Right` button
  97398. */
  97399. /**
  97400. * Sets the value of the `Right` button
  97401. */
  97402. buttonRB: number;
  97403. /**
  97404. * Gets the value of the Left joystick
  97405. */
  97406. /**
  97407. * Sets the value of the Left joystick
  97408. */
  97409. buttonLeftStick: number;
  97410. /**
  97411. * Gets the value of the Right joystick
  97412. */
  97413. /**
  97414. * Sets the value of the Right joystick
  97415. */
  97416. buttonRightStick: number;
  97417. /**
  97418. * Gets the value of D-pad up
  97419. */
  97420. /**
  97421. * Sets the value of D-pad up
  97422. */
  97423. dPadUp: number;
  97424. /**
  97425. * Gets the value of D-pad down
  97426. */
  97427. /**
  97428. * Sets the value of D-pad down
  97429. */
  97430. dPadDown: number;
  97431. /**
  97432. * Gets the value of D-pad left
  97433. */
  97434. /**
  97435. * Sets the value of D-pad left
  97436. */
  97437. dPadLeft: number;
  97438. /**
  97439. * Gets the value of D-pad right
  97440. */
  97441. /**
  97442. * Sets the value of D-pad right
  97443. */
  97444. dPadRight: number;
  97445. /**
  97446. * Force the gamepad to synchronize with device values
  97447. */
  97448. update(): void;
  97449. /**
  97450. * Disposes the gamepad
  97451. */
  97452. dispose(): void;
  97453. }
  97454. }
  97455. declare module BABYLON {
  97456. /**
  97457. * Base class of materials working in push mode in babylon JS
  97458. * @hidden
  97459. */
  97460. export class PushMaterial extends Material {
  97461. protected _activeEffect: Effect;
  97462. protected _normalMatrix: Matrix;
  97463. /**
  97464. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  97465. * This means that the material can keep using a previous shader while a new one is being compiled.
  97466. * This is mostly used when shader parallel compilation is supported (true by default)
  97467. */
  97468. allowShaderHotSwapping: boolean;
  97469. constructor(name: string, scene: Scene);
  97470. getEffect(): Effect;
  97471. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  97472. /**
  97473. * Binds the given world matrix to the active effect
  97474. *
  97475. * @param world the matrix to bind
  97476. */
  97477. bindOnlyWorldMatrix(world: Matrix): void;
  97478. /**
  97479. * Binds the given normal matrix to the active effect
  97480. *
  97481. * @param normalMatrix the matrix to bind
  97482. */
  97483. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  97484. bind(world: Matrix, mesh?: Mesh): void;
  97485. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  97486. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  97487. }
  97488. }
  97489. declare module BABYLON {
  97490. /**
  97491. * This groups all the flags used to control the materials channel.
  97492. */
  97493. export class MaterialFlags {
  97494. private static _DiffuseTextureEnabled;
  97495. /**
  97496. * Are diffuse textures enabled in the application.
  97497. */
  97498. static DiffuseTextureEnabled: boolean;
  97499. private static _AmbientTextureEnabled;
  97500. /**
  97501. * Are ambient textures enabled in the application.
  97502. */
  97503. static AmbientTextureEnabled: boolean;
  97504. private static _OpacityTextureEnabled;
  97505. /**
  97506. * Are opacity textures enabled in the application.
  97507. */
  97508. static OpacityTextureEnabled: boolean;
  97509. private static _ReflectionTextureEnabled;
  97510. /**
  97511. * Are reflection textures enabled in the application.
  97512. */
  97513. static ReflectionTextureEnabled: boolean;
  97514. private static _EmissiveTextureEnabled;
  97515. /**
  97516. * Are emissive textures enabled in the application.
  97517. */
  97518. static EmissiveTextureEnabled: boolean;
  97519. private static _SpecularTextureEnabled;
  97520. /**
  97521. * Are specular textures enabled in the application.
  97522. */
  97523. static SpecularTextureEnabled: boolean;
  97524. private static _BumpTextureEnabled;
  97525. /**
  97526. * Are bump textures enabled in the application.
  97527. */
  97528. static BumpTextureEnabled: boolean;
  97529. private static _LightmapTextureEnabled;
  97530. /**
  97531. * Are lightmap textures enabled in the application.
  97532. */
  97533. static LightmapTextureEnabled: boolean;
  97534. private static _RefractionTextureEnabled;
  97535. /**
  97536. * Are refraction textures enabled in the application.
  97537. */
  97538. static RefractionTextureEnabled: boolean;
  97539. private static _ColorGradingTextureEnabled;
  97540. /**
  97541. * Are color grading textures enabled in the application.
  97542. */
  97543. static ColorGradingTextureEnabled: boolean;
  97544. private static _FresnelEnabled;
  97545. /**
  97546. * Are fresnels enabled in the application.
  97547. */
  97548. static FresnelEnabled: boolean;
  97549. private static _ClearCoatTextureEnabled;
  97550. /**
  97551. * Are clear coat textures enabled in the application.
  97552. */
  97553. static ClearCoatTextureEnabled: boolean;
  97554. private static _ClearCoatBumpTextureEnabled;
  97555. /**
  97556. * Are clear coat bump textures enabled in the application.
  97557. */
  97558. static ClearCoatBumpTextureEnabled: boolean;
  97559. private static _ClearCoatTintTextureEnabled;
  97560. /**
  97561. * Are clear coat tint textures enabled in the application.
  97562. */
  97563. static ClearCoatTintTextureEnabled: boolean;
  97564. private static _SheenTextureEnabled;
  97565. /**
  97566. * Are sheen textures enabled in the application.
  97567. */
  97568. static SheenTextureEnabled: boolean;
  97569. private static _AnisotropicTextureEnabled;
  97570. /**
  97571. * Are anisotropic textures enabled in the application.
  97572. */
  97573. static AnisotropicTextureEnabled: boolean;
  97574. private static _ThicknessTextureEnabled;
  97575. /**
  97576. * Are thickness textures enabled in the application.
  97577. */
  97578. static ThicknessTextureEnabled: boolean;
  97579. }
  97580. }
  97581. declare module BABYLON {
  97582. /** @hidden */
  97583. export var defaultFragmentDeclaration: {
  97584. name: string;
  97585. shader: string;
  97586. };
  97587. }
  97588. declare module BABYLON {
  97589. /** @hidden */
  97590. export var defaultUboDeclaration: {
  97591. name: string;
  97592. shader: string;
  97593. };
  97594. }
  97595. declare module BABYLON {
  97596. /** @hidden */
  97597. export var lightFragmentDeclaration: {
  97598. name: string;
  97599. shader: string;
  97600. };
  97601. }
  97602. declare module BABYLON {
  97603. /** @hidden */
  97604. export var lightUboDeclaration: {
  97605. name: string;
  97606. shader: string;
  97607. };
  97608. }
  97609. declare module BABYLON {
  97610. /** @hidden */
  97611. export var lightsFragmentFunctions: {
  97612. name: string;
  97613. shader: string;
  97614. };
  97615. }
  97616. declare module BABYLON {
  97617. /** @hidden */
  97618. export var shadowsFragmentFunctions: {
  97619. name: string;
  97620. shader: string;
  97621. };
  97622. }
  97623. declare module BABYLON {
  97624. /** @hidden */
  97625. export var fresnelFunction: {
  97626. name: string;
  97627. shader: string;
  97628. };
  97629. }
  97630. declare module BABYLON {
  97631. /** @hidden */
  97632. export var reflectionFunction: {
  97633. name: string;
  97634. shader: string;
  97635. };
  97636. }
  97637. declare module BABYLON {
  97638. /** @hidden */
  97639. export var bumpFragmentFunctions: {
  97640. name: string;
  97641. shader: string;
  97642. };
  97643. }
  97644. declare module BABYLON {
  97645. /** @hidden */
  97646. export var logDepthDeclaration: {
  97647. name: string;
  97648. shader: string;
  97649. };
  97650. }
  97651. declare module BABYLON {
  97652. /** @hidden */
  97653. export var bumpFragment: {
  97654. name: string;
  97655. shader: string;
  97656. };
  97657. }
  97658. declare module BABYLON {
  97659. /** @hidden */
  97660. export var depthPrePass: {
  97661. name: string;
  97662. shader: string;
  97663. };
  97664. }
  97665. declare module BABYLON {
  97666. /** @hidden */
  97667. export var lightFragment: {
  97668. name: string;
  97669. shader: string;
  97670. };
  97671. }
  97672. declare module BABYLON {
  97673. /** @hidden */
  97674. export var logDepthFragment: {
  97675. name: string;
  97676. shader: string;
  97677. };
  97678. }
  97679. declare module BABYLON {
  97680. /** @hidden */
  97681. export var defaultPixelShader: {
  97682. name: string;
  97683. shader: string;
  97684. };
  97685. }
  97686. declare module BABYLON {
  97687. /** @hidden */
  97688. export var defaultVertexDeclaration: {
  97689. name: string;
  97690. shader: string;
  97691. };
  97692. }
  97693. declare module BABYLON {
  97694. /** @hidden */
  97695. export var bumpVertexDeclaration: {
  97696. name: string;
  97697. shader: string;
  97698. };
  97699. }
  97700. declare module BABYLON {
  97701. /** @hidden */
  97702. export var bumpVertex: {
  97703. name: string;
  97704. shader: string;
  97705. };
  97706. }
  97707. declare module BABYLON {
  97708. /** @hidden */
  97709. export var fogVertex: {
  97710. name: string;
  97711. shader: string;
  97712. };
  97713. }
  97714. declare module BABYLON {
  97715. /** @hidden */
  97716. export var shadowsVertex: {
  97717. name: string;
  97718. shader: string;
  97719. };
  97720. }
  97721. declare module BABYLON {
  97722. /** @hidden */
  97723. export var pointCloudVertex: {
  97724. name: string;
  97725. shader: string;
  97726. };
  97727. }
  97728. declare module BABYLON {
  97729. /** @hidden */
  97730. export var logDepthVertex: {
  97731. name: string;
  97732. shader: string;
  97733. };
  97734. }
  97735. declare module BABYLON {
  97736. /** @hidden */
  97737. export var defaultVertexShader: {
  97738. name: string;
  97739. shader: string;
  97740. };
  97741. }
  97742. declare module BABYLON {
  97743. /** @hidden */
  97744. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  97745. MAINUV1: boolean;
  97746. MAINUV2: boolean;
  97747. DIFFUSE: boolean;
  97748. DIFFUSEDIRECTUV: number;
  97749. AMBIENT: boolean;
  97750. AMBIENTDIRECTUV: number;
  97751. OPACITY: boolean;
  97752. OPACITYDIRECTUV: number;
  97753. OPACITYRGB: boolean;
  97754. REFLECTION: boolean;
  97755. EMISSIVE: boolean;
  97756. EMISSIVEDIRECTUV: number;
  97757. SPECULAR: boolean;
  97758. SPECULARDIRECTUV: number;
  97759. BUMP: boolean;
  97760. BUMPDIRECTUV: number;
  97761. PARALLAX: boolean;
  97762. PARALLAXOCCLUSION: boolean;
  97763. SPECULAROVERALPHA: boolean;
  97764. CLIPPLANE: boolean;
  97765. CLIPPLANE2: boolean;
  97766. CLIPPLANE3: boolean;
  97767. CLIPPLANE4: boolean;
  97768. ALPHATEST: boolean;
  97769. DEPTHPREPASS: boolean;
  97770. ALPHAFROMDIFFUSE: boolean;
  97771. POINTSIZE: boolean;
  97772. FOG: boolean;
  97773. SPECULARTERM: boolean;
  97774. DIFFUSEFRESNEL: boolean;
  97775. OPACITYFRESNEL: boolean;
  97776. REFLECTIONFRESNEL: boolean;
  97777. REFRACTIONFRESNEL: boolean;
  97778. EMISSIVEFRESNEL: boolean;
  97779. FRESNEL: boolean;
  97780. NORMAL: boolean;
  97781. UV1: boolean;
  97782. UV2: boolean;
  97783. VERTEXCOLOR: boolean;
  97784. VERTEXALPHA: boolean;
  97785. NUM_BONE_INFLUENCERS: number;
  97786. BonesPerMesh: number;
  97787. BONETEXTURE: boolean;
  97788. INSTANCES: boolean;
  97789. GLOSSINESS: boolean;
  97790. ROUGHNESS: boolean;
  97791. EMISSIVEASILLUMINATION: boolean;
  97792. LINKEMISSIVEWITHDIFFUSE: boolean;
  97793. REFLECTIONFRESNELFROMSPECULAR: boolean;
  97794. LIGHTMAP: boolean;
  97795. LIGHTMAPDIRECTUV: number;
  97796. OBJECTSPACE_NORMALMAP: boolean;
  97797. USELIGHTMAPASSHADOWMAP: boolean;
  97798. REFLECTIONMAP_3D: boolean;
  97799. REFLECTIONMAP_SPHERICAL: boolean;
  97800. REFLECTIONMAP_PLANAR: boolean;
  97801. REFLECTIONMAP_CUBIC: boolean;
  97802. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  97803. REFLECTIONMAP_PROJECTION: boolean;
  97804. REFLECTIONMAP_SKYBOX: boolean;
  97805. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  97806. REFLECTIONMAP_EXPLICIT: boolean;
  97807. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  97808. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  97809. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  97810. INVERTCUBICMAP: boolean;
  97811. LOGARITHMICDEPTH: boolean;
  97812. REFRACTION: boolean;
  97813. REFRACTIONMAP_3D: boolean;
  97814. REFLECTIONOVERALPHA: boolean;
  97815. TWOSIDEDLIGHTING: boolean;
  97816. SHADOWFLOAT: boolean;
  97817. MORPHTARGETS: boolean;
  97818. MORPHTARGETS_NORMAL: boolean;
  97819. MORPHTARGETS_TANGENT: boolean;
  97820. NUM_MORPH_INFLUENCERS: number;
  97821. NONUNIFORMSCALING: boolean;
  97822. PREMULTIPLYALPHA: boolean;
  97823. IMAGEPROCESSING: boolean;
  97824. VIGNETTE: boolean;
  97825. VIGNETTEBLENDMODEMULTIPLY: boolean;
  97826. VIGNETTEBLENDMODEOPAQUE: boolean;
  97827. TONEMAPPING: boolean;
  97828. TONEMAPPING_ACES: boolean;
  97829. CONTRAST: boolean;
  97830. COLORCURVES: boolean;
  97831. COLORGRADING: boolean;
  97832. COLORGRADING3D: boolean;
  97833. SAMPLER3DGREENDEPTH: boolean;
  97834. SAMPLER3DBGRMAP: boolean;
  97835. IMAGEPROCESSINGPOSTPROCESS: boolean;
  97836. MULTIVIEW: boolean;
  97837. /**
  97838. * If the reflection texture on this material is in linear color space
  97839. * @hidden
  97840. */
  97841. IS_REFLECTION_LINEAR: boolean;
  97842. /**
  97843. * If the refraction texture on this material is in linear color space
  97844. * @hidden
  97845. */
  97846. IS_REFRACTION_LINEAR: boolean;
  97847. EXPOSURE: boolean;
  97848. constructor();
  97849. setReflectionMode(modeToEnable: string): void;
  97850. }
  97851. /**
  97852. * This is the default material used in Babylon. It is the best trade off between quality
  97853. * and performances.
  97854. * @see http://doc.babylonjs.com/babylon101/materials
  97855. */
  97856. export class StandardMaterial extends PushMaterial {
  97857. private _diffuseTexture;
  97858. /**
  97859. * The basic texture of the material as viewed under a light.
  97860. */
  97861. diffuseTexture: Nullable<BaseTexture>;
  97862. private _ambientTexture;
  97863. /**
  97864. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  97865. */
  97866. ambientTexture: Nullable<BaseTexture>;
  97867. private _opacityTexture;
  97868. /**
  97869. * Define the transparency of the material from a texture.
  97870. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  97871. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  97872. */
  97873. opacityTexture: Nullable<BaseTexture>;
  97874. private _reflectionTexture;
  97875. /**
  97876. * Define the texture used to display the reflection.
  97877. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97878. */
  97879. reflectionTexture: Nullable<BaseTexture>;
  97880. private _emissiveTexture;
  97881. /**
  97882. * Define texture of the material as if self lit.
  97883. * This will be mixed in the final result even in the absence of light.
  97884. */
  97885. emissiveTexture: Nullable<BaseTexture>;
  97886. private _specularTexture;
  97887. /**
  97888. * Define how the color and intensity of the highlight given by the light in the material.
  97889. */
  97890. specularTexture: Nullable<BaseTexture>;
  97891. private _bumpTexture;
  97892. /**
  97893. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  97894. * 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.
  97895. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  97896. */
  97897. bumpTexture: Nullable<BaseTexture>;
  97898. private _lightmapTexture;
  97899. /**
  97900. * Complex lighting can be computationally expensive to compute at runtime.
  97901. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  97902. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  97903. */
  97904. lightmapTexture: Nullable<BaseTexture>;
  97905. private _refractionTexture;
  97906. /**
  97907. * Define the texture used to display the refraction.
  97908. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97909. */
  97910. refractionTexture: Nullable<BaseTexture>;
  97911. /**
  97912. * The color of the material lit by the environmental background lighting.
  97913. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  97914. */
  97915. ambientColor: Color3;
  97916. /**
  97917. * The basic color of the material as viewed under a light.
  97918. */
  97919. diffuseColor: Color3;
  97920. /**
  97921. * Define how the color and intensity of the highlight given by the light in the material.
  97922. */
  97923. specularColor: Color3;
  97924. /**
  97925. * Define the color of the material as if self lit.
  97926. * This will be mixed in the final result even in the absence of light.
  97927. */
  97928. emissiveColor: Color3;
  97929. /**
  97930. * Defines how sharp are the highlights in the material.
  97931. * The bigger the value the sharper giving a more glossy feeling to the result.
  97932. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  97933. */
  97934. specularPower: number;
  97935. private _useAlphaFromDiffuseTexture;
  97936. /**
  97937. * Does the transparency come from the diffuse texture alpha channel.
  97938. */
  97939. useAlphaFromDiffuseTexture: boolean;
  97940. private _useEmissiveAsIllumination;
  97941. /**
  97942. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  97943. */
  97944. useEmissiveAsIllumination: boolean;
  97945. private _linkEmissiveWithDiffuse;
  97946. /**
  97947. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  97948. * the emissive level when the final color is close to one.
  97949. */
  97950. linkEmissiveWithDiffuse: boolean;
  97951. private _useSpecularOverAlpha;
  97952. /**
  97953. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  97954. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  97955. */
  97956. useSpecularOverAlpha: boolean;
  97957. private _useReflectionOverAlpha;
  97958. /**
  97959. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  97960. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  97961. */
  97962. useReflectionOverAlpha: boolean;
  97963. private _disableLighting;
  97964. /**
  97965. * Does lights from the scene impacts this material.
  97966. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  97967. */
  97968. disableLighting: boolean;
  97969. private _useObjectSpaceNormalMap;
  97970. /**
  97971. * Allows using an object space normal map (instead of tangent space).
  97972. */
  97973. useObjectSpaceNormalMap: boolean;
  97974. private _useParallax;
  97975. /**
  97976. * Is parallax enabled or not.
  97977. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  97978. */
  97979. useParallax: boolean;
  97980. private _useParallaxOcclusion;
  97981. /**
  97982. * Is parallax occlusion enabled or not.
  97983. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  97984. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  97985. */
  97986. useParallaxOcclusion: boolean;
  97987. /**
  97988. * 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.
  97989. */
  97990. parallaxScaleBias: number;
  97991. private _roughness;
  97992. /**
  97993. * Helps to define how blurry the reflections should appears in the material.
  97994. */
  97995. roughness: number;
  97996. /**
  97997. * In case of refraction, define the value of the indice of refraction.
  97998. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97999. */
  98000. indexOfRefraction: number;
  98001. /**
  98002. * Invert the refraction texture alongside the y axis.
  98003. * It can be useful with procedural textures or probe for instance.
  98004. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98005. */
  98006. invertRefractionY: boolean;
  98007. /**
  98008. * Defines the alpha limits in alpha test mode.
  98009. */
  98010. alphaCutOff: number;
  98011. private _useLightmapAsShadowmap;
  98012. /**
  98013. * In case of light mapping, define whether the map contains light or shadow informations.
  98014. */
  98015. useLightmapAsShadowmap: boolean;
  98016. private _diffuseFresnelParameters;
  98017. /**
  98018. * Define the diffuse fresnel parameters of the material.
  98019. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98020. */
  98021. diffuseFresnelParameters: FresnelParameters;
  98022. private _opacityFresnelParameters;
  98023. /**
  98024. * Define the opacity fresnel parameters of the material.
  98025. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98026. */
  98027. opacityFresnelParameters: FresnelParameters;
  98028. private _reflectionFresnelParameters;
  98029. /**
  98030. * Define the reflection fresnel parameters of the material.
  98031. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98032. */
  98033. reflectionFresnelParameters: FresnelParameters;
  98034. private _refractionFresnelParameters;
  98035. /**
  98036. * Define the refraction fresnel parameters of the material.
  98037. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98038. */
  98039. refractionFresnelParameters: FresnelParameters;
  98040. private _emissiveFresnelParameters;
  98041. /**
  98042. * Define the emissive fresnel parameters of the material.
  98043. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98044. */
  98045. emissiveFresnelParameters: FresnelParameters;
  98046. private _useReflectionFresnelFromSpecular;
  98047. /**
  98048. * If true automatically deducts the fresnels values from the material specularity.
  98049. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98050. */
  98051. useReflectionFresnelFromSpecular: boolean;
  98052. private _useGlossinessFromSpecularMapAlpha;
  98053. /**
  98054. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  98055. */
  98056. useGlossinessFromSpecularMapAlpha: boolean;
  98057. private _maxSimultaneousLights;
  98058. /**
  98059. * Defines the maximum number of lights that can be used in the material
  98060. */
  98061. maxSimultaneousLights: number;
  98062. private _invertNormalMapX;
  98063. /**
  98064. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  98065. */
  98066. invertNormalMapX: boolean;
  98067. private _invertNormalMapY;
  98068. /**
  98069. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  98070. */
  98071. invertNormalMapY: boolean;
  98072. private _twoSidedLighting;
  98073. /**
  98074. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  98075. */
  98076. twoSidedLighting: boolean;
  98077. /**
  98078. * Default configuration related to image processing available in the standard Material.
  98079. */
  98080. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98081. /**
  98082. * Gets the image processing configuration used either in this material.
  98083. */
  98084. /**
  98085. * Sets the Default image processing configuration used either in the this material.
  98086. *
  98087. * If sets to null, the scene one is in use.
  98088. */
  98089. imageProcessingConfiguration: ImageProcessingConfiguration;
  98090. /**
  98091. * Keep track of the image processing observer to allow dispose and replace.
  98092. */
  98093. private _imageProcessingObserver;
  98094. /**
  98095. * Attaches a new image processing configuration to the Standard Material.
  98096. * @param configuration
  98097. */
  98098. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  98099. /**
  98100. * Gets wether the color curves effect is enabled.
  98101. */
  98102. /**
  98103. * Sets wether the color curves effect is enabled.
  98104. */
  98105. cameraColorCurvesEnabled: boolean;
  98106. /**
  98107. * Gets wether the color grading effect is enabled.
  98108. */
  98109. /**
  98110. * Gets wether the color grading effect is enabled.
  98111. */
  98112. cameraColorGradingEnabled: boolean;
  98113. /**
  98114. * Gets wether tonemapping is enabled or not.
  98115. */
  98116. /**
  98117. * Sets wether tonemapping is enabled or not
  98118. */
  98119. cameraToneMappingEnabled: boolean;
  98120. /**
  98121. * The camera exposure used on this material.
  98122. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98123. * This corresponds to a photographic exposure.
  98124. */
  98125. /**
  98126. * The camera exposure used on this material.
  98127. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98128. * This corresponds to a photographic exposure.
  98129. */
  98130. cameraExposure: number;
  98131. /**
  98132. * Gets The camera contrast used on this material.
  98133. */
  98134. /**
  98135. * Sets The camera contrast used on this material.
  98136. */
  98137. cameraContrast: number;
  98138. /**
  98139. * Gets the Color Grading 2D Lookup Texture.
  98140. */
  98141. /**
  98142. * Sets the Color Grading 2D Lookup Texture.
  98143. */
  98144. cameraColorGradingTexture: Nullable<BaseTexture>;
  98145. /**
  98146. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98147. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98148. * 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;
  98149. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98150. */
  98151. /**
  98152. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98153. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98154. * 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;
  98155. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98156. */
  98157. cameraColorCurves: Nullable<ColorCurves>;
  98158. /**
  98159. * Custom callback helping to override the default shader used in the material.
  98160. */
  98161. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  98162. protected _renderTargets: SmartArray<RenderTargetTexture>;
  98163. protected _worldViewProjectionMatrix: Matrix;
  98164. protected _globalAmbientColor: Color3;
  98165. protected _useLogarithmicDepth: boolean;
  98166. /**
  98167. * Instantiates a new standard material.
  98168. * This is the default material used in Babylon. It is the best trade off between quality
  98169. * and performances.
  98170. * @see http://doc.babylonjs.com/babylon101/materials
  98171. * @param name Define the name of the material in the scene
  98172. * @param scene Define the scene the material belong to
  98173. */
  98174. constructor(name: string, scene: Scene);
  98175. /**
  98176. * Gets a boolean indicating that current material needs to register RTT
  98177. */
  98178. readonly hasRenderTargetTextures: boolean;
  98179. /**
  98180. * Gets the current class name of the material e.g. "StandardMaterial"
  98181. * Mainly use in serialization.
  98182. * @returns the class name
  98183. */
  98184. getClassName(): string;
  98185. /**
  98186. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  98187. * You can try switching to logarithmic depth.
  98188. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  98189. */
  98190. useLogarithmicDepth: boolean;
  98191. /**
  98192. * Specifies if the material will require alpha blending
  98193. * @returns a boolean specifying if alpha blending is needed
  98194. */
  98195. needAlphaBlending(): boolean;
  98196. /**
  98197. * Specifies if this material should be rendered in alpha test mode
  98198. * @returns a boolean specifying if an alpha test is needed.
  98199. */
  98200. needAlphaTesting(): boolean;
  98201. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  98202. /**
  98203. * Get the texture used for alpha test purpose.
  98204. * @returns the diffuse texture in case of the standard material.
  98205. */
  98206. getAlphaTestTexture(): Nullable<BaseTexture>;
  98207. /**
  98208. * Get if the submesh is ready to be used and all its information available.
  98209. * Child classes can use it to update shaders
  98210. * @param mesh defines the mesh to check
  98211. * @param subMesh defines which submesh to check
  98212. * @param useInstances specifies that instances should be used
  98213. * @returns a boolean indicating that the submesh is ready or not
  98214. */
  98215. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  98216. /**
  98217. * Builds the material UBO layouts.
  98218. * Used internally during the effect preparation.
  98219. */
  98220. buildUniformLayout(): void;
  98221. /**
  98222. * Unbinds the material from the mesh
  98223. */
  98224. unbind(): void;
  98225. /**
  98226. * Binds the submesh to this material by preparing the effect and shader to draw
  98227. * @param world defines the world transformation matrix
  98228. * @param mesh defines the mesh containing the submesh
  98229. * @param subMesh defines the submesh to bind the material to
  98230. */
  98231. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  98232. /**
  98233. * Get the list of animatables in the material.
  98234. * @returns the list of animatables object used in the material
  98235. */
  98236. getAnimatables(): IAnimatable[];
  98237. /**
  98238. * Gets the active textures from the material
  98239. * @returns an array of textures
  98240. */
  98241. getActiveTextures(): BaseTexture[];
  98242. /**
  98243. * Specifies if the material uses a texture
  98244. * @param texture defines the texture to check against the material
  98245. * @returns a boolean specifying if the material uses the texture
  98246. */
  98247. hasTexture(texture: BaseTexture): boolean;
  98248. /**
  98249. * Disposes the material
  98250. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  98251. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  98252. */
  98253. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  98254. /**
  98255. * Makes a duplicate of the material, and gives it a new name
  98256. * @param name defines the new name for the duplicated material
  98257. * @returns the cloned material
  98258. */
  98259. clone(name: string): StandardMaterial;
  98260. /**
  98261. * Serializes this material in a JSON representation
  98262. * @returns the serialized material object
  98263. */
  98264. serialize(): any;
  98265. /**
  98266. * Creates a standard material from parsed material data
  98267. * @param source defines the JSON representation of the material
  98268. * @param scene defines the hosting scene
  98269. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  98270. * @returns a new standard material
  98271. */
  98272. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  98273. /**
  98274. * Are diffuse textures enabled in the application.
  98275. */
  98276. static DiffuseTextureEnabled: boolean;
  98277. /**
  98278. * Are ambient textures enabled in the application.
  98279. */
  98280. static AmbientTextureEnabled: boolean;
  98281. /**
  98282. * Are opacity textures enabled in the application.
  98283. */
  98284. static OpacityTextureEnabled: boolean;
  98285. /**
  98286. * Are reflection textures enabled in the application.
  98287. */
  98288. static ReflectionTextureEnabled: boolean;
  98289. /**
  98290. * Are emissive textures enabled in the application.
  98291. */
  98292. static EmissiveTextureEnabled: boolean;
  98293. /**
  98294. * Are specular textures enabled in the application.
  98295. */
  98296. static SpecularTextureEnabled: boolean;
  98297. /**
  98298. * Are bump textures enabled in the application.
  98299. */
  98300. static BumpTextureEnabled: boolean;
  98301. /**
  98302. * Are lightmap textures enabled in the application.
  98303. */
  98304. static LightmapTextureEnabled: boolean;
  98305. /**
  98306. * Are refraction textures enabled in the application.
  98307. */
  98308. static RefractionTextureEnabled: boolean;
  98309. /**
  98310. * Are color grading textures enabled in the application.
  98311. */
  98312. static ColorGradingTextureEnabled: boolean;
  98313. /**
  98314. * Are fresnels enabled in the application.
  98315. */
  98316. static FresnelEnabled: boolean;
  98317. }
  98318. }
  98319. declare module BABYLON {
  98320. /**
  98321. * A class extending Texture allowing drawing on a texture
  98322. * @see http://doc.babylonjs.com/how_to/dynamictexture
  98323. */
  98324. export class DynamicTexture extends Texture {
  98325. private _generateMipMaps;
  98326. private _canvas;
  98327. private _context;
  98328. private _engine;
  98329. /**
  98330. * Creates a DynamicTexture
  98331. * @param name defines the name of the texture
  98332. * @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
  98333. * @param scene defines the scene where you want the texture
  98334. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  98335. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  98336. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  98337. */
  98338. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  98339. /**
  98340. * Get the current class name of the texture useful for serialization or dynamic coding.
  98341. * @returns "DynamicTexture"
  98342. */
  98343. getClassName(): string;
  98344. /**
  98345. * Gets the current state of canRescale
  98346. */
  98347. readonly canRescale: boolean;
  98348. private _recreate;
  98349. /**
  98350. * Scales the texture
  98351. * @param ratio the scale factor to apply to both width and height
  98352. */
  98353. scale(ratio: number): void;
  98354. /**
  98355. * Resizes the texture
  98356. * @param width the new width
  98357. * @param height the new height
  98358. */
  98359. scaleTo(width: number, height: number): void;
  98360. /**
  98361. * Gets the context of the canvas used by the texture
  98362. * @returns the canvas context of the dynamic texture
  98363. */
  98364. getContext(): CanvasRenderingContext2D;
  98365. /**
  98366. * Clears the texture
  98367. */
  98368. clear(): void;
  98369. /**
  98370. * Updates the texture
  98371. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  98372. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  98373. */
  98374. update(invertY?: boolean, premulAlpha?: boolean): void;
  98375. /**
  98376. * Draws text onto the texture
  98377. * @param text defines the text to be drawn
  98378. * @param x defines the placement of the text from the left
  98379. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  98380. * @param font defines the font to be used with font-style, font-size, font-name
  98381. * @param color defines the color used for the text
  98382. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  98383. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  98384. * @param update defines whether texture is immediately update (default is true)
  98385. */
  98386. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  98387. /**
  98388. * Clones the texture
  98389. * @returns the clone of the texture.
  98390. */
  98391. clone(): DynamicTexture;
  98392. /**
  98393. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  98394. * @returns a serialized dynamic texture object
  98395. */
  98396. serialize(): any;
  98397. /** @hidden */
  98398. _rebuild(): void;
  98399. }
  98400. }
  98401. declare module BABYLON {
  98402. /** @hidden */
  98403. export var imageProcessingPixelShader: {
  98404. name: string;
  98405. shader: string;
  98406. };
  98407. }
  98408. declare module BABYLON {
  98409. /**
  98410. * ImageProcessingPostProcess
  98411. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  98412. */
  98413. export class ImageProcessingPostProcess extends PostProcess {
  98414. /**
  98415. * Default configuration related to image processing available in the PBR Material.
  98416. */
  98417. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98418. /**
  98419. * Gets the image processing configuration used either in this material.
  98420. */
  98421. /**
  98422. * Sets the Default image processing configuration used either in the this material.
  98423. *
  98424. * If sets to null, the scene one is in use.
  98425. */
  98426. imageProcessingConfiguration: ImageProcessingConfiguration;
  98427. /**
  98428. * Keep track of the image processing observer to allow dispose and replace.
  98429. */
  98430. private _imageProcessingObserver;
  98431. /**
  98432. * Attaches a new image processing configuration to the PBR Material.
  98433. * @param configuration
  98434. */
  98435. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  98436. /**
  98437. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  98438. */
  98439. /**
  98440. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  98441. */
  98442. colorCurves: Nullable<ColorCurves>;
  98443. /**
  98444. * Gets wether the color curves effect is enabled.
  98445. */
  98446. /**
  98447. * Sets wether the color curves effect is enabled.
  98448. */
  98449. colorCurvesEnabled: boolean;
  98450. /**
  98451. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  98452. */
  98453. /**
  98454. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  98455. */
  98456. colorGradingTexture: Nullable<BaseTexture>;
  98457. /**
  98458. * Gets wether the color grading effect is enabled.
  98459. */
  98460. /**
  98461. * Gets wether the color grading effect is enabled.
  98462. */
  98463. colorGradingEnabled: boolean;
  98464. /**
  98465. * Gets exposure used in the effect.
  98466. */
  98467. /**
  98468. * Sets exposure used in the effect.
  98469. */
  98470. exposure: number;
  98471. /**
  98472. * Gets wether tonemapping is enabled or not.
  98473. */
  98474. /**
  98475. * Sets wether tonemapping is enabled or not
  98476. */
  98477. toneMappingEnabled: boolean;
  98478. /**
  98479. * Gets the type of tone mapping effect.
  98480. */
  98481. /**
  98482. * Sets the type of tone mapping effect.
  98483. */
  98484. toneMappingType: number;
  98485. /**
  98486. * Gets contrast used in the effect.
  98487. */
  98488. /**
  98489. * Sets contrast used in the effect.
  98490. */
  98491. contrast: number;
  98492. /**
  98493. * Gets Vignette stretch size.
  98494. */
  98495. /**
  98496. * Sets Vignette stretch size.
  98497. */
  98498. vignetteStretch: number;
  98499. /**
  98500. * Gets Vignette centre X Offset.
  98501. */
  98502. /**
  98503. * Sets Vignette centre X Offset.
  98504. */
  98505. vignetteCentreX: number;
  98506. /**
  98507. * Gets Vignette centre Y Offset.
  98508. */
  98509. /**
  98510. * Sets Vignette centre Y Offset.
  98511. */
  98512. vignetteCentreY: number;
  98513. /**
  98514. * Gets Vignette weight or intensity of the vignette effect.
  98515. */
  98516. /**
  98517. * Sets Vignette weight or intensity of the vignette effect.
  98518. */
  98519. vignetteWeight: number;
  98520. /**
  98521. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  98522. * if vignetteEnabled is set to true.
  98523. */
  98524. /**
  98525. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  98526. * if vignetteEnabled is set to true.
  98527. */
  98528. vignetteColor: Color4;
  98529. /**
  98530. * Gets Camera field of view used by the Vignette effect.
  98531. */
  98532. /**
  98533. * Sets Camera field of view used by the Vignette effect.
  98534. */
  98535. vignetteCameraFov: number;
  98536. /**
  98537. * Gets the vignette blend mode allowing different kind of effect.
  98538. */
  98539. /**
  98540. * Sets the vignette blend mode allowing different kind of effect.
  98541. */
  98542. vignetteBlendMode: number;
  98543. /**
  98544. * Gets wether the vignette effect is enabled.
  98545. */
  98546. /**
  98547. * Sets wether the vignette effect is enabled.
  98548. */
  98549. vignetteEnabled: boolean;
  98550. private _fromLinearSpace;
  98551. /**
  98552. * Gets wether the input of the processing is in Gamma or Linear Space.
  98553. */
  98554. /**
  98555. * Sets wether the input of the processing is in Gamma or Linear Space.
  98556. */
  98557. fromLinearSpace: boolean;
  98558. /**
  98559. * Defines cache preventing GC.
  98560. */
  98561. private _defines;
  98562. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  98563. /**
  98564. * "ImageProcessingPostProcess"
  98565. * @returns "ImageProcessingPostProcess"
  98566. */
  98567. getClassName(): string;
  98568. protected _updateParameters(): void;
  98569. dispose(camera?: Camera): void;
  98570. }
  98571. }
  98572. declare module BABYLON {
  98573. /**
  98574. * Class containing static functions to help procedurally build meshes
  98575. */
  98576. export class GroundBuilder {
  98577. /**
  98578. * Creates a ground mesh
  98579. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  98580. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  98581. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98582. * @param name defines the name of the mesh
  98583. * @param options defines the options used to create the mesh
  98584. * @param scene defines the hosting scene
  98585. * @returns the ground mesh
  98586. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  98587. */
  98588. static CreateGround(name: string, options: {
  98589. width?: number;
  98590. height?: number;
  98591. subdivisions?: number;
  98592. subdivisionsX?: number;
  98593. subdivisionsY?: number;
  98594. updatable?: boolean;
  98595. }, scene: any): Mesh;
  98596. /**
  98597. * Creates a tiled ground mesh
  98598. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  98599. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  98600. * * 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
  98601. * * 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
  98602. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98603. * @param name defines the name of the mesh
  98604. * @param options defines the options used to create the mesh
  98605. * @param scene defines the hosting scene
  98606. * @returns the tiled ground mesh
  98607. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  98608. */
  98609. static CreateTiledGround(name: string, options: {
  98610. xmin: number;
  98611. zmin: number;
  98612. xmax: number;
  98613. zmax: number;
  98614. subdivisions?: {
  98615. w: number;
  98616. h: number;
  98617. };
  98618. precision?: {
  98619. w: number;
  98620. h: number;
  98621. };
  98622. updatable?: boolean;
  98623. }, scene?: Nullable<Scene>): Mesh;
  98624. /**
  98625. * Creates a ground mesh from a height map
  98626. * * The parameter `url` sets the URL of the height map image resource.
  98627. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  98628. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  98629. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  98630. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  98631. * * 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.
  98632. * * 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).
  98633. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  98634. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98635. * @param name defines the name of the mesh
  98636. * @param url defines the url to the height map
  98637. * @param options defines the options used to create the mesh
  98638. * @param scene defines the hosting scene
  98639. * @returns the ground mesh
  98640. * @see https://doc.babylonjs.com/babylon101/height_map
  98641. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  98642. */
  98643. static CreateGroundFromHeightMap(name: string, url: string, options: {
  98644. width?: number;
  98645. height?: number;
  98646. subdivisions?: number;
  98647. minHeight?: number;
  98648. maxHeight?: number;
  98649. colorFilter?: Color3;
  98650. alphaFilter?: number;
  98651. updatable?: boolean;
  98652. onReady?: (mesh: GroundMesh) => void;
  98653. }, scene?: Nullable<Scene>): GroundMesh;
  98654. }
  98655. }
  98656. declare module BABYLON {
  98657. /**
  98658. * Class containing static functions to help procedurally build meshes
  98659. */
  98660. export class TorusBuilder {
  98661. /**
  98662. * Creates a torus mesh
  98663. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  98664. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  98665. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  98666. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98667. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98668. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98669. * @param name defines the name of the mesh
  98670. * @param options defines the options used to create the mesh
  98671. * @param scene defines the hosting scene
  98672. * @returns the torus mesh
  98673. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  98674. */
  98675. static CreateTorus(name: string, options: {
  98676. diameter?: number;
  98677. thickness?: number;
  98678. tessellation?: number;
  98679. updatable?: boolean;
  98680. sideOrientation?: number;
  98681. frontUVs?: Vector4;
  98682. backUVs?: Vector4;
  98683. }, scene: any): Mesh;
  98684. }
  98685. }
  98686. declare module BABYLON {
  98687. /**
  98688. * Class containing static functions to help procedurally build meshes
  98689. */
  98690. export class CylinderBuilder {
  98691. /**
  98692. * Creates a cylinder or a cone mesh
  98693. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  98694. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  98695. * * 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.
  98696. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  98697. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  98698. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  98699. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  98700. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  98701. * * 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).
  98702. * * 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
  98703. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  98704. * * 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
  98705. * * 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.
  98706. * * If `enclose` is false, a ring surface is one element.
  98707. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  98708. * * 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
  98709. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98710. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98711. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98712. * @param name defines the name of the mesh
  98713. * @param options defines the options used to create the mesh
  98714. * @param scene defines the hosting scene
  98715. * @returns the cylinder mesh
  98716. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  98717. */
  98718. static CreateCylinder(name: string, options: {
  98719. height?: number;
  98720. diameterTop?: number;
  98721. diameterBottom?: number;
  98722. diameter?: number;
  98723. tessellation?: number;
  98724. subdivisions?: number;
  98725. arc?: number;
  98726. faceColors?: Color4[];
  98727. faceUV?: Vector4[];
  98728. updatable?: boolean;
  98729. hasRings?: boolean;
  98730. enclose?: boolean;
  98731. sideOrientation?: number;
  98732. frontUVs?: Vector4;
  98733. backUVs?: Vector4;
  98734. }, scene: any): Mesh;
  98735. }
  98736. }
  98737. declare module BABYLON {
  98738. /**
  98739. * Manager for handling gamepads
  98740. */
  98741. export class GamepadManager {
  98742. private _scene?;
  98743. private _babylonGamepads;
  98744. private _oneGamepadConnected;
  98745. /** @hidden */
  98746. _isMonitoring: boolean;
  98747. private _gamepadEventSupported;
  98748. private _gamepadSupport;
  98749. /**
  98750. * observable to be triggered when the gamepad controller has been connected
  98751. */
  98752. onGamepadConnectedObservable: Observable<Gamepad>;
  98753. /**
  98754. * observable to be triggered when the gamepad controller has been disconnected
  98755. */
  98756. onGamepadDisconnectedObservable: Observable<Gamepad>;
  98757. private _onGamepadConnectedEvent;
  98758. private _onGamepadDisconnectedEvent;
  98759. /**
  98760. * Initializes the gamepad manager
  98761. * @param _scene BabylonJS scene
  98762. */
  98763. constructor(_scene?: Scene | undefined);
  98764. /**
  98765. * The gamepads in the game pad manager
  98766. */
  98767. readonly gamepads: Gamepad[];
  98768. /**
  98769. * Get the gamepad controllers based on type
  98770. * @param type The type of gamepad controller
  98771. * @returns Nullable gamepad
  98772. */
  98773. getGamepadByType(type?: number): Nullable<Gamepad>;
  98774. /**
  98775. * Disposes the gamepad manager
  98776. */
  98777. dispose(): void;
  98778. private _addNewGamepad;
  98779. private _startMonitoringGamepads;
  98780. private _stopMonitoringGamepads;
  98781. /** @hidden */
  98782. _checkGamepadsStatus(): void;
  98783. private _updateGamepadObjects;
  98784. }
  98785. }
  98786. declare module BABYLON {
  98787. interface Scene {
  98788. /** @hidden */
  98789. _gamepadManager: Nullable<GamepadManager>;
  98790. /**
  98791. * Gets the gamepad manager associated with the scene
  98792. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  98793. */
  98794. gamepadManager: GamepadManager;
  98795. }
  98796. /**
  98797. * Interface representing a free camera inputs manager
  98798. */
  98799. interface FreeCameraInputsManager {
  98800. /**
  98801. * Adds gamepad input support to the FreeCameraInputsManager.
  98802. * @returns the FreeCameraInputsManager
  98803. */
  98804. addGamepad(): FreeCameraInputsManager;
  98805. }
  98806. /**
  98807. * Interface representing an arc rotate camera inputs manager
  98808. */
  98809. interface ArcRotateCameraInputsManager {
  98810. /**
  98811. * Adds gamepad input support to the ArcRotateCamera InputManager.
  98812. * @returns the camera inputs manager
  98813. */
  98814. addGamepad(): ArcRotateCameraInputsManager;
  98815. }
  98816. /**
  98817. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  98818. */
  98819. export class GamepadSystemSceneComponent implements ISceneComponent {
  98820. /**
  98821. * The component name helpfull to identify the component in the list of scene components.
  98822. */
  98823. readonly name: string;
  98824. /**
  98825. * The scene the component belongs to.
  98826. */
  98827. scene: Scene;
  98828. /**
  98829. * Creates a new instance of the component for the given scene
  98830. * @param scene Defines the scene to register the component in
  98831. */
  98832. constructor(scene: Scene);
  98833. /**
  98834. * Registers the component in a given scene
  98835. */
  98836. register(): void;
  98837. /**
  98838. * Rebuilds the elements related to this component in case of
  98839. * context lost for instance.
  98840. */
  98841. rebuild(): void;
  98842. /**
  98843. * Disposes the component and the associated ressources
  98844. */
  98845. dispose(): void;
  98846. private _beforeCameraUpdate;
  98847. }
  98848. }
  98849. declare module BABYLON {
  98850. /**
  98851. * Options to modify the vr teleportation behavior.
  98852. */
  98853. export interface VRTeleportationOptions {
  98854. /**
  98855. * The name of the mesh which should be used as the teleportation floor. (default: null)
  98856. */
  98857. floorMeshName?: string;
  98858. /**
  98859. * A list of meshes to be used as the teleportation floor. (default: empty)
  98860. */
  98861. floorMeshes?: Mesh[];
  98862. }
  98863. /**
  98864. * Options to modify the vr experience helper's behavior.
  98865. */
  98866. export interface VRExperienceHelperOptions extends WebVROptions {
  98867. /**
  98868. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  98869. */
  98870. createDeviceOrientationCamera?: boolean;
  98871. /**
  98872. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  98873. */
  98874. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  98875. /**
  98876. * Uses the main button on the controller to toggle the laser casted. (default: true)
  98877. */
  98878. laserToggle?: boolean;
  98879. /**
  98880. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  98881. */
  98882. floorMeshes?: Mesh[];
  98883. /**
  98884. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  98885. */
  98886. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  98887. }
  98888. /**
  98889. * Event containing information after VR has been entered
  98890. */
  98891. export class OnAfterEnteringVRObservableEvent {
  98892. /**
  98893. * If entering vr was successful
  98894. */
  98895. success: boolean;
  98896. }
  98897. /**
  98898. * Helps to quickly add VR support to an existing scene.
  98899. * See http://doc.babylonjs.com/how_to/webvr_helper
  98900. */
  98901. export class VRExperienceHelper {
  98902. /** Options to modify the vr experience helper's behavior. */
  98903. webVROptions: VRExperienceHelperOptions;
  98904. private _scene;
  98905. private _position;
  98906. private _btnVR;
  98907. private _btnVRDisplayed;
  98908. private _webVRsupported;
  98909. private _webVRready;
  98910. private _webVRrequesting;
  98911. private _webVRpresenting;
  98912. private _hasEnteredVR;
  98913. private _fullscreenVRpresenting;
  98914. private _canvas;
  98915. private _webVRCamera;
  98916. private _vrDeviceOrientationCamera;
  98917. private _deviceOrientationCamera;
  98918. private _existingCamera;
  98919. private _onKeyDown;
  98920. private _onVrDisplayPresentChange;
  98921. private _onVRDisplayChanged;
  98922. private _onVRRequestPresentStart;
  98923. private _onVRRequestPresentComplete;
  98924. /**
  98925. * Observable raised right before entering VR.
  98926. */
  98927. onEnteringVRObservable: Observable<VRExperienceHelper>;
  98928. /**
  98929. * Observable raised when entering VR has completed.
  98930. */
  98931. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  98932. /**
  98933. * Observable raised when exiting VR.
  98934. */
  98935. onExitingVRObservable: Observable<VRExperienceHelper>;
  98936. /**
  98937. * Observable raised when controller mesh is loaded.
  98938. */
  98939. onControllerMeshLoadedObservable: Observable<WebVRController>;
  98940. /** Return this.onEnteringVRObservable
  98941. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  98942. */
  98943. readonly onEnteringVR: Observable<VRExperienceHelper>;
  98944. /** Return this.onExitingVRObservable
  98945. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  98946. */
  98947. readonly onExitingVR: Observable<VRExperienceHelper>;
  98948. /** Return this.onControllerMeshLoadedObservable
  98949. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  98950. */
  98951. readonly onControllerMeshLoaded: Observable<WebVRController>;
  98952. private _rayLength;
  98953. private _useCustomVRButton;
  98954. private _teleportationRequested;
  98955. private _teleportActive;
  98956. private _floorMeshName;
  98957. private _floorMeshesCollection;
  98958. private _rotationAllowed;
  98959. private _teleportBackwardsVector;
  98960. private _teleportationTarget;
  98961. private _isDefaultTeleportationTarget;
  98962. private _postProcessMove;
  98963. private _teleportationFillColor;
  98964. private _teleportationBorderColor;
  98965. private _rotationAngle;
  98966. private _haloCenter;
  98967. private _cameraGazer;
  98968. private _padSensibilityUp;
  98969. private _padSensibilityDown;
  98970. private _leftController;
  98971. private _rightController;
  98972. /**
  98973. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  98974. */
  98975. onNewMeshSelected: Observable<AbstractMesh>;
  98976. /**
  98977. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  98978. */
  98979. onNewMeshPicked: Observable<PickingInfo>;
  98980. private _circleEase;
  98981. /**
  98982. * Observable raised before camera teleportation
  98983. */
  98984. onBeforeCameraTeleport: Observable<Vector3>;
  98985. /**
  98986. * Observable raised after camera teleportation
  98987. */
  98988. onAfterCameraTeleport: Observable<Vector3>;
  98989. /**
  98990. * Observable raised when current selected mesh gets unselected
  98991. */
  98992. onSelectedMeshUnselected: Observable<AbstractMesh>;
  98993. private _raySelectionPredicate;
  98994. /**
  98995. * To be optionaly changed by user to define custom ray selection
  98996. */
  98997. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  98998. /**
  98999. * To be optionaly changed by user to define custom selection logic (after ray selection)
  99000. */
  99001. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  99002. /**
  99003. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  99004. */
  99005. teleportationEnabled: boolean;
  99006. private _defaultHeight;
  99007. private _teleportationInitialized;
  99008. private _interactionsEnabled;
  99009. private _interactionsRequested;
  99010. private _displayGaze;
  99011. private _displayLaserPointer;
  99012. /**
  99013. * The mesh used to display where the user is going to teleport.
  99014. */
  99015. /**
  99016. * Sets the mesh to be used to display where the user is going to teleport.
  99017. */
  99018. teleportationTarget: Mesh;
  99019. /**
  99020. * 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
  99021. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  99022. * See http://doc.babylonjs.com/resources/baking_transformations
  99023. */
  99024. gazeTrackerMesh: Mesh;
  99025. /**
  99026. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  99027. */
  99028. updateGazeTrackerScale: boolean;
  99029. /**
  99030. * If the gaze trackers color should be updated when selecting meshes
  99031. */
  99032. updateGazeTrackerColor: boolean;
  99033. /**
  99034. * The gaze tracking mesh corresponding to the left controller
  99035. */
  99036. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  99037. /**
  99038. * The gaze tracking mesh corresponding to the right controller
  99039. */
  99040. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  99041. /**
  99042. * If the ray of the gaze should be displayed.
  99043. */
  99044. /**
  99045. * Sets if the ray of the gaze should be displayed.
  99046. */
  99047. displayGaze: boolean;
  99048. /**
  99049. * If the ray of the LaserPointer should be displayed.
  99050. */
  99051. /**
  99052. * Sets if the ray of the LaserPointer should be displayed.
  99053. */
  99054. displayLaserPointer: boolean;
  99055. /**
  99056. * The deviceOrientationCamera used as the camera when not in VR.
  99057. */
  99058. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  99059. /**
  99060. * Based on the current WebVR support, returns the current VR camera used.
  99061. */
  99062. readonly currentVRCamera: Nullable<Camera>;
  99063. /**
  99064. * The webVRCamera which is used when in VR.
  99065. */
  99066. readonly webVRCamera: WebVRFreeCamera;
  99067. /**
  99068. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  99069. */
  99070. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  99071. private readonly _teleportationRequestInitiated;
  99072. /**
  99073. * Defines wether or not Pointer lock should be requested when switching to
  99074. * full screen.
  99075. */
  99076. requestPointerLockOnFullScreen: boolean;
  99077. /**
  99078. * Instantiates a VRExperienceHelper.
  99079. * Helps to quickly add VR support to an existing scene.
  99080. * @param scene The scene the VRExperienceHelper belongs to.
  99081. * @param webVROptions Options to modify the vr experience helper's behavior.
  99082. */
  99083. constructor(scene: Scene,
  99084. /** Options to modify the vr experience helper's behavior. */
  99085. webVROptions?: VRExperienceHelperOptions);
  99086. private _onDefaultMeshLoaded;
  99087. private _onResize;
  99088. private _onFullscreenChange;
  99089. /**
  99090. * Gets a value indicating if we are currently in VR mode.
  99091. */
  99092. readonly isInVRMode: boolean;
  99093. private onVrDisplayPresentChange;
  99094. private onVRDisplayChanged;
  99095. private moveButtonToBottomRight;
  99096. private displayVRButton;
  99097. private updateButtonVisibility;
  99098. private _cachedAngularSensibility;
  99099. /**
  99100. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  99101. * Otherwise, will use the fullscreen API.
  99102. */
  99103. enterVR(): void;
  99104. /**
  99105. * Attempt to exit VR, or fullscreen.
  99106. */
  99107. exitVR(): void;
  99108. /**
  99109. * The position of the vr experience helper.
  99110. */
  99111. /**
  99112. * Sets the position of the vr experience helper.
  99113. */
  99114. position: Vector3;
  99115. /**
  99116. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  99117. */
  99118. enableInteractions(): void;
  99119. private readonly _noControllerIsActive;
  99120. private beforeRender;
  99121. private _isTeleportationFloor;
  99122. /**
  99123. * Adds a floor mesh to be used for teleportation.
  99124. * @param floorMesh the mesh to be used for teleportation.
  99125. */
  99126. addFloorMesh(floorMesh: Mesh): void;
  99127. /**
  99128. * Removes a floor mesh from being used for teleportation.
  99129. * @param floorMesh the mesh to be removed.
  99130. */
  99131. removeFloorMesh(floorMesh: Mesh): void;
  99132. /**
  99133. * Enables interactions and teleportation using the VR controllers and gaze.
  99134. * @param vrTeleportationOptions options to modify teleportation behavior.
  99135. */
  99136. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  99137. private _onNewGamepadConnected;
  99138. private _tryEnableInteractionOnController;
  99139. private _onNewGamepadDisconnected;
  99140. private _enableInteractionOnController;
  99141. private _checkTeleportWithRay;
  99142. private _checkRotate;
  99143. private _checkTeleportBackwards;
  99144. private _enableTeleportationOnController;
  99145. private _createTeleportationCircles;
  99146. private _displayTeleportationTarget;
  99147. private _hideTeleportationTarget;
  99148. private _rotateCamera;
  99149. private _moveTeleportationSelectorTo;
  99150. private _workingVector;
  99151. private _workingQuaternion;
  99152. private _workingMatrix;
  99153. /**
  99154. * Teleports the users feet to the desired location
  99155. * @param location The location where the user's feet should be placed
  99156. */
  99157. teleportCamera(location: Vector3): void;
  99158. private _convertNormalToDirectionOfRay;
  99159. private _castRayAndSelectObject;
  99160. private _notifySelectedMeshUnselected;
  99161. /**
  99162. * Sets the color of the laser ray from the vr controllers.
  99163. * @param color new color for the ray.
  99164. */
  99165. changeLaserColor(color: Color3): void;
  99166. /**
  99167. * Sets the color of the ray from the vr headsets gaze.
  99168. * @param color new color for the ray.
  99169. */
  99170. changeGazeColor(color: Color3): void;
  99171. /**
  99172. * Exits VR and disposes of the vr experience helper
  99173. */
  99174. dispose(): void;
  99175. /**
  99176. * Gets the name of the VRExperienceHelper class
  99177. * @returns "VRExperienceHelper"
  99178. */
  99179. getClassName(): string;
  99180. }
  99181. }
  99182. declare module BABYLON {
  99183. /**
  99184. * Manages an XRSession
  99185. * @see https://doc.babylonjs.com/how_to/webxr
  99186. */
  99187. export class WebXRSessionManager implements IDisposable {
  99188. private scene;
  99189. /**
  99190. * Fires every time a new xrFrame arrives which can be used to update the camera
  99191. */
  99192. onXRFrameObservable: Observable<any>;
  99193. /**
  99194. * Fires when the xr session is ended either by the device or manually done
  99195. */
  99196. onXRSessionEnded: Observable<any>;
  99197. /** @hidden */
  99198. _xrSession: XRSession;
  99199. /** @hidden */
  99200. _frameOfReference: XRFrameOfReference;
  99201. /** @hidden */
  99202. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  99203. /** @hidden */
  99204. _currentXRFrame: Nullable<XRFrame>;
  99205. private _xrNavigator;
  99206. private _xrDevice;
  99207. private _tmpMatrix;
  99208. /**
  99209. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  99210. * @param scene The scene which the session should be created for
  99211. */
  99212. constructor(scene: Scene);
  99213. /**
  99214. * Initializes the manager
  99215. * After initialization enterXR can be called to start an XR session
  99216. * @returns Promise which resolves after it is initialized
  99217. */
  99218. initializeAsync(): Promise<void>;
  99219. /**
  99220. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  99221. * @param sessionCreationOptions xr options to create the session with
  99222. * @param frameOfReferenceType option to configure how the xr pose is expressed
  99223. * @returns Promise which resolves after it enters XR
  99224. */
  99225. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  99226. /**
  99227. * Stops the xrSession and restores the renderloop
  99228. * @returns Promise which resolves after it exits XR
  99229. */
  99230. exitXRAsync(): Promise<void>;
  99231. /**
  99232. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  99233. * @param ray ray to cast into the environment
  99234. * @returns Promise which resolves with a collision point in the environment if it exists
  99235. */
  99236. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  99237. /**
  99238. * Checks if a session would be supported for the creation options specified
  99239. * @param options creation options to check if they are supported
  99240. * @returns true if supported
  99241. */
  99242. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  99243. /**
  99244. * @hidden
  99245. * Converts the render layer of xrSession to a render target
  99246. * @param session session to create render target for
  99247. * @param scene scene the new render target should be created for
  99248. */
  99249. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  99250. /**
  99251. * Disposes of the session manager
  99252. */
  99253. dispose(): void;
  99254. }
  99255. }
  99256. declare module BABYLON {
  99257. /**
  99258. * WebXR Camera which holds the views for the xrSession
  99259. * @see https://doc.babylonjs.com/how_to/webxr
  99260. */
  99261. export class WebXRCamera extends FreeCamera {
  99262. private static _TmpMatrix;
  99263. /**
  99264. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  99265. * @param name the name of the camera
  99266. * @param scene the scene to add the camera to
  99267. */
  99268. constructor(name: string, scene: Scene);
  99269. private _updateNumberOfRigCameras;
  99270. /** @hidden */
  99271. _updateForDualEyeDebugging(pupilDistance?: number): void;
  99272. /**
  99273. * Updates the cameras position from the current pose information of the XR session
  99274. * @param xrSessionManager the session containing pose information
  99275. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  99276. */
  99277. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  99278. }
  99279. }
  99280. declare module BABYLON {
  99281. /**
  99282. * States of the webXR experience
  99283. */
  99284. export enum WebXRState {
  99285. /**
  99286. * Transitioning to being in XR mode
  99287. */
  99288. ENTERING_XR = 0,
  99289. /**
  99290. * Transitioning to non XR mode
  99291. */
  99292. EXITING_XR = 1,
  99293. /**
  99294. * In XR mode and presenting
  99295. */
  99296. IN_XR = 2,
  99297. /**
  99298. * Not entered XR mode
  99299. */
  99300. NOT_IN_XR = 3
  99301. }
  99302. /**
  99303. * Helper class used to enable XR
  99304. * @see https://doc.babylonjs.com/how_to/webxr
  99305. */
  99306. export class WebXRExperienceHelper implements IDisposable {
  99307. private scene;
  99308. /**
  99309. * 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
  99310. */
  99311. container: AbstractMesh;
  99312. /**
  99313. * Camera used to render xr content
  99314. */
  99315. camera: WebXRCamera;
  99316. /**
  99317. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  99318. */
  99319. state: WebXRState;
  99320. private _setState;
  99321. private static _TmpVector;
  99322. /**
  99323. * Fires when the state of the experience helper has changed
  99324. */
  99325. onStateChangedObservable: Observable<WebXRState>;
  99326. /** @hidden */
  99327. _sessionManager: WebXRSessionManager;
  99328. private _nonVRCamera;
  99329. private _originalSceneAutoClear;
  99330. private _supported;
  99331. /**
  99332. * Creates the experience helper
  99333. * @param scene the scene to attach the experience helper to
  99334. * @returns a promise for the experience helper
  99335. */
  99336. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  99337. /**
  99338. * Creates a WebXRExperienceHelper
  99339. * @param scene The scene the helper should be created in
  99340. */
  99341. private constructor();
  99342. /**
  99343. * Exits XR mode and returns the scene to its original state
  99344. * @returns promise that resolves after xr mode has exited
  99345. */
  99346. exitXRAsync(): Promise<void>;
  99347. /**
  99348. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  99349. * @param sessionCreationOptions options for the XR session
  99350. * @param frameOfReference frame of reference of the XR session
  99351. * @returns promise that resolves after xr mode has entered
  99352. */
  99353. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  99354. /**
  99355. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  99356. * @param ray ray to cast into the environment
  99357. * @returns Promise which resolves with a collision point in the environment if it exists
  99358. */
  99359. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  99360. /**
  99361. * Updates the global position of the camera by moving the camera's container
  99362. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  99363. * @param position The desired global position of the camera
  99364. */
  99365. setPositionOfCameraUsingContainer(position: Vector3): void;
  99366. /**
  99367. * Rotates the xr camera by rotating the camera's container around the camera's position
  99368. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  99369. * @param rotation the desired quaternion rotation to apply to the camera
  99370. */
  99371. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  99372. /**
  99373. * Checks if the creation options are supported by the xr session
  99374. * @param options creation options
  99375. * @returns true if supported
  99376. */
  99377. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  99378. /**
  99379. * Disposes of the experience helper
  99380. */
  99381. dispose(): void;
  99382. }
  99383. }
  99384. declare module BABYLON {
  99385. /**
  99386. * Button which can be used to enter a different mode of XR
  99387. */
  99388. export class WebXREnterExitUIButton {
  99389. /** button element */
  99390. element: HTMLElement;
  99391. /** XR initialization options for the button */
  99392. initializationOptions: XRSessionCreationOptions;
  99393. /**
  99394. * Creates a WebXREnterExitUIButton
  99395. * @param element button element
  99396. * @param initializationOptions XR initialization options for the button
  99397. */
  99398. constructor(
  99399. /** button element */
  99400. element: HTMLElement,
  99401. /** XR initialization options for the button */
  99402. initializationOptions: XRSessionCreationOptions);
  99403. /**
  99404. * Overwritable function which can be used to update the button's visuals when the state changes
  99405. * @param activeButton the current active button in the UI
  99406. */
  99407. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  99408. }
  99409. /**
  99410. * Options to create the webXR UI
  99411. */
  99412. export class WebXREnterExitUIOptions {
  99413. /**
  99414. * Context to enter xr with
  99415. */
  99416. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  99417. /**
  99418. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  99419. */
  99420. customButtons?: Array<WebXREnterExitUIButton>;
  99421. }
  99422. /**
  99423. * UI to allow the user to enter/exit XR mode
  99424. */
  99425. export class WebXREnterExitUI implements IDisposable {
  99426. private scene;
  99427. private _overlay;
  99428. private _buttons;
  99429. private _activeButton;
  99430. /**
  99431. * Fired every time the active button is changed.
  99432. *
  99433. * When xr is entered via a button that launches xr that button will be the callback parameter
  99434. *
  99435. * When exiting xr the callback parameter will be null)
  99436. */
  99437. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  99438. /**
  99439. * Creates UI to allow the user to enter/exit XR mode
  99440. * @param scene the scene to add the ui to
  99441. * @param helper the xr experience helper to enter/exit xr with
  99442. * @param options options to configure the UI
  99443. * @returns the created ui
  99444. */
  99445. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  99446. private constructor();
  99447. private _updateButtons;
  99448. /**
  99449. * Disposes of the object
  99450. */
  99451. dispose(): void;
  99452. }
  99453. }
  99454. declare module BABYLON {
  99455. /**
  99456. * Represents an XR input
  99457. */
  99458. export class WebXRController {
  99459. /**
  99460. * 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
  99461. */
  99462. grip?: AbstractMesh;
  99463. /**
  99464. * Pointer which can be used to select objects or attach a visible laser to
  99465. */
  99466. pointer: AbstractMesh;
  99467. /**
  99468. * Creates the controller
  99469. * @see https://doc.babylonjs.com/how_to/webxr
  99470. * @param scene the scene which the controller should be associated to
  99471. */
  99472. constructor(scene: Scene);
  99473. /**
  99474. * Disposes of the object
  99475. */
  99476. dispose(): void;
  99477. }
  99478. /**
  99479. * XR input used to track XR inputs such as controllers/rays
  99480. */
  99481. export class WebXRInput implements IDisposable {
  99482. private helper;
  99483. /**
  99484. * XR controllers being tracked
  99485. */
  99486. controllers: Array<WebXRController>;
  99487. private _tmpMatrix;
  99488. private _frameObserver;
  99489. /**
  99490. * Initializes the WebXRInput
  99491. * @param helper experience helper which the input should be created for
  99492. */
  99493. constructor(helper: WebXRExperienceHelper);
  99494. /**
  99495. * Disposes of the object
  99496. */
  99497. dispose(): void;
  99498. }
  99499. }
  99500. declare module BABYLON {
  99501. /**
  99502. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  99503. */
  99504. export class WebXRManagedOutputCanvas implements IDisposable {
  99505. private _canvas;
  99506. /**
  99507. * xrpresent context of the canvas which can be used to display/mirror xr content
  99508. */
  99509. canvasContext: Nullable<WebGLRenderingContext>;
  99510. /**
  99511. * Initializes the canvas to be added/removed upon entering/exiting xr
  99512. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  99513. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  99514. */
  99515. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  99516. /**
  99517. * Disposes of the object
  99518. */
  99519. dispose(): void;
  99520. private _setManagedOutputCanvas;
  99521. private _addCanvas;
  99522. private _removeCanvas;
  99523. }
  99524. }
  99525. declare module BABYLON {
  99526. /**
  99527. * Contains an array of blocks representing the octree
  99528. */
  99529. export interface IOctreeContainer<T> {
  99530. /**
  99531. * Blocks within the octree
  99532. */
  99533. blocks: Array<OctreeBlock<T>>;
  99534. }
  99535. /**
  99536. * Class used to store a cell in an octree
  99537. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99538. */
  99539. export class OctreeBlock<T> {
  99540. /**
  99541. * Gets the content of the current block
  99542. */
  99543. entries: T[];
  99544. /**
  99545. * Gets the list of block children
  99546. */
  99547. blocks: Array<OctreeBlock<T>>;
  99548. private _depth;
  99549. private _maxDepth;
  99550. private _capacity;
  99551. private _minPoint;
  99552. private _maxPoint;
  99553. private _boundingVectors;
  99554. private _creationFunc;
  99555. /**
  99556. * Creates a new block
  99557. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  99558. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  99559. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  99560. * @param depth defines the current depth of this block in the octree
  99561. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  99562. * @param creationFunc defines a callback to call when an element is added to the block
  99563. */
  99564. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  99565. /**
  99566. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  99567. */
  99568. readonly capacity: number;
  99569. /**
  99570. * Gets the minimum vector (in world space) of the block's bounding box
  99571. */
  99572. readonly minPoint: Vector3;
  99573. /**
  99574. * Gets the maximum vector (in world space) of the block's bounding box
  99575. */
  99576. readonly maxPoint: Vector3;
  99577. /**
  99578. * Add a new element to this block
  99579. * @param entry defines the element to add
  99580. */
  99581. addEntry(entry: T): void;
  99582. /**
  99583. * Remove an element from this block
  99584. * @param entry defines the element to remove
  99585. */
  99586. removeEntry(entry: T): void;
  99587. /**
  99588. * Add an array of elements to this block
  99589. * @param entries defines the array of elements to add
  99590. */
  99591. addEntries(entries: T[]): void;
  99592. /**
  99593. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  99594. * @param frustumPlanes defines the frustum planes to test
  99595. * @param selection defines the array to store current content if selection is positive
  99596. * @param allowDuplicate defines if the selection array can contains duplicated entries
  99597. */
  99598. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  99599. /**
  99600. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  99601. * @param sphereCenter defines the bounding sphere center
  99602. * @param sphereRadius defines the bounding sphere radius
  99603. * @param selection defines the array to store current content if selection is positive
  99604. * @param allowDuplicate defines if the selection array can contains duplicated entries
  99605. */
  99606. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  99607. /**
  99608. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  99609. * @param ray defines the ray to test with
  99610. * @param selection defines the array to store current content if selection is positive
  99611. */
  99612. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  99613. /**
  99614. * Subdivide the content into child blocks (this block will then be empty)
  99615. */
  99616. createInnerBlocks(): void;
  99617. /**
  99618. * @hidden
  99619. */
  99620. 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;
  99621. }
  99622. }
  99623. declare module BABYLON {
  99624. /**
  99625. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  99626. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99627. */
  99628. export class Octree<T> {
  99629. /** 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.) */
  99630. maxDepth: number;
  99631. /**
  99632. * Blocks within the octree containing objects
  99633. */
  99634. blocks: Array<OctreeBlock<T>>;
  99635. /**
  99636. * Content stored in the octree
  99637. */
  99638. dynamicContent: T[];
  99639. private _maxBlockCapacity;
  99640. private _selectionContent;
  99641. private _creationFunc;
  99642. /**
  99643. * Creates a octree
  99644. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99645. * @param creationFunc function to be used to instatiate the octree
  99646. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  99647. * @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.)
  99648. */
  99649. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  99650. /** 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.) */
  99651. maxDepth?: number);
  99652. /**
  99653. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  99654. * @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);
  99655. * @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);
  99656. * @param entries meshes to be added to the octree blocks
  99657. */
  99658. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  99659. /**
  99660. * Adds a mesh to the octree
  99661. * @param entry Mesh to add to the octree
  99662. */
  99663. addMesh(entry: T): void;
  99664. /**
  99665. * Remove an element from the octree
  99666. * @param entry defines the element to remove
  99667. */
  99668. removeMesh(entry: T): void;
  99669. /**
  99670. * Selects an array of meshes within the frustum
  99671. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  99672. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  99673. * @returns array of meshes within the frustum
  99674. */
  99675. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  99676. /**
  99677. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  99678. * @param sphereCenter defines the bounding sphere center
  99679. * @param sphereRadius defines the bounding sphere radius
  99680. * @param allowDuplicate defines if the selection array can contains duplicated entries
  99681. * @returns an array of objects that intersect the sphere
  99682. */
  99683. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  99684. /**
  99685. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  99686. * @param ray defines the ray to test with
  99687. * @returns array of intersected objects
  99688. */
  99689. intersectsRay(ray: Ray): SmartArray<T>;
  99690. /**
  99691. * Adds a mesh into the octree block if it intersects the block
  99692. */
  99693. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  99694. /**
  99695. * Adds a submesh into the octree block if it intersects the block
  99696. */
  99697. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  99698. }
  99699. }
  99700. declare module BABYLON {
  99701. interface Scene {
  99702. /**
  99703. * @hidden
  99704. * Backing Filed
  99705. */
  99706. _selectionOctree: Octree<AbstractMesh>;
  99707. /**
  99708. * Gets the octree used to boost mesh selection (picking)
  99709. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99710. */
  99711. selectionOctree: Octree<AbstractMesh>;
  99712. /**
  99713. * Creates or updates the octree used to boost selection (picking)
  99714. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99715. * @param maxCapacity defines the maximum capacity per leaf
  99716. * @param maxDepth defines the maximum depth of the octree
  99717. * @returns an octree of AbstractMesh
  99718. */
  99719. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  99720. }
  99721. interface AbstractMesh {
  99722. /**
  99723. * @hidden
  99724. * Backing Field
  99725. */
  99726. _submeshesOctree: Octree<SubMesh>;
  99727. /**
  99728. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  99729. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  99730. * @param maxCapacity defines the maximum size of each block (64 by default)
  99731. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  99732. * @returns the new octree
  99733. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  99734. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99735. */
  99736. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  99737. }
  99738. /**
  99739. * Defines the octree scene component responsible to manage any octrees
  99740. * in a given scene.
  99741. */
  99742. export class OctreeSceneComponent {
  99743. /**
  99744. * The component name helpfull to identify the component in the list of scene components.
  99745. */
  99746. readonly name: string;
  99747. /**
  99748. * The scene the component belongs to.
  99749. */
  99750. scene: Scene;
  99751. /**
  99752. * Indicates if the meshes have been checked to make sure they are isEnabled()
  99753. */
  99754. readonly checksIsEnabled: boolean;
  99755. /**
  99756. * Creates a new instance of the component for the given scene
  99757. * @param scene Defines the scene to register the component in
  99758. */
  99759. constructor(scene: Scene);
  99760. /**
  99761. * Registers the component in a given scene
  99762. */
  99763. register(): void;
  99764. /**
  99765. * Return the list of active meshes
  99766. * @returns the list of active meshes
  99767. */
  99768. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  99769. /**
  99770. * Return the list of active sub meshes
  99771. * @param mesh The mesh to get the candidates sub meshes from
  99772. * @returns the list of active sub meshes
  99773. */
  99774. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  99775. private _tempRay;
  99776. /**
  99777. * Return the list of sub meshes intersecting with a given local ray
  99778. * @param mesh defines the mesh to find the submesh for
  99779. * @param localRay defines the ray in local space
  99780. * @returns the list of intersecting sub meshes
  99781. */
  99782. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  99783. /**
  99784. * Return the list of sub meshes colliding with a collider
  99785. * @param mesh defines the mesh to find the submesh for
  99786. * @param collider defines the collider to evaluate the collision against
  99787. * @returns the list of colliding sub meshes
  99788. */
  99789. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  99790. /**
  99791. * Rebuilds the elements related to this component in case of
  99792. * context lost for instance.
  99793. */
  99794. rebuild(): void;
  99795. /**
  99796. * Disposes the component and the associated ressources.
  99797. */
  99798. dispose(): void;
  99799. }
  99800. }
  99801. declare module BABYLON {
  99802. /**
  99803. * Renders a layer on top of an existing scene
  99804. */
  99805. export class UtilityLayerRenderer implements IDisposable {
  99806. /** the original scene that will be rendered on top of */
  99807. originalScene: Scene;
  99808. private _pointerCaptures;
  99809. private _lastPointerEvents;
  99810. private static _DefaultUtilityLayer;
  99811. private static _DefaultKeepDepthUtilityLayer;
  99812. private _sharedGizmoLight;
  99813. /**
  99814. * @hidden
  99815. * Light which used by gizmos to get light shading
  99816. */
  99817. _getSharedGizmoLight(): HemisphericLight;
  99818. /**
  99819. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  99820. */
  99821. pickUtilitySceneFirst: boolean;
  99822. /**
  99823. * 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)
  99824. */
  99825. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  99826. /**
  99827. * 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)
  99828. */
  99829. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  99830. /**
  99831. * The scene that is rendered on top of the original scene
  99832. */
  99833. utilityLayerScene: Scene;
  99834. /**
  99835. * If the utility layer should automatically be rendered on top of existing scene
  99836. */
  99837. shouldRender: boolean;
  99838. /**
  99839. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  99840. */
  99841. onlyCheckPointerDownEvents: boolean;
  99842. /**
  99843. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  99844. */
  99845. processAllEvents: boolean;
  99846. /**
  99847. * Observable raised when the pointer move from the utility layer scene to the main scene
  99848. */
  99849. onPointerOutObservable: Observable<number>;
  99850. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  99851. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  99852. private _afterRenderObserver;
  99853. private _sceneDisposeObserver;
  99854. private _originalPointerObserver;
  99855. /**
  99856. * Instantiates a UtilityLayerRenderer
  99857. * @param originalScene the original scene that will be rendered on top of
  99858. * @param handleEvents boolean indicating if the utility layer should handle events
  99859. */
  99860. constructor(
  99861. /** the original scene that will be rendered on top of */
  99862. originalScene: Scene, handleEvents?: boolean);
  99863. private _notifyObservers;
  99864. /**
  99865. * Renders the utility layers scene on top of the original scene
  99866. */
  99867. render(): void;
  99868. /**
  99869. * Disposes of the renderer
  99870. */
  99871. dispose(): void;
  99872. private _updateCamera;
  99873. }
  99874. }
  99875. declare module BABYLON {
  99876. /**
  99877. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  99878. */
  99879. export class Gizmo implements IDisposable {
  99880. /** The utility layer the gizmo will be added to */
  99881. gizmoLayer: UtilityLayerRenderer;
  99882. /**
  99883. * The root mesh of the gizmo
  99884. */
  99885. _rootMesh: Mesh;
  99886. private _attachedMesh;
  99887. /**
  99888. * Ratio for the scale of the gizmo (Default: 1)
  99889. */
  99890. scaleRatio: number;
  99891. private _tmpMatrix;
  99892. /**
  99893. * If a custom mesh has been set (Default: false)
  99894. */
  99895. protected _customMeshSet: boolean;
  99896. /**
  99897. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  99898. * * When set, interactions will be enabled
  99899. */
  99900. attachedMesh: Nullable<AbstractMesh>;
  99901. /**
  99902. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  99903. * @param mesh The mesh to replace the default mesh of the gizmo
  99904. */
  99905. setCustomMesh(mesh: Mesh): void;
  99906. /**
  99907. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  99908. */
  99909. updateGizmoRotationToMatchAttachedMesh: boolean;
  99910. /**
  99911. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  99912. */
  99913. updateGizmoPositionToMatchAttachedMesh: boolean;
  99914. /**
  99915. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  99916. */
  99917. protected _updateScale: boolean;
  99918. protected _interactionsEnabled: boolean;
  99919. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99920. private _beforeRenderObserver;
  99921. /**
  99922. * Creates a gizmo
  99923. * @param gizmoLayer The utility layer the gizmo will be added to
  99924. */
  99925. constructor(
  99926. /** The utility layer the gizmo will be added to */
  99927. gizmoLayer?: UtilityLayerRenderer);
  99928. private _tempVector;
  99929. /**
  99930. * @hidden
  99931. * Updates the gizmo to match the attached mesh's position/rotation
  99932. */
  99933. protected _update(): void;
  99934. /**
  99935. * Disposes of the gizmo
  99936. */
  99937. dispose(): void;
  99938. }
  99939. }
  99940. declare module BABYLON {
  99941. /**
  99942. * Single axis drag gizmo
  99943. */
  99944. export class AxisDragGizmo extends Gizmo {
  99945. /**
  99946. * Drag behavior responsible for the gizmos dragging interactions
  99947. */
  99948. dragBehavior: PointerDragBehavior;
  99949. private _pointerObserver;
  99950. /**
  99951. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99952. */
  99953. snapDistance: number;
  99954. /**
  99955. * Event that fires each time the gizmo snaps to a new location.
  99956. * * snapDistance is the the change in distance
  99957. */
  99958. onSnapObservable: Observable<{
  99959. snapDistance: number;
  99960. }>;
  99961. /** @hidden */
  99962. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  99963. /** @hidden */
  99964. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  99965. /**
  99966. * Creates an AxisDragGizmo
  99967. * @param gizmoLayer The utility layer the gizmo will be added to
  99968. * @param dragAxis The axis which the gizmo will be able to drag on
  99969. * @param color The color of the gizmo
  99970. */
  99971. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  99972. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99973. /**
  99974. * Disposes of the gizmo
  99975. */
  99976. dispose(): void;
  99977. }
  99978. }
  99979. declare module BABYLON.Debug {
  99980. /**
  99981. * The Axes viewer will show 3 axes in a specific point in space
  99982. */
  99983. export class AxesViewer {
  99984. private _xAxis;
  99985. private _yAxis;
  99986. private _zAxis;
  99987. private _scaleLinesFactor;
  99988. private _instanced;
  99989. /**
  99990. * Gets the hosting scene
  99991. */
  99992. scene: Scene;
  99993. /**
  99994. * Gets or sets a number used to scale line length
  99995. */
  99996. scaleLines: number;
  99997. /** Gets the node hierarchy used to render x-axis */
  99998. readonly xAxis: TransformNode;
  99999. /** Gets the node hierarchy used to render y-axis */
  100000. readonly yAxis: TransformNode;
  100001. /** Gets the node hierarchy used to render z-axis */
  100002. readonly zAxis: TransformNode;
  100003. /**
  100004. * Creates a new AxesViewer
  100005. * @param scene defines the hosting scene
  100006. * @param scaleLines defines a number used to scale line length (1 by default)
  100007. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  100008. * @param xAxis defines the node hierarchy used to render the x-axis
  100009. * @param yAxis defines the node hierarchy used to render the y-axis
  100010. * @param zAxis defines the node hierarchy used to render the z-axis
  100011. */
  100012. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  100013. /**
  100014. * Force the viewer to update
  100015. * @param position defines the position of the viewer
  100016. * @param xaxis defines the x axis of the viewer
  100017. * @param yaxis defines the y axis of the viewer
  100018. * @param zaxis defines the z axis of the viewer
  100019. */
  100020. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  100021. /**
  100022. * Creates an instance of this axes viewer.
  100023. * @returns a new axes viewer with instanced meshes
  100024. */
  100025. createInstance(): AxesViewer;
  100026. /** Releases resources */
  100027. dispose(): void;
  100028. private static _SetRenderingGroupId;
  100029. }
  100030. }
  100031. declare module BABYLON.Debug {
  100032. /**
  100033. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  100034. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  100035. */
  100036. export class BoneAxesViewer extends AxesViewer {
  100037. /**
  100038. * Gets or sets the target mesh where to display the axes viewer
  100039. */
  100040. mesh: Nullable<Mesh>;
  100041. /**
  100042. * Gets or sets the target bone where to display the axes viewer
  100043. */
  100044. bone: Nullable<Bone>;
  100045. /** Gets current position */
  100046. pos: Vector3;
  100047. /** Gets direction of X axis */
  100048. xaxis: Vector3;
  100049. /** Gets direction of Y axis */
  100050. yaxis: Vector3;
  100051. /** Gets direction of Z axis */
  100052. zaxis: Vector3;
  100053. /**
  100054. * Creates a new BoneAxesViewer
  100055. * @param scene defines the hosting scene
  100056. * @param bone defines the target bone
  100057. * @param mesh defines the target mesh
  100058. * @param scaleLines defines a scaling factor for line length (1 by default)
  100059. */
  100060. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  100061. /**
  100062. * Force the viewer to update
  100063. */
  100064. update(): void;
  100065. /** Releases resources */
  100066. dispose(): void;
  100067. }
  100068. }
  100069. declare module BABYLON {
  100070. /**
  100071. * Interface used to define scene explorer extensibility option
  100072. */
  100073. export interface IExplorerExtensibilityOption {
  100074. /**
  100075. * Define the option label
  100076. */
  100077. label: string;
  100078. /**
  100079. * Defines the action to execute on click
  100080. */
  100081. action: (entity: any) => void;
  100082. }
  100083. /**
  100084. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  100085. */
  100086. export interface IExplorerExtensibilityGroup {
  100087. /**
  100088. * Defines a predicate to test if a given type mut be extended
  100089. */
  100090. predicate: (entity: any) => boolean;
  100091. /**
  100092. * Gets the list of options added to a type
  100093. */
  100094. entries: IExplorerExtensibilityOption[];
  100095. }
  100096. /**
  100097. * Interface used to define the options to use to create the Inspector
  100098. */
  100099. export interface IInspectorOptions {
  100100. /**
  100101. * Display in overlay mode (default: false)
  100102. */
  100103. overlay?: boolean;
  100104. /**
  100105. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  100106. */
  100107. globalRoot?: HTMLElement;
  100108. /**
  100109. * Display the Scene explorer
  100110. */
  100111. showExplorer?: boolean;
  100112. /**
  100113. * Display the property inspector
  100114. */
  100115. showInspector?: boolean;
  100116. /**
  100117. * Display in embed mode (both panes on the right)
  100118. */
  100119. embedMode?: boolean;
  100120. /**
  100121. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  100122. */
  100123. handleResize?: boolean;
  100124. /**
  100125. * Allow the panes to popup (default: true)
  100126. */
  100127. enablePopup?: boolean;
  100128. /**
  100129. * Allow the panes to be closed by users (default: true)
  100130. */
  100131. enableClose?: boolean;
  100132. /**
  100133. * Optional list of extensibility entries
  100134. */
  100135. explorerExtensibility?: IExplorerExtensibilityGroup[];
  100136. /**
  100137. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  100138. */
  100139. inspectorURL?: string;
  100140. }
  100141. interface Scene {
  100142. /**
  100143. * @hidden
  100144. * Backing field
  100145. */
  100146. _debugLayer: DebugLayer;
  100147. /**
  100148. * Gets the debug layer (aka Inspector) associated with the scene
  100149. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100150. */
  100151. debugLayer: DebugLayer;
  100152. }
  100153. /**
  100154. * The debug layer (aka Inspector) is the go to tool in order to better understand
  100155. * what is happening in your scene
  100156. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100157. */
  100158. export class DebugLayer {
  100159. /**
  100160. * Define the url to get the inspector script from.
  100161. * By default it uses the babylonjs CDN.
  100162. * @ignoreNaming
  100163. */
  100164. static InspectorURL: string;
  100165. private _scene;
  100166. private BJSINSPECTOR;
  100167. /**
  100168. * Observable triggered when a property is changed through the inspector.
  100169. */
  100170. onPropertyChangedObservable: Observable<{
  100171. object: any;
  100172. property: string;
  100173. value: any;
  100174. initialValue: any;
  100175. }>;
  100176. /**
  100177. * Instantiates a new debug layer.
  100178. * The debug layer (aka Inspector) is the go to tool in order to better understand
  100179. * what is happening in your scene
  100180. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100181. * @param scene Defines the scene to inspect
  100182. */
  100183. constructor(scene: Scene);
  100184. /** Creates the inspector window. */
  100185. private _createInspector;
  100186. /**
  100187. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  100188. * @param entity defines the entity to select
  100189. * @param lineContainerTitle defines the specific block to highlight
  100190. */
  100191. select(entity: any, lineContainerTitle?: string): void;
  100192. /** Get the inspector from bundle or global */
  100193. private _getGlobalInspector;
  100194. /**
  100195. * Get if the inspector is visible or not.
  100196. * @returns true if visible otherwise, false
  100197. */
  100198. isVisible(): boolean;
  100199. /**
  100200. * Hide the inspector and close its window.
  100201. */
  100202. hide(): void;
  100203. /**
  100204. * Launch the debugLayer.
  100205. * @param config Define the configuration of the inspector
  100206. * @return a promise fulfilled when the debug layer is visible
  100207. */
  100208. show(config?: IInspectorOptions): Promise<DebugLayer>;
  100209. }
  100210. }
  100211. declare module BABYLON {
  100212. /**
  100213. * Class containing static functions to help procedurally build meshes
  100214. */
  100215. export class BoxBuilder {
  100216. /**
  100217. * Creates a box mesh
  100218. * * The parameter `size` sets the size (float) of each box side (default 1)
  100219. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  100220. * * 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)
  100221. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  100222. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100223. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100224. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100225. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  100226. * @param name defines the name of the mesh
  100227. * @param options defines the options used to create the mesh
  100228. * @param scene defines the hosting scene
  100229. * @returns the box mesh
  100230. */
  100231. static CreateBox(name: string, options: {
  100232. size?: number;
  100233. width?: number;
  100234. height?: number;
  100235. depth?: number;
  100236. faceUV?: Vector4[];
  100237. faceColors?: Color4[];
  100238. sideOrientation?: number;
  100239. frontUVs?: Vector4;
  100240. backUVs?: Vector4;
  100241. updatable?: boolean;
  100242. }, scene?: Nullable<Scene>): Mesh;
  100243. }
  100244. }
  100245. declare module BABYLON {
  100246. /**
  100247. * Class containing static functions to help procedurally build meshes
  100248. */
  100249. export class SphereBuilder {
  100250. /**
  100251. * Creates a sphere mesh
  100252. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  100253. * * 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`)
  100254. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  100255. * * 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
  100256. * * 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)
  100257. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100258. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100259. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100260. * @param name defines the name of the mesh
  100261. * @param options defines the options used to create the mesh
  100262. * @param scene defines the hosting scene
  100263. * @returns the sphere mesh
  100264. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  100265. */
  100266. static CreateSphere(name: string, options: {
  100267. segments?: number;
  100268. diameter?: number;
  100269. diameterX?: number;
  100270. diameterY?: number;
  100271. diameterZ?: number;
  100272. arc?: number;
  100273. slice?: number;
  100274. sideOrientation?: number;
  100275. frontUVs?: Vector4;
  100276. backUVs?: Vector4;
  100277. updatable?: boolean;
  100278. }, scene: any): Mesh;
  100279. }
  100280. }
  100281. declare module BABYLON.Debug {
  100282. /**
  100283. * Used to show the physics impostor around the specific mesh
  100284. */
  100285. export class PhysicsViewer {
  100286. /** @hidden */
  100287. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  100288. /** @hidden */
  100289. protected _meshes: Array<Nullable<AbstractMesh>>;
  100290. /** @hidden */
  100291. protected _scene: Nullable<Scene>;
  100292. /** @hidden */
  100293. protected _numMeshes: number;
  100294. /** @hidden */
  100295. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  100296. private _renderFunction;
  100297. private _utilityLayer;
  100298. private _debugBoxMesh;
  100299. private _debugSphereMesh;
  100300. private _debugCylinderMesh;
  100301. private _debugMaterial;
  100302. private _debugMeshMeshes;
  100303. /**
  100304. * Creates a new PhysicsViewer
  100305. * @param scene defines the hosting scene
  100306. */
  100307. constructor(scene: Scene);
  100308. /** @hidden */
  100309. protected _updateDebugMeshes(): void;
  100310. /**
  100311. * Renders a specified physic impostor
  100312. * @param impostor defines the impostor to render
  100313. * @param targetMesh defines the mesh represented by the impostor
  100314. * @returns the new debug mesh used to render the impostor
  100315. */
  100316. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  100317. /**
  100318. * Hides a specified physic impostor
  100319. * @param impostor defines the impostor to hide
  100320. */
  100321. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  100322. private _getDebugMaterial;
  100323. private _getDebugBoxMesh;
  100324. private _getDebugSphereMesh;
  100325. private _getDebugCylinderMesh;
  100326. private _getDebugMeshMesh;
  100327. private _getDebugMesh;
  100328. /** Releases all resources */
  100329. dispose(): void;
  100330. }
  100331. }
  100332. declare module BABYLON {
  100333. /**
  100334. * Class containing static functions to help procedurally build meshes
  100335. */
  100336. export class LinesBuilder {
  100337. /**
  100338. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  100339. * * 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
  100340. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  100341. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  100342. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  100343. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  100344. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  100345. * * 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
  100346. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  100347. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100348. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  100349. * @param name defines the name of the new line system
  100350. * @param options defines the options used to create the line system
  100351. * @param scene defines the hosting scene
  100352. * @returns a new line system mesh
  100353. */
  100354. static CreateLineSystem(name: string, options: {
  100355. lines: Vector3[][];
  100356. updatable?: boolean;
  100357. instance?: Nullable<LinesMesh>;
  100358. colors?: Nullable<Color4[][]>;
  100359. useVertexAlpha?: boolean;
  100360. }, scene: Nullable<Scene>): LinesMesh;
  100361. /**
  100362. * Creates a line mesh
  100363. * 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
  100364. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  100365. * * The parameter `points` is an array successive Vector3
  100366. * * 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
  100367. * * The optional parameter `colors` is an array of successive Color4, one per line point
  100368. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  100369. * * When updating an instance, remember that only point positions can change, not the number of points
  100370. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100371. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  100372. * @param name defines the name of the new line system
  100373. * @param options defines the options used to create the line system
  100374. * @param scene defines the hosting scene
  100375. * @returns a new line mesh
  100376. */
  100377. static CreateLines(name: string, options: {
  100378. points: Vector3[];
  100379. updatable?: boolean;
  100380. instance?: Nullable<LinesMesh>;
  100381. colors?: Color4[];
  100382. useVertexAlpha?: boolean;
  100383. }, scene?: Nullable<Scene>): LinesMesh;
  100384. /**
  100385. * Creates a dashed line mesh
  100386. * * 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
  100387. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  100388. * * The parameter `points` is an array successive Vector3
  100389. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  100390. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  100391. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  100392. * * 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
  100393. * * When updating an instance, remember that only point positions can change, not the number of points
  100394. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100395. * @param name defines the name of the mesh
  100396. * @param options defines the options used to create the mesh
  100397. * @param scene defines the hosting scene
  100398. * @returns the dashed line mesh
  100399. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  100400. */
  100401. static CreateDashedLines(name: string, options: {
  100402. points: Vector3[];
  100403. dashSize?: number;
  100404. gapSize?: number;
  100405. dashNb?: number;
  100406. updatable?: boolean;
  100407. instance?: LinesMesh;
  100408. }, scene?: Nullable<Scene>): LinesMesh;
  100409. }
  100410. }
  100411. declare module BABYLON {
  100412. /**
  100413. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  100414. * in order to better appreciate the issue one might have.
  100415. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  100416. */
  100417. export class RayHelper {
  100418. /**
  100419. * Defines the ray we are currently tryin to visualize.
  100420. */
  100421. ray: Nullable<Ray>;
  100422. private _renderPoints;
  100423. private _renderLine;
  100424. private _renderFunction;
  100425. private _scene;
  100426. private _updateToMeshFunction;
  100427. private _attachedToMesh;
  100428. private _meshSpaceDirection;
  100429. private _meshSpaceOrigin;
  100430. /**
  100431. * Helper function to create a colored helper in a scene in one line.
  100432. * @param ray Defines the ray we are currently tryin to visualize
  100433. * @param scene Defines the scene the ray is used in
  100434. * @param color Defines the color we want to see the ray in
  100435. * @returns The newly created ray helper.
  100436. */
  100437. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  100438. /**
  100439. * Instantiate a new ray helper.
  100440. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  100441. * in order to better appreciate the issue one might have.
  100442. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  100443. * @param ray Defines the ray we are currently tryin to visualize
  100444. */
  100445. constructor(ray: Ray);
  100446. /**
  100447. * Shows the ray we are willing to debug.
  100448. * @param scene Defines the scene the ray needs to be rendered in
  100449. * @param color Defines the color the ray needs to be rendered in
  100450. */
  100451. show(scene: Scene, color?: Color3): void;
  100452. /**
  100453. * Hides the ray we are debugging.
  100454. */
  100455. hide(): void;
  100456. private _render;
  100457. /**
  100458. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  100459. * @param mesh Defines the mesh we want the helper attached to
  100460. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  100461. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  100462. * @param length Defines the length of the ray
  100463. */
  100464. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  100465. /**
  100466. * Detach the ray helper from the mesh it has previously been attached to.
  100467. */
  100468. detachFromMesh(): void;
  100469. private _updateToMesh;
  100470. /**
  100471. * Dispose the helper and release its associated resources.
  100472. */
  100473. dispose(): void;
  100474. }
  100475. }
  100476. declare module BABYLON.Debug {
  100477. /**
  100478. * Class used to render a debug view of a given skeleton
  100479. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  100480. */
  100481. export class SkeletonViewer {
  100482. /** defines the skeleton to render */
  100483. skeleton: Skeleton;
  100484. /** defines the mesh attached to the skeleton */
  100485. mesh: AbstractMesh;
  100486. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  100487. autoUpdateBonesMatrices: boolean;
  100488. /** defines the rendering group id to use with the viewer */
  100489. renderingGroupId: number;
  100490. /** Gets or sets the color used to render the skeleton */
  100491. color: Color3;
  100492. private _scene;
  100493. private _debugLines;
  100494. private _debugMesh;
  100495. private _isEnabled;
  100496. private _renderFunction;
  100497. private _utilityLayer;
  100498. /**
  100499. * Returns the mesh used to render the bones
  100500. */
  100501. readonly debugMesh: Nullable<LinesMesh>;
  100502. /**
  100503. * Creates a new SkeletonViewer
  100504. * @param skeleton defines the skeleton to render
  100505. * @param mesh defines the mesh attached to the skeleton
  100506. * @param scene defines the hosting scene
  100507. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  100508. * @param renderingGroupId defines the rendering group id to use with the viewer
  100509. */
  100510. constructor(
  100511. /** defines the skeleton to render */
  100512. skeleton: Skeleton,
  100513. /** defines the mesh attached to the skeleton */
  100514. mesh: AbstractMesh, scene: Scene,
  100515. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  100516. autoUpdateBonesMatrices?: boolean,
  100517. /** defines the rendering group id to use with the viewer */
  100518. renderingGroupId?: number);
  100519. /** Gets or sets a boolean indicating if the viewer is enabled */
  100520. isEnabled: boolean;
  100521. private _getBonePosition;
  100522. private _getLinesForBonesWithLength;
  100523. private _getLinesForBonesNoLength;
  100524. /** Update the viewer to sync with current skeleton state */
  100525. update(): void;
  100526. /** Release associated resources */
  100527. dispose(): void;
  100528. }
  100529. }
  100530. declare module BABYLON {
  100531. /**
  100532. * Options to create the null engine
  100533. */
  100534. export class NullEngineOptions {
  100535. /**
  100536. * Render width (Default: 512)
  100537. */
  100538. renderWidth: number;
  100539. /**
  100540. * Render height (Default: 256)
  100541. */
  100542. renderHeight: number;
  100543. /**
  100544. * Texture size (Default: 512)
  100545. */
  100546. textureSize: number;
  100547. /**
  100548. * If delta time between frames should be constant
  100549. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100550. */
  100551. deterministicLockstep: boolean;
  100552. /**
  100553. * Maximum about of steps between frames (Default: 4)
  100554. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100555. */
  100556. lockstepMaxSteps: number;
  100557. }
  100558. /**
  100559. * The null engine class provides support for headless version of babylon.js.
  100560. * This can be used in server side scenario or for testing purposes
  100561. */
  100562. export class NullEngine extends Engine {
  100563. private _options;
  100564. /**
  100565. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100566. */
  100567. isDeterministicLockStep(): boolean;
  100568. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  100569. getLockstepMaxSteps(): number;
  100570. /**
  100571. * Sets hardware scaling, used to save performance if needed
  100572. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  100573. */
  100574. getHardwareScalingLevel(): number;
  100575. constructor(options?: NullEngineOptions);
  100576. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  100577. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  100578. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  100579. getRenderWidth(useScreen?: boolean): number;
  100580. getRenderHeight(useScreen?: boolean): number;
  100581. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  100582. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  100583. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  100584. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  100585. bindSamplers(effect: Effect): void;
  100586. enableEffect(effect: Effect): void;
  100587. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  100588. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  100589. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  100590. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  100591. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  100592. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  100593. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  100594. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  100595. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  100596. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  100597. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  100598. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  100599. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  100600. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  100601. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  100602. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  100603. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  100604. setFloat(uniform: WebGLUniformLocation, value: number): void;
  100605. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  100606. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  100607. setBool(uniform: WebGLUniformLocation, bool: number): void;
  100608. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  100609. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  100610. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  100611. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  100612. bindBuffers(vertexBuffers: {
  100613. [key: string]: VertexBuffer;
  100614. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  100615. wipeCaches(bruteForce?: boolean): void;
  100616. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  100617. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  100618. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  100619. /** @hidden */
  100620. _createTexture(): WebGLTexture;
  100621. /** @hidden */
  100622. _releaseTexture(texture: InternalTexture): void;
  100623. 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;
  100624. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  100625. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  100626. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  100627. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  100628. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  100629. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  100630. areAllEffectsReady(): boolean;
  100631. /**
  100632. * @hidden
  100633. * Get the current error code of the webGL context
  100634. * @returns the error code
  100635. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  100636. */
  100637. getError(): number;
  100638. /** @hidden */
  100639. _getUnpackAlignement(): number;
  100640. /** @hidden */
  100641. _unpackFlipY(value: boolean): void;
  100642. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  100643. /**
  100644. * Updates a dynamic vertex buffer.
  100645. * @param vertexBuffer the vertex buffer to update
  100646. * @param data the data used to update the vertex buffer
  100647. * @param byteOffset the byte offset of the data (optional)
  100648. * @param byteLength the byte length of the data (optional)
  100649. */
  100650. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  100651. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  100652. /** @hidden */
  100653. _bindTexture(channel: number, texture: InternalTexture): void;
  100654. /** @hidden */
  100655. _releaseBuffer(buffer: WebGLBuffer): boolean;
  100656. releaseEffects(): void;
  100657. displayLoadingUI(): void;
  100658. hideLoadingUI(): void;
  100659. /** @hidden */
  100660. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  100661. /** @hidden */
  100662. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  100663. /** @hidden */
  100664. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  100665. /** @hidden */
  100666. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  100667. }
  100668. }
  100669. declare module BABYLON {
  100670. /** @hidden */
  100671. export class _OcclusionDataStorage {
  100672. /** @hidden */
  100673. occlusionInternalRetryCounter: number;
  100674. /** @hidden */
  100675. isOcclusionQueryInProgress: boolean;
  100676. /** @hidden */
  100677. isOccluded: boolean;
  100678. /** @hidden */
  100679. occlusionRetryCount: number;
  100680. /** @hidden */
  100681. occlusionType: number;
  100682. /** @hidden */
  100683. occlusionQueryAlgorithmType: number;
  100684. }
  100685. interface Engine {
  100686. /**
  100687. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  100688. * @return the new query
  100689. */
  100690. createQuery(): WebGLQuery;
  100691. /**
  100692. * Delete and release a webGL query
  100693. * @param query defines the query to delete
  100694. * @return the current engine
  100695. */
  100696. deleteQuery(query: WebGLQuery): Engine;
  100697. /**
  100698. * Check if a given query has resolved and got its value
  100699. * @param query defines the query to check
  100700. * @returns true if the query got its value
  100701. */
  100702. isQueryResultAvailable(query: WebGLQuery): boolean;
  100703. /**
  100704. * Gets the value of a given query
  100705. * @param query defines the query to check
  100706. * @returns the value of the query
  100707. */
  100708. getQueryResult(query: WebGLQuery): number;
  100709. /**
  100710. * Initiates an occlusion query
  100711. * @param algorithmType defines the algorithm to use
  100712. * @param query defines the query to use
  100713. * @returns the current engine
  100714. * @see http://doc.babylonjs.com/features/occlusionquery
  100715. */
  100716. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  100717. /**
  100718. * Ends an occlusion query
  100719. * @see http://doc.babylonjs.com/features/occlusionquery
  100720. * @param algorithmType defines the algorithm to use
  100721. * @returns the current engine
  100722. */
  100723. endOcclusionQuery(algorithmType: number): Engine;
  100724. /**
  100725. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  100726. * Please note that only one query can be issued at a time
  100727. * @returns a time token used to track the time span
  100728. */
  100729. startTimeQuery(): Nullable<_TimeToken>;
  100730. /**
  100731. * Ends a time query
  100732. * @param token defines the token used to measure the time span
  100733. * @returns the time spent (in ns)
  100734. */
  100735. endTimeQuery(token: _TimeToken): int;
  100736. /** @hidden */
  100737. _currentNonTimestampToken: Nullable<_TimeToken>;
  100738. /** @hidden */
  100739. _createTimeQuery(): WebGLQuery;
  100740. /** @hidden */
  100741. _deleteTimeQuery(query: WebGLQuery): void;
  100742. /** @hidden */
  100743. _getGlAlgorithmType(algorithmType: number): number;
  100744. /** @hidden */
  100745. _getTimeQueryResult(query: WebGLQuery): any;
  100746. /** @hidden */
  100747. _getTimeQueryAvailability(query: WebGLQuery): any;
  100748. }
  100749. interface AbstractMesh {
  100750. /**
  100751. * Backing filed
  100752. * @hidden
  100753. */
  100754. __occlusionDataStorage: _OcclusionDataStorage;
  100755. /**
  100756. * Access property
  100757. * @hidden
  100758. */
  100759. _occlusionDataStorage: _OcclusionDataStorage;
  100760. /**
  100761. * 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.
  100762. * The default value is -1 which means don't break the query and wait till the result
  100763. * @see http://doc.babylonjs.com/features/occlusionquery
  100764. */
  100765. occlusionRetryCount: number;
  100766. /**
  100767. * 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:
  100768. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  100769. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  100770. * * 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.
  100771. * @see http://doc.babylonjs.com/features/occlusionquery
  100772. */
  100773. occlusionType: number;
  100774. /**
  100775. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  100776. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  100777. * * 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.
  100778. * @see http://doc.babylonjs.com/features/occlusionquery
  100779. */
  100780. occlusionQueryAlgorithmType: number;
  100781. /**
  100782. * 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
  100783. * @see http://doc.babylonjs.com/features/occlusionquery
  100784. */
  100785. isOccluded: boolean;
  100786. /**
  100787. * Flag to check the progress status of the query
  100788. * @see http://doc.babylonjs.com/features/occlusionquery
  100789. */
  100790. isOcclusionQueryInProgress: boolean;
  100791. }
  100792. }
  100793. declare module BABYLON {
  100794. /** @hidden */
  100795. export var _forceTransformFeedbackToBundle: boolean;
  100796. interface Engine {
  100797. /**
  100798. * Creates a webGL transform feedback object
  100799. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  100800. * @returns the webGL transform feedback object
  100801. */
  100802. createTransformFeedback(): WebGLTransformFeedback;
  100803. /**
  100804. * Delete a webGL transform feedback object
  100805. * @param value defines the webGL transform feedback object to delete
  100806. */
  100807. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  100808. /**
  100809. * Bind a webGL transform feedback object to the webgl context
  100810. * @param value defines the webGL transform feedback object to bind
  100811. */
  100812. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  100813. /**
  100814. * Begins a transform feedback operation
  100815. * @param usePoints defines if points or triangles must be used
  100816. */
  100817. beginTransformFeedback(usePoints: boolean): void;
  100818. /**
  100819. * Ends a transform feedback operation
  100820. */
  100821. endTransformFeedback(): void;
  100822. /**
  100823. * Specify the varyings to use with transform feedback
  100824. * @param program defines the associated webGL program
  100825. * @param value defines the list of strings representing the varying names
  100826. */
  100827. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  100828. /**
  100829. * Bind a webGL buffer for a transform feedback operation
  100830. * @param value defines the webGL buffer to bind
  100831. */
  100832. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  100833. }
  100834. }
  100835. declare module BABYLON {
  100836. /**
  100837. * Gather the list of clipboard event types as constants.
  100838. */
  100839. export class ClipboardEventTypes {
  100840. /**
  100841. * The clipboard event is fired when a copy command is active (pressed).
  100842. */
  100843. static readonly COPY: number;
  100844. /**
  100845. * The clipboard event is fired when a cut command is active (pressed).
  100846. */
  100847. static readonly CUT: number;
  100848. /**
  100849. * The clipboard event is fired when a paste command is active (pressed).
  100850. */
  100851. static readonly PASTE: number;
  100852. }
  100853. /**
  100854. * This class is used to store clipboard related info for the onClipboardObservable event.
  100855. */
  100856. export class ClipboardInfo {
  100857. /**
  100858. * Defines the type of event (BABYLON.ClipboardEventTypes)
  100859. */
  100860. type: number;
  100861. /**
  100862. * Defines the related dom event
  100863. */
  100864. event: ClipboardEvent;
  100865. /**
  100866. *Creates an instance of ClipboardInfo.
  100867. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  100868. * @param event Defines the related dom event
  100869. */
  100870. constructor(
  100871. /**
  100872. * Defines the type of event (BABYLON.ClipboardEventTypes)
  100873. */
  100874. type: number,
  100875. /**
  100876. * Defines the related dom event
  100877. */
  100878. event: ClipboardEvent);
  100879. /**
  100880. * Get the clipboard event's type from the keycode.
  100881. * @param keyCode Defines the keyCode for the current keyboard event.
  100882. * @return {number}
  100883. */
  100884. static GetTypeFromCharacter(keyCode: number): number;
  100885. }
  100886. }
  100887. declare module BABYLON {
  100888. /**
  100889. * Class used to represent data loading progression
  100890. */
  100891. export class SceneLoaderProgressEvent {
  100892. /** defines if data length to load can be evaluated */
  100893. readonly lengthComputable: boolean;
  100894. /** defines the loaded data length */
  100895. readonly loaded: number;
  100896. /** defines the data length to load */
  100897. readonly total: number;
  100898. /**
  100899. * Create a new progress event
  100900. * @param lengthComputable defines if data length to load can be evaluated
  100901. * @param loaded defines the loaded data length
  100902. * @param total defines the data length to load
  100903. */
  100904. constructor(
  100905. /** defines if data length to load can be evaluated */
  100906. lengthComputable: boolean,
  100907. /** defines the loaded data length */
  100908. loaded: number,
  100909. /** defines the data length to load */
  100910. total: number);
  100911. /**
  100912. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  100913. * @param event defines the source event
  100914. * @returns a new SceneLoaderProgressEvent
  100915. */
  100916. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  100917. }
  100918. /**
  100919. * Interface used by SceneLoader plugins to define supported file extensions
  100920. */
  100921. export interface ISceneLoaderPluginExtensions {
  100922. /**
  100923. * Defines the list of supported extensions
  100924. */
  100925. [extension: string]: {
  100926. isBinary: boolean;
  100927. };
  100928. }
  100929. /**
  100930. * Interface used by SceneLoader plugin factory
  100931. */
  100932. export interface ISceneLoaderPluginFactory {
  100933. /**
  100934. * Defines the name of the factory
  100935. */
  100936. name: string;
  100937. /**
  100938. * Function called to create a new plugin
  100939. * @return the new plugin
  100940. */
  100941. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  100942. /**
  100943. * Boolean indicating if the plugin can direct load specific data
  100944. */
  100945. canDirectLoad?: (data: string) => boolean;
  100946. }
  100947. /**
  100948. * Interface used to define a SceneLoader plugin
  100949. */
  100950. export interface ISceneLoaderPlugin {
  100951. /**
  100952. * The friendly name of this plugin.
  100953. */
  100954. name: string;
  100955. /**
  100956. * The file extensions supported by this plugin.
  100957. */
  100958. extensions: string | ISceneLoaderPluginExtensions;
  100959. /**
  100960. * Import meshes into a scene.
  100961. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  100962. * @param scene The scene to import into
  100963. * @param data The data to import
  100964. * @param rootUrl The root url for scene and resources
  100965. * @param meshes The meshes array to import into
  100966. * @param particleSystems The particle systems array to import into
  100967. * @param skeletons The skeletons array to import into
  100968. * @param onError The callback when import fails
  100969. * @returns True if successful or false otherwise
  100970. */
  100971. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  100972. /**
  100973. * Load into a scene.
  100974. * @param scene The scene to load into
  100975. * @param data The data to import
  100976. * @param rootUrl The root url for scene and resources
  100977. * @param onError The callback when import fails
  100978. * @returns true if successful or false otherwise
  100979. */
  100980. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  100981. /**
  100982. * The callback that returns true if the data can be directly loaded.
  100983. */
  100984. canDirectLoad?: (data: string) => boolean;
  100985. /**
  100986. * The callback that allows custom handling of the root url based on the response url.
  100987. */
  100988. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  100989. /**
  100990. * Load into an asset container.
  100991. * @param scene The scene to load into
  100992. * @param data The data to import
  100993. * @param rootUrl The root url for scene and resources
  100994. * @param onError The callback when import fails
  100995. * @returns The loaded asset container
  100996. */
  100997. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  100998. }
  100999. /**
  101000. * Interface used to define an async SceneLoader plugin
  101001. */
  101002. export interface ISceneLoaderPluginAsync {
  101003. /**
  101004. * The friendly name of this plugin.
  101005. */
  101006. name: string;
  101007. /**
  101008. * The file extensions supported by this plugin.
  101009. */
  101010. extensions: string | ISceneLoaderPluginExtensions;
  101011. /**
  101012. * Import meshes into a scene.
  101013. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101014. * @param scene The scene to import into
  101015. * @param data The data to import
  101016. * @param rootUrl The root url for scene and resources
  101017. * @param onProgress The callback when the load progresses
  101018. * @param fileName Defines the name of the file to load
  101019. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  101020. */
  101021. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  101022. meshes: AbstractMesh[];
  101023. particleSystems: IParticleSystem[];
  101024. skeletons: Skeleton[];
  101025. animationGroups: AnimationGroup[];
  101026. }>;
  101027. /**
  101028. * Load into a scene.
  101029. * @param scene The scene to load into
  101030. * @param data The data to import
  101031. * @param rootUrl The root url for scene and resources
  101032. * @param onProgress The callback when the load progresses
  101033. * @param fileName Defines the name of the file to load
  101034. * @returns Nothing
  101035. */
  101036. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  101037. /**
  101038. * The callback that returns true if the data can be directly loaded.
  101039. */
  101040. canDirectLoad?: (data: string) => boolean;
  101041. /**
  101042. * The callback that allows custom handling of the root url based on the response url.
  101043. */
  101044. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  101045. /**
  101046. * Load into an asset container.
  101047. * @param scene The scene to load into
  101048. * @param data The data to import
  101049. * @param rootUrl The root url for scene and resources
  101050. * @param onProgress The callback when the load progresses
  101051. * @param fileName Defines the name of the file to load
  101052. * @returns The loaded asset container
  101053. */
  101054. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  101055. }
  101056. /**
  101057. * Class used to load scene from various file formats using registered plugins
  101058. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  101059. */
  101060. export class SceneLoader {
  101061. /**
  101062. * No logging while loading
  101063. */
  101064. static readonly NO_LOGGING: number;
  101065. /**
  101066. * Minimal logging while loading
  101067. */
  101068. static readonly MINIMAL_LOGGING: number;
  101069. /**
  101070. * Summary logging while loading
  101071. */
  101072. static readonly SUMMARY_LOGGING: number;
  101073. /**
  101074. * Detailled logging while loading
  101075. */
  101076. static readonly DETAILED_LOGGING: number;
  101077. /**
  101078. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  101079. */
  101080. static ForceFullSceneLoadingForIncremental: boolean;
  101081. /**
  101082. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  101083. */
  101084. static ShowLoadingScreen: boolean;
  101085. /**
  101086. * Defines the current logging level (while loading the scene)
  101087. * @ignorenaming
  101088. */
  101089. static loggingLevel: number;
  101090. /**
  101091. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  101092. */
  101093. static CleanBoneMatrixWeights: boolean;
  101094. /**
  101095. * Event raised when a plugin is used to load a scene
  101096. */
  101097. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  101098. private static _registeredPlugins;
  101099. private static _getDefaultPlugin;
  101100. private static _getPluginForExtension;
  101101. private static _getPluginForDirectLoad;
  101102. private static _getPluginForFilename;
  101103. private static _getDirectLoad;
  101104. private static _loadData;
  101105. private static _getFileInfo;
  101106. /**
  101107. * Gets a plugin that can load the given extension
  101108. * @param extension defines the extension to load
  101109. * @returns a plugin or null if none works
  101110. */
  101111. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  101112. /**
  101113. * Gets a boolean indicating that the given extension can be loaded
  101114. * @param extension defines the extension to load
  101115. * @returns true if the extension is supported
  101116. */
  101117. static IsPluginForExtensionAvailable(extension: string): boolean;
  101118. /**
  101119. * Adds a new plugin to the list of registered plugins
  101120. * @param plugin defines the plugin to add
  101121. */
  101122. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  101123. /**
  101124. * Import meshes into a scene
  101125. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101126. * @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)
  101127. * @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)
  101128. * @param scene the instance of BABYLON.Scene to append to
  101129. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  101130. * @param onProgress a callback with a progress event for each file being loaded
  101131. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  101132. * @param pluginExtension the extension used to determine the plugin
  101133. * @returns The loaded plugin
  101134. */
  101135. 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>;
  101136. /**
  101137. * Import meshes into a scene
  101138. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101139. * @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)
  101140. * @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)
  101141. * @param scene the instance of BABYLON.Scene to append to
  101142. * @param onProgress a callback with a progress event for each file being loaded
  101143. * @param pluginExtension the extension used to determine the plugin
  101144. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  101145. */
  101146. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  101147. meshes: AbstractMesh[];
  101148. particleSystems: IParticleSystem[];
  101149. skeletons: Skeleton[];
  101150. animationGroups: AnimationGroup[];
  101151. }>;
  101152. /**
  101153. * Load a scene
  101154. * @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)
  101155. * @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)
  101156. * @param engine is the instance of BABYLON.Engine to use to create the scene
  101157. * @param onSuccess a callback with the scene when import succeeds
  101158. * @param onProgress a callback with a progress event for each file being loaded
  101159. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  101160. * @param pluginExtension the extension used to determine the plugin
  101161. * @returns The loaded plugin
  101162. */
  101163. 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>;
  101164. /**
  101165. * Load a scene
  101166. * @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)
  101167. * @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)
  101168. * @param engine is the instance of BABYLON.Engine to use to create the scene
  101169. * @param onProgress a callback with a progress event for each file being loaded
  101170. * @param pluginExtension the extension used to determine the plugin
  101171. * @returns The loaded scene
  101172. */
  101173. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  101174. /**
  101175. * Append a scene
  101176. * @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)
  101177. * @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)
  101178. * @param scene is the instance of BABYLON.Scene to append to
  101179. * @param onSuccess a callback with the scene when import succeeds
  101180. * @param onProgress a callback with a progress event for each file being loaded
  101181. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  101182. * @param pluginExtension the extension used to determine the plugin
  101183. * @returns The loaded plugin
  101184. */
  101185. 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>;
  101186. /**
  101187. * Append a scene
  101188. * @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)
  101189. * @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)
  101190. * @param scene is the instance of BABYLON.Scene to append to
  101191. * @param onProgress a callback with a progress event for each file being loaded
  101192. * @param pluginExtension the extension used to determine the plugin
  101193. * @returns The given scene
  101194. */
  101195. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  101196. /**
  101197. * Load a scene into an asset container
  101198. * @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)
  101199. * @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)
  101200. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  101201. * @param onSuccess a callback with the scene when import succeeds
  101202. * @param onProgress a callback with a progress event for each file being loaded
  101203. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  101204. * @param pluginExtension the extension used to determine the plugin
  101205. * @returns The loaded plugin
  101206. */
  101207. 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>;
  101208. /**
  101209. * Load a scene into an asset container
  101210. * @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)
  101211. * @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)
  101212. * @param scene is the instance of Scene to append to
  101213. * @param onProgress a callback with a progress event for each file being loaded
  101214. * @param pluginExtension the extension used to determine the plugin
  101215. * @returns The loaded asset container
  101216. */
  101217. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  101218. }
  101219. }
  101220. declare module BABYLON {
  101221. /**
  101222. * Google Daydream controller
  101223. */
  101224. export class DaydreamController extends WebVRController {
  101225. /**
  101226. * Base Url for the controller model.
  101227. */
  101228. static MODEL_BASE_URL: string;
  101229. /**
  101230. * File name for the controller model.
  101231. */
  101232. static MODEL_FILENAME: string;
  101233. /**
  101234. * Gamepad Id prefix used to identify Daydream Controller.
  101235. */
  101236. static readonly GAMEPAD_ID_PREFIX: string;
  101237. /**
  101238. * Creates a new DaydreamController from a gamepad
  101239. * @param vrGamepad the gamepad that the controller should be created from
  101240. */
  101241. constructor(vrGamepad: any);
  101242. /**
  101243. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101244. * @param scene scene in which to add meshes
  101245. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101246. */
  101247. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101248. /**
  101249. * Called once for each button that changed state since the last frame
  101250. * @param buttonIdx Which button index changed
  101251. * @param state New state of the button
  101252. * @param changes Which properties on the state changed since last frame
  101253. */
  101254. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101255. }
  101256. }
  101257. declare module BABYLON {
  101258. /**
  101259. * Gear VR Controller
  101260. */
  101261. export class GearVRController extends WebVRController {
  101262. /**
  101263. * Base Url for the controller model.
  101264. */
  101265. static MODEL_BASE_URL: string;
  101266. /**
  101267. * File name for the controller model.
  101268. */
  101269. static MODEL_FILENAME: string;
  101270. /**
  101271. * Gamepad Id prefix used to identify this controller.
  101272. */
  101273. static readonly GAMEPAD_ID_PREFIX: string;
  101274. private readonly _buttonIndexToObservableNameMap;
  101275. /**
  101276. * Creates a new GearVRController from a gamepad
  101277. * @param vrGamepad the gamepad that the controller should be created from
  101278. */
  101279. constructor(vrGamepad: any);
  101280. /**
  101281. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101282. * @param scene scene in which to add meshes
  101283. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101284. */
  101285. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101286. /**
  101287. * Called once for each button that changed state since the last frame
  101288. * @param buttonIdx Which button index changed
  101289. * @param state New state of the button
  101290. * @param changes Which properties on the state changed since last frame
  101291. */
  101292. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101293. }
  101294. }
  101295. declare module BABYLON {
  101296. /**
  101297. * Generic Controller
  101298. */
  101299. export class GenericController extends WebVRController {
  101300. /**
  101301. * Base Url for the controller model.
  101302. */
  101303. static readonly MODEL_BASE_URL: string;
  101304. /**
  101305. * File name for the controller model.
  101306. */
  101307. static readonly MODEL_FILENAME: string;
  101308. /**
  101309. * Creates a new GenericController from a gamepad
  101310. * @param vrGamepad the gamepad that the controller should be created from
  101311. */
  101312. constructor(vrGamepad: any);
  101313. /**
  101314. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101315. * @param scene scene in which to add meshes
  101316. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101317. */
  101318. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101319. /**
  101320. * Called once for each button that changed state since the last frame
  101321. * @param buttonIdx Which button index changed
  101322. * @param state New state of the button
  101323. * @param changes Which properties on the state changed since last frame
  101324. */
  101325. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101326. }
  101327. }
  101328. declare module BABYLON {
  101329. /**
  101330. * Oculus Touch Controller
  101331. */
  101332. export class OculusTouchController extends WebVRController {
  101333. /**
  101334. * Base Url for the controller model.
  101335. */
  101336. static MODEL_BASE_URL: string;
  101337. /**
  101338. * File name for the left controller model.
  101339. */
  101340. static MODEL_LEFT_FILENAME: string;
  101341. /**
  101342. * File name for the right controller model.
  101343. */
  101344. static MODEL_RIGHT_FILENAME: string;
  101345. /**
  101346. * Fired when the secondary trigger on this controller is modified
  101347. */
  101348. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  101349. /**
  101350. * Fired when the thumb rest on this controller is modified
  101351. */
  101352. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  101353. /**
  101354. * Creates a new OculusTouchController from a gamepad
  101355. * @param vrGamepad the gamepad that the controller should be created from
  101356. */
  101357. constructor(vrGamepad: any);
  101358. /**
  101359. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101360. * @param scene scene in which to add meshes
  101361. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101362. */
  101363. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101364. /**
  101365. * Fired when the A button on this controller is modified
  101366. */
  101367. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101368. /**
  101369. * Fired when the B button on this controller is modified
  101370. */
  101371. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101372. /**
  101373. * Fired when the X button on this controller is modified
  101374. */
  101375. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101376. /**
  101377. * Fired when the Y button on this controller is modified
  101378. */
  101379. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101380. /**
  101381. * Called once for each button that changed state since the last frame
  101382. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  101383. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  101384. * 2) secondary trigger (same)
  101385. * 3) A (right) X (left), touch, pressed = value
  101386. * 4) B / Y
  101387. * 5) thumb rest
  101388. * @param buttonIdx Which button index changed
  101389. * @param state New state of the button
  101390. * @param changes Which properties on the state changed since last frame
  101391. */
  101392. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101393. }
  101394. }
  101395. declare module BABYLON {
  101396. /**
  101397. * Vive Controller
  101398. */
  101399. export class ViveController extends WebVRController {
  101400. /**
  101401. * Base Url for the controller model.
  101402. */
  101403. static MODEL_BASE_URL: string;
  101404. /**
  101405. * File name for the controller model.
  101406. */
  101407. static MODEL_FILENAME: string;
  101408. /**
  101409. * Creates a new ViveController from a gamepad
  101410. * @param vrGamepad the gamepad that the controller should be created from
  101411. */
  101412. constructor(vrGamepad: any);
  101413. /**
  101414. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101415. * @param scene scene in which to add meshes
  101416. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101417. */
  101418. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101419. /**
  101420. * Fired when the left button on this controller is modified
  101421. */
  101422. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101423. /**
  101424. * Fired when the right button on this controller is modified
  101425. */
  101426. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101427. /**
  101428. * Fired when the menu button on this controller is modified
  101429. */
  101430. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101431. /**
  101432. * Called once for each button that changed state since the last frame
  101433. * Vive mapping:
  101434. * 0: touchpad
  101435. * 1: trigger
  101436. * 2: left AND right buttons
  101437. * 3: menu button
  101438. * @param buttonIdx Which button index changed
  101439. * @param state New state of the button
  101440. * @param changes Which properties on the state changed since last frame
  101441. */
  101442. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101443. }
  101444. }
  101445. declare module BABYLON {
  101446. /**
  101447. * Defines the WindowsMotionController object that the state of the windows motion controller
  101448. */
  101449. export class WindowsMotionController extends WebVRController {
  101450. /**
  101451. * The base url used to load the left and right controller models
  101452. */
  101453. static MODEL_BASE_URL: string;
  101454. /**
  101455. * The name of the left controller model file
  101456. */
  101457. static MODEL_LEFT_FILENAME: string;
  101458. /**
  101459. * The name of the right controller model file
  101460. */
  101461. static MODEL_RIGHT_FILENAME: string;
  101462. /**
  101463. * The controller name prefix for this controller type
  101464. */
  101465. static readonly GAMEPAD_ID_PREFIX: string;
  101466. /**
  101467. * The controller id pattern for this controller type
  101468. */
  101469. private static readonly GAMEPAD_ID_PATTERN;
  101470. private _loadedMeshInfo;
  101471. private readonly _mapping;
  101472. /**
  101473. * Fired when the trackpad on this controller is clicked
  101474. */
  101475. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  101476. /**
  101477. * Fired when the trackpad on this controller is modified
  101478. */
  101479. onTrackpadValuesChangedObservable: Observable<StickValues>;
  101480. /**
  101481. * The current x and y values of this controller's trackpad
  101482. */
  101483. trackpad: StickValues;
  101484. /**
  101485. * Creates a new WindowsMotionController from a gamepad
  101486. * @param vrGamepad the gamepad that the controller should be created from
  101487. */
  101488. constructor(vrGamepad: any);
  101489. /**
  101490. * Fired when the trigger on this controller is modified
  101491. */
  101492. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101493. /**
  101494. * Fired when the menu button on this controller is modified
  101495. */
  101496. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101497. /**
  101498. * Fired when the grip button on this controller is modified
  101499. */
  101500. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101501. /**
  101502. * Fired when the thumbstick button on this controller is modified
  101503. */
  101504. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101505. /**
  101506. * Fired when the touchpad button on this controller is modified
  101507. */
  101508. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101509. /**
  101510. * Fired when the touchpad values on this controller are modified
  101511. */
  101512. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  101513. private _updateTrackpad;
  101514. /**
  101515. * Called once per frame by the engine.
  101516. */
  101517. update(): void;
  101518. /**
  101519. * Called once for each button that changed state since the last frame
  101520. * @param buttonIdx Which button index changed
  101521. * @param state New state of the button
  101522. * @param changes Which properties on the state changed since last frame
  101523. */
  101524. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101525. /**
  101526. * Moves the buttons on the controller mesh based on their current state
  101527. * @param buttonName the name of the button to move
  101528. * @param buttonValue the value of the button which determines the buttons new position
  101529. */
  101530. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  101531. /**
  101532. * Moves the axis on the controller mesh based on its current state
  101533. * @param axis the index of the axis
  101534. * @param axisValue the value of the axis which determines the meshes new position
  101535. * @hidden
  101536. */
  101537. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  101538. /**
  101539. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101540. * @param scene scene in which to add meshes
  101541. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101542. */
  101543. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  101544. /**
  101545. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  101546. * can be transformed by button presses and axes values, based on this._mapping.
  101547. *
  101548. * @param scene scene in which the meshes exist
  101549. * @param meshes list of meshes that make up the controller model to process
  101550. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  101551. */
  101552. private processModel;
  101553. private createMeshInfo;
  101554. /**
  101555. * Gets the ray of the controller in the direction the controller is pointing
  101556. * @param length the length the resulting ray should be
  101557. * @returns a ray in the direction the controller is pointing
  101558. */
  101559. getForwardRay(length?: number): Ray;
  101560. /**
  101561. * Disposes of the controller
  101562. */
  101563. dispose(): void;
  101564. }
  101565. }
  101566. declare module BABYLON {
  101567. /**
  101568. * Single axis scale gizmo
  101569. */
  101570. export class AxisScaleGizmo extends Gizmo {
  101571. private _coloredMaterial;
  101572. /**
  101573. * Drag behavior responsible for the gizmos dragging interactions
  101574. */
  101575. dragBehavior: PointerDragBehavior;
  101576. private _pointerObserver;
  101577. /**
  101578. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  101579. */
  101580. snapDistance: number;
  101581. /**
  101582. * Event that fires each time the gizmo snaps to a new location.
  101583. * * snapDistance is the the change in distance
  101584. */
  101585. onSnapObservable: Observable<{
  101586. snapDistance: number;
  101587. }>;
  101588. /**
  101589. * If the scaling operation should be done on all axis (default: false)
  101590. */
  101591. uniformScaling: boolean;
  101592. /**
  101593. * Creates an AxisScaleGizmo
  101594. * @param gizmoLayer The utility layer the gizmo will be added to
  101595. * @param dragAxis The axis which the gizmo will be able to scale on
  101596. * @param color The color of the gizmo
  101597. */
  101598. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  101599. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  101600. /**
  101601. * Disposes of the gizmo
  101602. */
  101603. dispose(): void;
  101604. /**
  101605. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  101606. * @param mesh The mesh to replace the default mesh of the gizmo
  101607. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  101608. */
  101609. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  101610. }
  101611. }
  101612. declare module BABYLON {
  101613. /**
  101614. * Bounding box gizmo
  101615. */
  101616. export class BoundingBoxGizmo extends Gizmo {
  101617. private _lineBoundingBox;
  101618. private _rotateSpheresParent;
  101619. private _scaleBoxesParent;
  101620. private _boundingDimensions;
  101621. private _renderObserver;
  101622. private _pointerObserver;
  101623. private _scaleDragSpeed;
  101624. private _tmpQuaternion;
  101625. private _tmpVector;
  101626. private _tmpRotationMatrix;
  101627. /**
  101628. * 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)
  101629. */
  101630. ignoreChildren: boolean;
  101631. /**
  101632. * 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)
  101633. */
  101634. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  101635. /**
  101636. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  101637. */
  101638. rotationSphereSize: number;
  101639. /**
  101640. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  101641. */
  101642. scaleBoxSize: number;
  101643. /**
  101644. * 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)
  101645. */
  101646. fixedDragMeshScreenSize: boolean;
  101647. /**
  101648. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  101649. */
  101650. fixedDragMeshScreenSizeDistanceFactor: number;
  101651. /**
  101652. * Fired when a rotation sphere or scale box is dragged
  101653. */
  101654. onDragStartObservable: Observable<{}>;
  101655. /**
  101656. * Fired when a scale box is dragged
  101657. */
  101658. onScaleBoxDragObservable: Observable<{}>;
  101659. /**
  101660. * Fired when a scale box drag is ended
  101661. */
  101662. onScaleBoxDragEndObservable: Observable<{}>;
  101663. /**
  101664. * Fired when a rotation sphere is dragged
  101665. */
  101666. onRotationSphereDragObservable: Observable<{}>;
  101667. /**
  101668. * Fired when a rotation sphere drag is ended
  101669. */
  101670. onRotationSphereDragEndObservable: Observable<{}>;
  101671. /**
  101672. * 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)
  101673. */
  101674. scalePivot: Nullable<Vector3>;
  101675. private _anchorMesh;
  101676. private _existingMeshScale;
  101677. private _dragMesh;
  101678. private pointerDragBehavior;
  101679. private coloredMaterial;
  101680. private hoverColoredMaterial;
  101681. /**
  101682. * Sets the color of the bounding box gizmo
  101683. * @param color the color to set
  101684. */
  101685. setColor(color: Color3): void;
  101686. /**
  101687. * Creates an BoundingBoxGizmo
  101688. * @param gizmoLayer The utility layer the gizmo will be added to
  101689. * @param color The color of the gizmo
  101690. */
  101691. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  101692. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  101693. private _selectNode;
  101694. /**
  101695. * Updates the bounding box information for the Gizmo
  101696. */
  101697. updateBoundingBox(): void;
  101698. private _updateRotationSpheres;
  101699. private _updateScaleBoxes;
  101700. /**
  101701. * Enables rotation on the specified axis and disables rotation on the others
  101702. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  101703. */
  101704. setEnabledRotationAxis(axis: string): void;
  101705. /**
  101706. * Enables/disables scaling
  101707. * @param enable if scaling should be enabled
  101708. */
  101709. setEnabledScaling(enable: boolean): void;
  101710. private _updateDummy;
  101711. /**
  101712. * Enables a pointer drag behavior on the bounding box of the gizmo
  101713. */
  101714. enableDragBehavior(): void;
  101715. /**
  101716. * Disposes of the gizmo
  101717. */
  101718. dispose(): void;
  101719. /**
  101720. * 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)
  101721. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  101722. * @returns the bounding box mesh with the passed in mesh as a child
  101723. */
  101724. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  101725. /**
  101726. * CustomMeshes are not supported by this gizmo
  101727. * @param mesh The mesh to replace the default mesh of the gizmo
  101728. */
  101729. setCustomMesh(mesh: Mesh): void;
  101730. }
  101731. }
  101732. declare module BABYLON {
  101733. /**
  101734. * Single plane rotation gizmo
  101735. */
  101736. export class PlaneRotationGizmo extends Gizmo {
  101737. /**
  101738. * Drag behavior responsible for the gizmos dragging interactions
  101739. */
  101740. dragBehavior: PointerDragBehavior;
  101741. private _pointerObserver;
  101742. /**
  101743. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  101744. */
  101745. snapDistance: number;
  101746. /**
  101747. * Event that fires each time the gizmo snaps to a new location.
  101748. * * snapDistance is the the change in distance
  101749. */
  101750. onSnapObservable: Observable<{
  101751. snapDistance: number;
  101752. }>;
  101753. /**
  101754. * Creates a PlaneRotationGizmo
  101755. * @param gizmoLayer The utility layer the gizmo will be added to
  101756. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  101757. * @param color The color of the gizmo
  101758. * @param tessellation Amount of tessellation to be used when creating rotation circles
  101759. */
  101760. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  101761. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  101762. /**
  101763. * Disposes of the gizmo
  101764. */
  101765. dispose(): void;
  101766. }
  101767. }
  101768. declare module BABYLON {
  101769. /**
  101770. * Gizmo that enables rotating a mesh along 3 axis
  101771. */
  101772. export class RotationGizmo extends Gizmo {
  101773. /**
  101774. * Internal gizmo used for interactions on the x axis
  101775. */
  101776. xGizmo: PlaneRotationGizmo;
  101777. /**
  101778. * Internal gizmo used for interactions on the y axis
  101779. */
  101780. yGizmo: PlaneRotationGizmo;
  101781. /**
  101782. * Internal gizmo used for interactions on the z axis
  101783. */
  101784. zGizmo: PlaneRotationGizmo;
  101785. /** Fires an event when any of it's sub gizmos are dragged */
  101786. onDragStartObservable: Observable<{}>;
  101787. /** Fires an event when any of it's sub gizmos are released from dragging */
  101788. onDragEndObservable: Observable<{}>;
  101789. attachedMesh: Nullable<AbstractMesh>;
  101790. /**
  101791. * Creates a RotationGizmo
  101792. * @param gizmoLayer The utility layer the gizmo will be added to
  101793. * @param tessellation Amount of tessellation to be used when creating rotation circles
  101794. */
  101795. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  101796. updateGizmoRotationToMatchAttachedMesh: boolean;
  101797. /**
  101798. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  101799. */
  101800. snapDistance: number;
  101801. /**
  101802. * Ratio for the scale of the gizmo (Default: 1)
  101803. */
  101804. scaleRatio: number;
  101805. /**
  101806. * Disposes of the gizmo
  101807. */
  101808. dispose(): void;
  101809. /**
  101810. * CustomMeshes are not supported by this gizmo
  101811. * @param mesh The mesh to replace the default mesh of the gizmo
  101812. */
  101813. setCustomMesh(mesh: Mesh): void;
  101814. }
  101815. }
  101816. declare module BABYLON {
  101817. /**
  101818. * Gizmo that enables dragging a mesh along 3 axis
  101819. */
  101820. export class PositionGizmo extends Gizmo {
  101821. /**
  101822. * Internal gizmo used for interactions on the x axis
  101823. */
  101824. xGizmo: AxisDragGizmo;
  101825. /**
  101826. * Internal gizmo used for interactions on the y axis
  101827. */
  101828. yGizmo: AxisDragGizmo;
  101829. /**
  101830. * Internal gizmo used for interactions on the z axis
  101831. */
  101832. zGizmo: AxisDragGizmo;
  101833. /** Fires an event when any of it's sub gizmos are dragged */
  101834. onDragStartObservable: Observable<{}>;
  101835. /** Fires an event when any of it's sub gizmos are released from dragging */
  101836. onDragEndObservable: Observable<{}>;
  101837. attachedMesh: Nullable<AbstractMesh>;
  101838. /**
  101839. * Creates a PositionGizmo
  101840. * @param gizmoLayer The utility layer the gizmo will be added to
  101841. */
  101842. constructor(gizmoLayer?: UtilityLayerRenderer);
  101843. updateGizmoRotationToMatchAttachedMesh: boolean;
  101844. /**
  101845. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  101846. */
  101847. snapDistance: number;
  101848. /**
  101849. * Ratio for the scale of the gizmo (Default: 1)
  101850. */
  101851. scaleRatio: number;
  101852. /**
  101853. * Disposes of the gizmo
  101854. */
  101855. dispose(): void;
  101856. /**
  101857. * CustomMeshes are not supported by this gizmo
  101858. * @param mesh The mesh to replace the default mesh of the gizmo
  101859. */
  101860. setCustomMesh(mesh: Mesh): void;
  101861. }
  101862. }
  101863. declare module BABYLON {
  101864. /**
  101865. * Class containing static functions to help procedurally build meshes
  101866. */
  101867. export class PolyhedronBuilder {
  101868. /**
  101869. * Creates a polyhedron mesh
  101870. * * 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
  101871. * * The parameter `size` (positive float, default 1) sets the polygon size
  101872. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  101873. * * 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`
  101874. * * 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
  101875. * * 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)`)
  101876. * * 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
  101877. * * 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
  101878. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  101879. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  101880. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101881. * @param name defines the name of the mesh
  101882. * @param options defines the options used to create the mesh
  101883. * @param scene defines the hosting scene
  101884. * @returns the polyhedron mesh
  101885. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  101886. */
  101887. static CreatePolyhedron(name: string, options: {
  101888. type?: number;
  101889. size?: number;
  101890. sizeX?: number;
  101891. sizeY?: number;
  101892. sizeZ?: number;
  101893. custom?: any;
  101894. faceUV?: Vector4[];
  101895. faceColors?: Color4[];
  101896. flat?: boolean;
  101897. updatable?: boolean;
  101898. sideOrientation?: number;
  101899. frontUVs?: Vector4;
  101900. backUVs?: Vector4;
  101901. }, scene?: Nullable<Scene>): Mesh;
  101902. }
  101903. }
  101904. declare module BABYLON {
  101905. /**
  101906. * Gizmo that enables scaling a mesh along 3 axis
  101907. */
  101908. export class ScaleGizmo extends Gizmo {
  101909. /**
  101910. * Internal gizmo used for interactions on the x axis
  101911. */
  101912. xGizmo: AxisScaleGizmo;
  101913. /**
  101914. * Internal gizmo used for interactions on the y axis
  101915. */
  101916. yGizmo: AxisScaleGizmo;
  101917. /**
  101918. * Internal gizmo used for interactions on the z axis
  101919. */
  101920. zGizmo: AxisScaleGizmo;
  101921. /**
  101922. * Internal gizmo used to scale all axis equally
  101923. */
  101924. uniformScaleGizmo: AxisScaleGizmo;
  101925. /** Fires an event when any of it's sub gizmos are dragged */
  101926. onDragStartObservable: Observable<{}>;
  101927. /** Fires an event when any of it's sub gizmos are released from dragging */
  101928. onDragEndObservable: Observable<{}>;
  101929. attachedMesh: Nullable<AbstractMesh>;
  101930. /**
  101931. * Creates a ScaleGizmo
  101932. * @param gizmoLayer The utility layer the gizmo will be added to
  101933. */
  101934. constructor(gizmoLayer?: UtilityLayerRenderer);
  101935. updateGizmoRotationToMatchAttachedMesh: boolean;
  101936. /**
  101937. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  101938. */
  101939. snapDistance: number;
  101940. /**
  101941. * Ratio for the scale of the gizmo (Default: 1)
  101942. */
  101943. scaleRatio: number;
  101944. /**
  101945. * Disposes of the gizmo
  101946. */
  101947. dispose(): void;
  101948. }
  101949. }
  101950. declare module BABYLON {
  101951. /**
  101952. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  101953. */
  101954. export class GizmoManager implements IDisposable {
  101955. private scene;
  101956. /**
  101957. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  101958. */
  101959. gizmos: {
  101960. positionGizmo: Nullable<PositionGizmo>;
  101961. rotationGizmo: Nullable<RotationGizmo>;
  101962. scaleGizmo: Nullable<ScaleGizmo>;
  101963. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  101964. };
  101965. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  101966. clearGizmoOnEmptyPointerEvent: boolean;
  101967. /** Fires an event when the manager is attached to a mesh */
  101968. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  101969. private _gizmosEnabled;
  101970. private _pointerObserver;
  101971. private _attachedMesh;
  101972. private _boundingBoxColor;
  101973. private _defaultUtilityLayer;
  101974. private _defaultKeepDepthUtilityLayer;
  101975. /**
  101976. * When bounding box gizmo is enabled, this can be used to track drag/end events
  101977. */
  101978. boundingBoxDragBehavior: SixDofDragBehavior;
  101979. /**
  101980. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  101981. */
  101982. attachableMeshes: Nullable<Array<AbstractMesh>>;
  101983. /**
  101984. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  101985. */
  101986. usePointerToAttachGizmos: boolean;
  101987. /**
  101988. * Instatiates a gizmo manager
  101989. * @param scene the scene to overlay the gizmos on top of
  101990. */
  101991. constructor(scene: Scene);
  101992. /**
  101993. * Attaches a set of gizmos to the specified mesh
  101994. * @param mesh The mesh the gizmo's should be attached to
  101995. */
  101996. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  101997. /**
  101998. * If the position gizmo is enabled
  101999. */
  102000. positionGizmoEnabled: boolean;
  102001. /**
  102002. * If the rotation gizmo is enabled
  102003. */
  102004. rotationGizmoEnabled: boolean;
  102005. /**
  102006. * If the scale gizmo is enabled
  102007. */
  102008. scaleGizmoEnabled: boolean;
  102009. /**
  102010. * If the boundingBox gizmo is enabled
  102011. */
  102012. boundingBoxGizmoEnabled: boolean;
  102013. /**
  102014. * Disposes of the gizmo manager
  102015. */
  102016. dispose(): void;
  102017. }
  102018. }
  102019. declare module BABYLON {
  102020. /**
  102021. * A directional light is defined by a direction (what a surprise!).
  102022. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  102023. * 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.
  102024. * Documentation: https://doc.babylonjs.com/babylon101/lights
  102025. */
  102026. export class DirectionalLight extends ShadowLight {
  102027. private _shadowFrustumSize;
  102028. /**
  102029. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  102030. */
  102031. /**
  102032. * Specifies a fix frustum size for the shadow generation.
  102033. */
  102034. shadowFrustumSize: number;
  102035. private _shadowOrthoScale;
  102036. /**
  102037. * Gets the shadow projection scale against the optimal computed one.
  102038. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  102039. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  102040. */
  102041. /**
  102042. * Sets the shadow projection scale against the optimal computed one.
  102043. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  102044. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  102045. */
  102046. shadowOrthoScale: number;
  102047. /**
  102048. * Automatically compute the projection matrix to best fit (including all the casters)
  102049. * on each frame.
  102050. */
  102051. autoUpdateExtends: boolean;
  102052. private _orthoLeft;
  102053. private _orthoRight;
  102054. private _orthoTop;
  102055. private _orthoBottom;
  102056. /**
  102057. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  102058. * The directional light is emitted from everywhere in the given direction.
  102059. * It can cast shadows.
  102060. * Documentation : https://doc.babylonjs.com/babylon101/lights
  102061. * @param name The friendly name of the light
  102062. * @param direction The direction of the light
  102063. * @param scene The scene the light belongs to
  102064. */
  102065. constructor(name: string, direction: Vector3, scene: Scene);
  102066. /**
  102067. * Returns the string "DirectionalLight".
  102068. * @return The class name
  102069. */
  102070. getClassName(): string;
  102071. /**
  102072. * Returns the integer 1.
  102073. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  102074. */
  102075. getTypeID(): number;
  102076. /**
  102077. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  102078. * Returns the DirectionalLight Shadow projection matrix.
  102079. */
  102080. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102081. /**
  102082. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  102083. * Returns the DirectionalLight Shadow projection matrix.
  102084. */
  102085. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  102086. /**
  102087. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  102088. * Returns the DirectionalLight Shadow projection matrix.
  102089. */
  102090. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102091. protected _buildUniformLayout(): void;
  102092. /**
  102093. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  102094. * @param effect The effect to update
  102095. * @param lightIndex The index of the light in the effect to update
  102096. * @returns The directional light
  102097. */
  102098. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  102099. /**
  102100. * Gets the minZ used for shadow according to both the scene and the light.
  102101. *
  102102. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  102103. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  102104. * @param activeCamera The camera we are returning the min for
  102105. * @returns the depth min z
  102106. */
  102107. getDepthMinZ(activeCamera: Camera): number;
  102108. /**
  102109. * Gets the maxZ used for shadow according to both the scene and the light.
  102110. *
  102111. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  102112. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  102113. * @param activeCamera The camera we are returning the max for
  102114. * @returns the depth max z
  102115. */
  102116. getDepthMaxZ(activeCamera: Camera): number;
  102117. /**
  102118. * Prepares the list of defines specific to the light type.
  102119. * @param defines the list of defines
  102120. * @param lightIndex defines the index of the light for the effect
  102121. */
  102122. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  102123. }
  102124. }
  102125. declare module BABYLON {
  102126. /**
  102127. * Class containing static functions to help procedurally build meshes
  102128. */
  102129. export class HemisphereBuilder {
  102130. /**
  102131. * Creates a hemisphere mesh
  102132. * @param name defines the name of the mesh
  102133. * @param options defines the options used to create the mesh
  102134. * @param scene defines the hosting scene
  102135. * @returns the hemisphere mesh
  102136. */
  102137. static CreateHemisphere(name: string, options: {
  102138. segments?: number;
  102139. diameter?: number;
  102140. sideOrientation?: number;
  102141. }, scene: any): Mesh;
  102142. }
  102143. }
  102144. declare module BABYLON {
  102145. /**
  102146. * A spot light is defined by a position, a direction, an angle, and an exponent.
  102147. * These values define a cone of light starting from the position, emitting toward the direction.
  102148. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  102149. * and the exponent defines the speed of the decay of the light with distance (reach).
  102150. * Documentation: https://doc.babylonjs.com/babylon101/lights
  102151. */
  102152. export class SpotLight extends ShadowLight {
  102153. private _angle;
  102154. private _innerAngle;
  102155. private _cosHalfAngle;
  102156. private _lightAngleScale;
  102157. private _lightAngleOffset;
  102158. /**
  102159. * Gets the cone angle of the spot light in Radians.
  102160. */
  102161. /**
  102162. * Sets the cone angle of the spot light in Radians.
  102163. */
  102164. angle: number;
  102165. /**
  102166. * Only used in gltf falloff mode, this defines the angle where
  102167. * the directional falloff will start before cutting at angle which could be seen
  102168. * as outer angle.
  102169. */
  102170. /**
  102171. * Only used in gltf falloff mode, this defines the angle where
  102172. * the directional falloff will start before cutting at angle which could be seen
  102173. * as outer angle.
  102174. */
  102175. innerAngle: number;
  102176. private _shadowAngleScale;
  102177. /**
  102178. * Allows scaling the angle of the light for shadow generation only.
  102179. */
  102180. /**
  102181. * Allows scaling the angle of the light for shadow generation only.
  102182. */
  102183. shadowAngleScale: number;
  102184. /**
  102185. * The light decay speed with the distance from the emission spot.
  102186. */
  102187. exponent: number;
  102188. private _projectionTextureMatrix;
  102189. /**
  102190. * Allows reading the projecton texture
  102191. */
  102192. readonly projectionTextureMatrix: Matrix;
  102193. protected _projectionTextureLightNear: number;
  102194. /**
  102195. * Gets the near clip of the Spotlight for texture projection.
  102196. */
  102197. /**
  102198. * Sets the near clip of the Spotlight for texture projection.
  102199. */
  102200. projectionTextureLightNear: number;
  102201. protected _projectionTextureLightFar: number;
  102202. /**
  102203. * Gets the far clip of the Spotlight for texture projection.
  102204. */
  102205. /**
  102206. * Sets the far clip of the Spotlight for texture projection.
  102207. */
  102208. projectionTextureLightFar: number;
  102209. protected _projectionTextureUpDirection: Vector3;
  102210. /**
  102211. * Gets the Up vector of the Spotlight for texture projection.
  102212. */
  102213. /**
  102214. * Sets the Up vector of the Spotlight for texture projection.
  102215. */
  102216. projectionTextureUpDirection: Vector3;
  102217. private _projectionTexture;
  102218. /**
  102219. * Gets the projection texture of the light.
  102220. */
  102221. /**
  102222. * Sets the projection texture of the light.
  102223. */
  102224. projectionTexture: Nullable<BaseTexture>;
  102225. private _projectionTextureViewLightDirty;
  102226. private _projectionTextureProjectionLightDirty;
  102227. private _projectionTextureDirty;
  102228. private _projectionTextureViewTargetVector;
  102229. private _projectionTextureViewLightMatrix;
  102230. private _projectionTextureProjectionLightMatrix;
  102231. private _projectionTextureScalingMatrix;
  102232. /**
  102233. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  102234. * It can cast shadows.
  102235. * Documentation : https://doc.babylonjs.com/babylon101/lights
  102236. * @param name The light friendly name
  102237. * @param position The position of the spot light in the scene
  102238. * @param direction The direction of the light in the scene
  102239. * @param angle The cone angle of the light in Radians
  102240. * @param exponent The light decay speed with the distance from the emission spot
  102241. * @param scene The scene the lights belongs to
  102242. */
  102243. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  102244. /**
  102245. * Returns the string "SpotLight".
  102246. * @returns the class name
  102247. */
  102248. getClassName(): string;
  102249. /**
  102250. * Returns the integer 2.
  102251. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  102252. */
  102253. getTypeID(): number;
  102254. /**
  102255. * Overrides the direction setter to recompute the projection texture view light Matrix.
  102256. */
  102257. protected _setDirection(value: Vector3): void;
  102258. /**
  102259. * Overrides the position setter to recompute the projection texture view light Matrix.
  102260. */
  102261. protected _setPosition(value: Vector3): void;
  102262. /**
  102263. * 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.
  102264. * Returns the SpotLight.
  102265. */
  102266. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102267. protected _computeProjectionTextureViewLightMatrix(): void;
  102268. protected _computeProjectionTextureProjectionLightMatrix(): void;
  102269. /**
  102270. * Main function for light texture projection matrix computing.
  102271. */
  102272. protected _computeProjectionTextureMatrix(): void;
  102273. protected _buildUniformLayout(): void;
  102274. private _computeAngleValues;
  102275. /**
  102276. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  102277. * @param effect The effect to update
  102278. * @param lightIndex The index of the light in the effect to update
  102279. * @returns The spot light
  102280. */
  102281. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  102282. /**
  102283. * Disposes the light and the associated resources.
  102284. */
  102285. dispose(): void;
  102286. /**
  102287. * Prepares the list of defines specific to the light type.
  102288. * @param defines the list of defines
  102289. * @param lightIndex defines the index of the light for the effect
  102290. */
  102291. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  102292. }
  102293. }
  102294. declare module BABYLON {
  102295. /**
  102296. * Gizmo that enables viewing a light
  102297. */
  102298. export class LightGizmo extends Gizmo {
  102299. private _lightMesh;
  102300. private _material;
  102301. /**
  102302. * Creates a LightGizmo
  102303. * @param gizmoLayer The utility layer the gizmo will be added to
  102304. */
  102305. constructor(gizmoLayer?: UtilityLayerRenderer);
  102306. private _light;
  102307. /**
  102308. * The light that the gizmo is attached to
  102309. */
  102310. light: Nullable<Light>;
  102311. /**
  102312. * @hidden
  102313. * Updates the gizmo to match the attached mesh's position/rotation
  102314. */
  102315. protected _update(): void;
  102316. private static _Scale;
  102317. /**
  102318. * Creates the lines for a light mesh
  102319. */
  102320. private static _createLightLines;
  102321. private static _CreateHemisphericLightMesh;
  102322. private static _CreatePointLightMesh;
  102323. private static _CreateSpotLightMesh;
  102324. private static _CreateDirectionalLightMesh;
  102325. }
  102326. }
  102327. declare module BABYLON {
  102328. /** @hidden */
  102329. export var backgroundFragmentDeclaration: {
  102330. name: string;
  102331. shader: string;
  102332. };
  102333. }
  102334. declare module BABYLON {
  102335. /** @hidden */
  102336. export var backgroundUboDeclaration: {
  102337. name: string;
  102338. shader: string;
  102339. };
  102340. }
  102341. declare module BABYLON {
  102342. /** @hidden */
  102343. export var backgroundPixelShader: {
  102344. name: string;
  102345. shader: string;
  102346. };
  102347. }
  102348. declare module BABYLON {
  102349. /** @hidden */
  102350. export var backgroundVertexDeclaration: {
  102351. name: string;
  102352. shader: string;
  102353. };
  102354. }
  102355. declare module BABYLON {
  102356. /** @hidden */
  102357. export var backgroundVertexShader: {
  102358. name: string;
  102359. shader: string;
  102360. };
  102361. }
  102362. declare module BABYLON {
  102363. /**
  102364. * Background material used to create an efficient environement around your scene.
  102365. */
  102366. export class BackgroundMaterial extends PushMaterial {
  102367. /**
  102368. * Standard reflectance value at parallel view angle.
  102369. */
  102370. static StandardReflectance0: number;
  102371. /**
  102372. * Standard reflectance value at grazing angle.
  102373. */
  102374. static StandardReflectance90: number;
  102375. protected _primaryColor: Color3;
  102376. /**
  102377. * Key light Color (multiply against the environement texture)
  102378. */
  102379. primaryColor: Color3;
  102380. protected __perceptualColor: Nullable<Color3>;
  102381. /**
  102382. * Experimental Internal Use Only.
  102383. *
  102384. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  102385. * This acts as a helper to set the primary color to a more "human friendly" value.
  102386. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  102387. * output color as close as possible from the chosen value.
  102388. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  102389. * part of lighting setup.)
  102390. */
  102391. _perceptualColor: Nullable<Color3>;
  102392. protected _primaryColorShadowLevel: float;
  102393. /**
  102394. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  102395. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  102396. */
  102397. primaryColorShadowLevel: float;
  102398. protected _primaryColorHighlightLevel: float;
  102399. /**
  102400. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  102401. * The primary color is used at the level chosen to define what the white area would look.
  102402. */
  102403. primaryColorHighlightLevel: float;
  102404. protected _reflectionTexture: Nullable<BaseTexture>;
  102405. /**
  102406. * Reflection Texture used in the material.
  102407. * Should be author in a specific way for the best result (refer to the documentation).
  102408. */
  102409. reflectionTexture: Nullable<BaseTexture>;
  102410. protected _reflectionBlur: float;
  102411. /**
  102412. * Reflection Texture level of blur.
  102413. *
  102414. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  102415. * texture twice.
  102416. */
  102417. reflectionBlur: float;
  102418. protected _diffuseTexture: Nullable<BaseTexture>;
  102419. /**
  102420. * Diffuse Texture used in the material.
  102421. * Should be author in a specific way for the best result (refer to the documentation).
  102422. */
  102423. diffuseTexture: Nullable<BaseTexture>;
  102424. protected _shadowLights: Nullable<IShadowLight[]>;
  102425. /**
  102426. * Specify the list of lights casting shadow on the material.
  102427. * All scene shadow lights will be included if null.
  102428. */
  102429. shadowLights: Nullable<IShadowLight[]>;
  102430. protected _shadowLevel: float;
  102431. /**
  102432. * Helps adjusting the shadow to a softer level if required.
  102433. * 0 means black shadows and 1 means no shadows.
  102434. */
  102435. shadowLevel: float;
  102436. protected _sceneCenter: Vector3;
  102437. /**
  102438. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  102439. * It is usually zero but might be interesting to modify according to your setup.
  102440. */
  102441. sceneCenter: Vector3;
  102442. protected _opacityFresnel: boolean;
  102443. /**
  102444. * This helps specifying that the material is falling off to the sky box at grazing angle.
  102445. * This helps ensuring a nice transition when the camera goes under the ground.
  102446. */
  102447. opacityFresnel: boolean;
  102448. protected _reflectionFresnel: boolean;
  102449. /**
  102450. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  102451. * This helps adding a mirror texture on the ground.
  102452. */
  102453. reflectionFresnel: boolean;
  102454. protected _reflectionFalloffDistance: number;
  102455. /**
  102456. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  102457. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  102458. */
  102459. reflectionFalloffDistance: number;
  102460. protected _reflectionAmount: number;
  102461. /**
  102462. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  102463. */
  102464. reflectionAmount: number;
  102465. protected _reflectionReflectance0: number;
  102466. /**
  102467. * This specifies the weight of the reflection at grazing angle.
  102468. */
  102469. reflectionReflectance0: number;
  102470. protected _reflectionReflectance90: number;
  102471. /**
  102472. * This specifies the weight of the reflection at a perpendicular point of view.
  102473. */
  102474. reflectionReflectance90: number;
  102475. /**
  102476. * Sets the reflection reflectance fresnel values according to the default standard
  102477. * empirically know to work well :-)
  102478. */
  102479. reflectionStandardFresnelWeight: number;
  102480. protected _useRGBColor: boolean;
  102481. /**
  102482. * Helps to directly use the maps channels instead of their level.
  102483. */
  102484. useRGBColor: boolean;
  102485. protected _enableNoise: boolean;
  102486. /**
  102487. * This helps reducing the banding effect that could occur on the background.
  102488. */
  102489. enableNoise: boolean;
  102490. /**
  102491. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  102492. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  102493. * Recommended to be keep at 1.0 except for special cases.
  102494. */
  102495. fovMultiplier: number;
  102496. private _fovMultiplier;
  102497. /**
  102498. * Enable the FOV adjustment feature controlled by fovMultiplier.
  102499. */
  102500. useEquirectangularFOV: boolean;
  102501. private _maxSimultaneousLights;
  102502. /**
  102503. * Number of Simultaneous lights allowed on the material.
  102504. */
  102505. maxSimultaneousLights: int;
  102506. /**
  102507. * Default configuration related to image processing available in the Background Material.
  102508. */
  102509. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102510. /**
  102511. * Keep track of the image processing observer to allow dispose and replace.
  102512. */
  102513. private _imageProcessingObserver;
  102514. /**
  102515. * Attaches a new image processing configuration to the PBR Material.
  102516. * @param configuration (if null the scene configuration will be use)
  102517. */
  102518. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102519. /**
  102520. * Gets the image processing configuration used either in this material.
  102521. */
  102522. /**
  102523. * Sets the Default image processing configuration used either in the this material.
  102524. *
  102525. * If sets to null, the scene one is in use.
  102526. */
  102527. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  102528. /**
  102529. * Gets wether the color curves effect is enabled.
  102530. */
  102531. /**
  102532. * Sets wether the color curves effect is enabled.
  102533. */
  102534. cameraColorCurvesEnabled: boolean;
  102535. /**
  102536. * Gets wether the color grading effect is enabled.
  102537. */
  102538. /**
  102539. * Gets wether the color grading effect is enabled.
  102540. */
  102541. cameraColorGradingEnabled: boolean;
  102542. /**
  102543. * Gets wether tonemapping is enabled or not.
  102544. */
  102545. /**
  102546. * Sets wether tonemapping is enabled or not
  102547. */
  102548. cameraToneMappingEnabled: boolean;
  102549. /**
  102550. * The camera exposure used on this material.
  102551. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102552. * This corresponds to a photographic exposure.
  102553. */
  102554. /**
  102555. * The camera exposure used on this material.
  102556. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102557. * This corresponds to a photographic exposure.
  102558. */
  102559. cameraExposure: float;
  102560. /**
  102561. * Gets The camera contrast used on this material.
  102562. */
  102563. /**
  102564. * Sets The camera contrast used on this material.
  102565. */
  102566. cameraContrast: float;
  102567. /**
  102568. * Gets the Color Grading 2D Lookup Texture.
  102569. */
  102570. /**
  102571. * Sets the Color Grading 2D Lookup Texture.
  102572. */
  102573. cameraColorGradingTexture: Nullable<BaseTexture>;
  102574. /**
  102575. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102576. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102577. * 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;
  102578. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102579. */
  102580. /**
  102581. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102582. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102583. * 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;
  102584. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102585. */
  102586. cameraColorCurves: Nullable<ColorCurves>;
  102587. /**
  102588. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  102589. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  102590. */
  102591. switchToBGR: boolean;
  102592. private _renderTargets;
  102593. private _reflectionControls;
  102594. private _white;
  102595. private _primaryShadowColor;
  102596. private _primaryHighlightColor;
  102597. /**
  102598. * Instantiates a Background Material in the given scene
  102599. * @param name The friendly name of the material
  102600. * @param scene The scene to add the material to
  102601. */
  102602. constructor(name: string, scene: Scene);
  102603. /**
  102604. * Gets a boolean indicating that current material needs to register RTT
  102605. */
  102606. readonly hasRenderTargetTextures: boolean;
  102607. /**
  102608. * The entire material has been created in order to prevent overdraw.
  102609. * @returns false
  102610. */
  102611. needAlphaTesting(): boolean;
  102612. /**
  102613. * The entire material has been created in order to prevent overdraw.
  102614. * @returns true if blending is enable
  102615. */
  102616. needAlphaBlending(): boolean;
  102617. /**
  102618. * Checks wether the material is ready to be rendered for a given mesh.
  102619. * @param mesh The mesh to render
  102620. * @param subMesh The submesh to check against
  102621. * @param useInstances Specify wether or not the material is used with instances
  102622. * @returns true if all the dependencies are ready (Textures, Effects...)
  102623. */
  102624. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102625. /**
  102626. * Compute the primary color according to the chosen perceptual color.
  102627. */
  102628. private _computePrimaryColorFromPerceptualColor;
  102629. /**
  102630. * Compute the highlights and shadow colors according to their chosen levels.
  102631. */
  102632. private _computePrimaryColors;
  102633. /**
  102634. * Build the uniform buffer used in the material.
  102635. */
  102636. buildUniformLayout(): void;
  102637. /**
  102638. * Unbind the material.
  102639. */
  102640. unbind(): void;
  102641. /**
  102642. * Bind only the world matrix to the material.
  102643. * @param world The world matrix to bind.
  102644. */
  102645. bindOnlyWorldMatrix(world: Matrix): void;
  102646. /**
  102647. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  102648. * @param world The world matrix to bind.
  102649. * @param subMesh The submesh to bind for.
  102650. */
  102651. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102652. /**
  102653. * Dispose the material.
  102654. * @param forceDisposeEffect Force disposal of the associated effect.
  102655. * @param forceDisposeTextures Force disposal of the associated textures.
  102656. */
  102657. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  102658. /**
  102659. * Clones the material.
  102660. * @param name The cloned name.
  102661. * @returns The cloned material.
  102662. */
  102663. clone(name: string): BackgroundMaterial;
  102664. /**
  102665. * Serializes the current material to its JSON representation.
  102666. * @returns The JSON representation.
  102667. */
  102668. serialize(): any;
  102669. /**
  102670. * Gets the class name of the material
  102671. * @returns "BackgroundMaterial"
  102672. */
  102673. getClassName(): string;
  102674. /**
  102675. * Parse a JSON input to create back a background material.
  102676. * @param source The JSON data to parse
  102677. * @param scene The scene to create the parsed material in
  102678. * @param rootUrl The root url of the assets the material depends upon
  102679. * @returns the instantiated BackgroundMaterial.
  102680. */
  102681. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  102682. }
  102683. }
  102684. declare module BABYLON {
  102685. /**
  102686. * Represents the different options available during the creation of
  102687. * a Environment helper.
  102688. *
  102689. * This can control the default ground, skybox and image processing setup of your scene.
  102690. */
  102691. export interface IEnvironmentHelperOptions {
  102692. /**
  102693. * Specifies wether or not to create a ground.
  102694. * True by default.
  102695. */
  102696. createGround: boolean;
  102697. /**
  102698. * Specifies the ground size.
  102699. * 15 by default.
  102700. */
  102701. groundSize: number;
  102702. /**
  102703. * The texture used on the ground for the main color.
  102704. * Comes from the BabylonJS CDN by default.
  102705. *
  102706. * Remarks: Can be either a texture or a url.
  102707. */
  102708. groundTexture: string | BaseTexture;
  102709. /**
  102710. * The color mixed in the ground texture by default.
  102711. * BabylonJS clearColor by default.
  102712. */
  102713. groundColor: Color3;
  102714. /**
  102715. * Specifies the ground opacity.
  102716. * 1 by default.
  102717. */
  102718. groundOpacity: number;
  102719. /**
  102720. * Enables the ground to receive shadows.
  102721. * True by default.
  102722. */
  102723. enableGroundShadow: boolean;
  102724. /**
  102725. * Helps preventing the shadow to be fully black on the ground.
  102726. * 0.5 by default.
  102727. */
  102728. groundShadowLevel: number;
  102729. /**
  102730. * Creates a mirror texture attach to the ground.
  102731. * false by default.
  102732. */
  102733. enableGroundMirror: boolean;
  102734. /**
  102735. * Specifies the ground mirror size ratio.
  102736. * 0.3 by default as the default kernel is 64.
  102737. */
  102738. groundMirrorSizeRatio: number;
  102739. /**
  102740. * Specifies the ground mirror blur kernel size.
  102741. * 64 by default.
  102742. */
  102743. groundMirrorBlurKernel: number;
  102744. /**
  102745. * Specifies the ground mirror visibility amount.
  102746. * 1 by default
  102747. */
  102748. groundMirrorAmount: number;
  102749. /**
  102750. * Specifies the ground mirror reflectance weight.
  102751. * This uses the standard weight of the background material to setup the fresnel effect
  102752. * of the mirror.
  102753. * 1 by default.
  102754. */
  102755. groundMirrorFresnelWeight: number;
  102756. /**
  102757. * Specifies the ground mirror Falloff distance.
  102758. * This can helps reducing the size of the reflection.
  102759. * 0 by Default.
  102760. */
  102761. groundMirrorFallOffDistance: number;
  102762. /**
  102763. * Specifies the ground mirror texture type.
  102764. * Unsigned Int by Default.
  102765. */
  102766. groundMirrorTextureType: number;
  102767. /**
  102768. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  102769. * the shown objects.
  102770. */
  102771. groundYBias: number;
  102772. /**
  102773. * Specifies wether or not to create a skybox.
  102774. * True by default.
  102775. */
  102776. createSkybox: boolean;
  102777. /**
  102778. * Specifies the skybox size.
  102779. * 20 by default.
  102780. */
  102781. skyboxSize: number;
  102782. /**
  102783. * The texture used on the skybox for the main color.
  102784. * Comes from the BabylonJS CDN by default.
  102785. *
  102786. * Remarks: Can be either a texture or a url.
  102787. */
  102788. skyboxTexture: string | BaseTexture;
  102789. /**
  102790. * The color mixed in the skybox texture by default.
  102791. * BabylonJS clearColor by default.
  102792. */
  102793. skyboxColor: Color3;
  102794. /**
  102795. * The background rotation around the Y axis of the scene.
  102796. * This helps aligning the key lights of your scene with the background.
  102797. * 0 by default.
  102798. */
  102799. backgroundYRotation: number;
  102800. /**
  102801. * Compute automatically the size of the elements to best fit with the scene.
  102802. */
  102803. sizeAuto: boolean;
  102804. /**
  102805. * Default position of the rootMesh if autoSize is not true.
  102806. */
  102807. rootPosition: Vector3;
  102808. /**
  102809. * Sets up the image processing in the scene.
  102810. * true by default.
  102811. */
  102812. setupImageProcessing: boolean;
  102813. /**
  102814. * The texture used as your environment texture in the scene.
  102815. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  102816. *
  102817. * Remarks: Can be either a texture or a url.
  102818. */
  102819. environmentTexture: string | BaseTexture;
  102820. /**
  102821. * The value of the exposure to apply to the scene.
  102822. * 0.6 by default if setupImageProcessing is true.
  102823. */
  102824. cameraExposure: number;
  102825. /**
  102826. * The value of the contrast to apply to the scene.
  102827. * 1.6 by default if setupImageProcessing is true.
  102828. */
  102829. cameraContrast: number;
  102830. /**
  102831. * Specifies wether or not tonemapping should be enabled in the scene.
  102832. * true by default if setupImageProcessing is true.
  102833. */
  102834. toneMappingEnabled: boolean;
  102835. }
  102836. /**
  102837. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  102838. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  102839. * It also helps with the default setup of your imageProcessing configuration.
  102840. */
  102841. export class EnvironmentHelper {
  102842. /**
  102843. * Default ground texture URL.
  102844. */
  102845. private static _groundTextureCDNUrl;
  102846. /**
  102847. * Default skybox texture URL.
  102848. */
  102849. private static _skyboxTextureCDNUrl;
  102850. /**
  102851. * Default environment texture URL.
  102852. */
  102853. private static _environmentTextureCDNUrl;
  102854. /**
  102855. * Creates the default options for the helper.
  102856. */
  102857. private static _getDefaultOptions;
  102858. private _rootMesh;
  102859. /**
  102860. * Gets the root mesh created by the helper.
  102861. */
  102862. readonly rootMesh: Mesh;
  102863. private _skybox;
  102864. /**
  102865. * Gets the skybox created by the helper.
  102866. */
  102867. readonly skybox: Nullable<Mesh>;
  102868. private _skyboxTexture;
  102869. /**
  102870. * Gets the skybox texture created by the helper.
  102871. */
  102872. readonly skyboxTexture: Nullable<BaseTexture>;
  102873. private _skyboxMaterial;
  102874. /**
  102875. * Gets the skybox material created by the helper.
  102876. */
  102877. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  102878. private _ground;
  102879. /**
  102880. * Gets the ground mesh created by the helper.
  102881. */
  102882. readonly ground: Nullable<Mesh>;
  102883. private _groundTexture;
  102884. /**
  102885. * Gets the ground texture created by the helper.
  102886. */
  102887. readonly groundTexture: Nullable<BaseTexture>;
  102888. private _groundMirror;
  102889. /**
  102890. * Gets the ground mirror created by the helper.
  102891. */
  102892. readonly groundMirror: Nullable<MirrorTexture>;
  102893. /**
  102894. * Gets the ground mirror render list to helps pushing the meshes
  102895. * you wish in the ground reflection.
  102896. */
  102897. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  102898. private _groundMaterial;
  102899. /**
  102900. * Gets the ground material created by the helper.
  102901. */
  102902. readonly groundMaterial: Nullable<BackgroundMaterial>;
  102903. /**
  102904. * Stores the creation options.
  102905. */
  102906. private readonly _scene;
  102907. private _options;
  102908. /**
  102909. * This observable will be notified with any error during the creation of the environment,
  102910. * mainly texture creation errors.
  102911. */
  102912. onErrorObservable: Observable<{
  102913. message?: string;
  102914. exception?: any;
  102915. }>;
  102916. /**
  102917. * constructor
  102918. * @param options Defines the options we want to customize the helper
  102919. * @param scene The scene to add the material to
  102920. */
  102921. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  102922. /**
  102923. * Updates the background according to the new options
  102924. * @param options
  102925. */
  102926. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  102927. /**
  102928. * Sets the primary color of all the available elements.
  102929. * @param color the main color to affect to the ground and the background
  102930. */
  102931. setMainColor(color: Color3): void;
  102932. /**
  102933. * Setup the image processing according to the specified options.
  102934. */
  102935. private _setupImageProcessing;
  102936. /**
  102937. * Setup the environment texture according to the specified options.
  102938. */
  102939. private _setupEnvironmentTexture;
  102940. /**
  102941. * Setup the background according to the specified options.
  102942. */
  102943. private _setupBackground;
  102944. /**
  102945. * Get the scene sizes according to the setup.
  102946. */
  102947. private _getSceneSize;
  102948. /**
  102949. * Setup the ground according to the specified options.
  102950. */
  102951. private _setupGround;
  102952. /**
  102953. * Setup the ground material according to the specified options.
  102954. */
  102955. private _setupGroundMaterial;
  102956. /**
  102957. * Setup the ground diffuse texture according to the specified options.
  102958. */
  102959. private _setupGroundDiffuseTexture;
  102960. /**
  102961. * Setup the ground mirror texture according to the specified options.
  102962. */
  102963. private _setupGroundMirrorTexture;
  102964. /**
  102965. * Setup the ground to receive the mirror texture.
  102966. */
  102967. private _setupMirrorInGroundMaterial;
  102968. /**
  102969. * Setup the skybox according to the specified options.
  102970. */
  102971. private _setupSkybox;
  102972. /**
  102973. * Setup the skybox material according to the specified options.
  102974. */
  102975. private _setupSkyboxMaterial;
  102976. /**
  102977. * Setup the skybox reflection texture according to the specified options.
  102978. */
  102979. private _setupSkyboxReflectionTexture;
  102980. private _errorHandler;
  102981. /**
  102982. * Dispose all the elements created by the Helper.
  102983. */
  102984. dispose(): void;
  102985. }
  102986. }
  102987. declare module BABYLON {
  102988. /**
  102989. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  102990. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  102991. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  102992. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  102993. */
  102994. export class PhotoDome extends TransformNode {
  102995. private _useDirectMapping;
  102996. /**
  102997. * The texture being displayed on the sphere
  102998. */
  102999. protected _photoTexture: Texture;
  103000. /**
  103001. * Gets or sets the texture being displayed on the sphere
  103002. */
  103003. photoTexture: Texture;
  103004. /**
  103005. * Observable raised when an error occured while loading the 360 image
  103006. */
  103007. onLoadErrorObservable: Observable<string>;
  103008. /**
  103009. * The skybox material
  103010. */
  103011. protected _material: BackgroundMaterial;
  103012. /**
  103013. * The surface used for the skybox
  103014. */
  103015. protected _mesh: Mesh;
  103016. /**
  103017. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  103018. * Also see the options.resolution property.
  103019. */
  103020. fovMultiplier: number;
  103021. /**
  103022. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  103023. * @param name Element's name, child elements will append suffixes for their own names.
  103024. * @param urlsOfPhoto defines the url of the photo to display
  103025. * @param options defines an object containing optional or exposed sub element properties
  103026. * @param onError defines a callback called when an error occured while loading the texture
  103027. */
  103028. constructor(name: string, urlOfPhoto: string, options: {
  103029. resolution?: number;
  103030. size?: number;
  103031. useDirectMapping?: boolean;
  103032. faceForward?: boolean;
  103033. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  103034. /**
  103035. * Releases resources associated with this node.
  103036. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  103037. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  103038. */
  103039. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  103040. }
  103041. }
  103042. declare module BABYLON {
  103043. /** @hidden */
  103044. export var rgbdDecodePixelShader: {
  103045. name: string;
  103046. shader: string;
  103047. };
  103048. }
  103049. declare module BABYLON {
  103050. /**
  103051. * Class used to host texture specific utilities
  103052. */
  103053. export class BRDFTextureTools {
  103054. /**
  103055. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  103056. * @param texture the texture to expand.
  103057. */
  103058. private static _ExpandDefaultBRDFTexture;
  103059. /**
  103060. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  103061. * @param scene defines the hosting scene
  103062. * @returns the environment BRDF texture
  103063. */
  103064. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  103065. private static _environmentBRDFBase64Texture;
  103066. }
  103067. }
  103068. declare module BABYLON {
  103069. /**
  103070. * @hidden
  103071. */
  103072. export interface IMaterialClearCoatDefines {
  103073. CLEARCOAT: boolean;
  103074. CLEARCOAT_DEFAULTIOR: boolean;
  103075. CLEARCOAT_TEXTURE: boolean;
  103076. CLEARCOAT_TEXTUREDIRECTUV: number;
  103077. CLEARCOAT_BUMP: boolean;
  103078. CLEARCOAT_BUMPDIRECTUV: number;
  103079. CLEARCOAT_TINT: boolean;
  103080. CLEARCOAT_TINT_TEXTURE: boolean;
  103081. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  103082. /** @hidden */
  103083. _areTexturesDirty: boolean;
  103084. }
  103085. /**
  103086. * Define the code related to the clear coat parameters of the pbr material.
  103087. */
  103088. export class PBRClearCoatConfiguration {
  103089. /**
  103090. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  103091. * The default fits with a polyurethane material.
  103092. */
  103093. private static readonly _DefaultIndiceOfRefraction;
  103094. private _isEnabled;
  103095. /**
  103096. * Defines if the clear coat is enabled in the material.
  103097. */
  103098. isEnabled: boolean;
  103099. /**
  103100. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  103101. */
  103102. intensity: number;
  103103. /**
  103104. * Defines the clear coat layer roughness.
  103105. */
  103106. roughness: number;
  103107. private _indiceOfRefraction;
  103108. /**
  103109. * Defines the indice of refraction of the clear coat.
  103110. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  103111. * The default fits with a polyurethane material.
  103112. * Changing the default value is more performance intensive.
  103113. */
  103114. indiceOfRefraction: number;
  103115. private _texture;
  103116. /**
  103117. * Stores the clear coat values in a texture.
  103118. */
  103119. texture: Nullable<BaseTexture>;
  103120. private _bumpTexture;
  103121. /**
  103122. * Define the clear coat specific bump texture.
  103123. */
  103124. bumpTexture: Nullable<BaseTexture>;
  103125. private _isTintEnabled;
  103126. /**
  103127. * Defines if the clear coat tint is enabled in the material.
  103128. */
  103129. isTintEnabled: boolean;
  103130. /**
  103131. * Defines the clear coat tint of the material.
  103132. * This is only use if tint is enabled
  103133. */
  103134. tintColor: Color3;
  103135. /**
  103136. * Defines the distance at which the tint color should be found in the
  103137. * clear coat media.
  103138. * This is only use if tint is enabled
  103139. */
  103140. tintColorAtDistance: number;
  103141. /**
  103142. * Defines the clear coat layer thickness.
  103143. * This is only use if tint is enabled
  103144. */
  103145. tintThickness: number;
  103146. private _tintTexture;
  103147. /**
  103148. * Stores the clear tint values in a texture.
  103149. * rgb is tint
  103150. * a is a thickness factor
  103151. */
  103152. tintTexture: Nullable<BaseTexture>;
  103153. /** @hidden */
  103154. private _internalMarkAllSubMeshesAsTexturesDirty;
  103155. /** @hidden */
  103156. _markAllSubMeshesAsTexturesDirty(): void;
  103157. /**
  103158. * Instantiate a new istance of clear coat configuration.
  103159. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  103160. */
  103161. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  103162. /**
  103163. * Gets wehter the submesh is ready to be used or not.
  103164. * @param defines the list of "defines" to update.
  103165. * @param scene defines the scene the material belongs to.
  103166. * @param engine defines the engine the material belongs to.
  103167. * @param disableBumpMap defines wether the material disables bump or not.
  103168. * @returns - boolean indicating that the submesh is ready or not.
  103169. */
  103170. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  103171. /**
  103172. * Checks to see if a texture is used in the material.
  103173. * @param defines the list of "defines" to update.
  103174. * @param scene defines the scene to the material belongs to.
  103175. */
  103176. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  103177. /**
  103178. * Binds the material data.
  103179. * @param uniformBuffer defines the Uniform buffer to fill in.
  103180. * @param scene defines the scene the material belongs to.
  103181. * @param engine defines the engine the material belongs to.
  103182. * @param disableBumpMap defines wether the material disables bump or not.
  103183. * @param isFrozen defines wether the material is frozen or not.
  103184. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  103185. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  103186. */
  103187. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  103188. /**
  103189. * Checks to see if a texture is used in the material.
  103190. * @param texture - Base texture to use.
  103191. * @returns - Boolean specifying if a texture is used in the material.
  103192. */
  103193. hasTexture(texture: BaseTexture): boolean;
  103194. /**
  103195. * Returns an array of the actively used textures.
  103196. * @param activeTextures Array of BaseTextures
  103197. */
  103198. getActiveTextures(activeTextures: BaseTexture[]): void;
  103199. /**
  103200. * Returns the animatable textures.
  103201. * @param animatables Array of animatable textures.
  103202. */
  103203. getAnimatables(animatables: IAnimatable[]): void;
  103204. /**
  103205. * Disposes the resources of the material.
  103206. * @param forceDisposeTextures - Forces the disposal of all textures.
  103207. */
  103208. dispose(forceDisposeTextures?: boolean): void;
  103209. /**
  103210. * Get the current class name of the texture useful for serialization or dynamic coding.
  103211. * @returns "PBRClearCoatConfiguration"
  103212. */
  103213. getClassName(): string;
  103214. /**
  103215. * Add fallbacks to the effect fallbacks list.
  103216. * @param defines defines the Base texture to use.
  103217. * @param fallbacks defines the current fallback list.
  103218. * @param currentRank defines the current fallback rank.
  103219. * @returns the new fallback rank.
  103220. */
  103221. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  103222. /**
  103223. * Add the required uniforms to the current list.
  103224. * @param uniforms defines the current uniform list.
  103225. */
  103226. static AddUniforms(uniforms: string[]): void;
  103227. /**
  103228. * Add the required samplers to the current list.
  103229. * @param samplers defines the current sampler list.
  103230. */
  103231. static AddSamplers(samplers: string[]): void;
  103232. /**
  103233. * Add the required uniforms to the current buffer.
  103234. * @param uniformBuffer defines the current uniform buffer.
  103235. */
  103236. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  103237. /**
  103238. * Makes a duplicate of the current configuration into another one.
  103239. * @param clearCoatConfiguration define the config where to copy the info
  103240. */
  103241. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  103242. /**
  103243. * Serializes this clear coat configuration.
  103244. * @returns - An object with the serialized config.
  103245. */
  103246. serialize(): any;
  103247. /**
  103248. * Parses a Clear Coat Configuration from a serialized object.
  103249. * @param source - Serialized object.
  103250. */
  103251. parse(source: any): void;
  103252. }
  103253. }
  103254. declare module BABYLON {
  103255. /**
  103256. * @hidden
  103257. */
  103258. export interface IMaterialAnisotropicDefines {
  103259. ANISOTROPIC: boolean;
  103260. ANISOTROPIC_TEXTURE: boolean;
  103261. ANISOTROPIC_TEXTUREDIRECTUV: number;
  103262. MAINUV1: boolean;
  103263. _areTexturesDirty: boolean;
  103264. _needUVs: boolean;
  103265. }
  103266. /**
  103267. * Define the code related to the anisotropic parameters of the pbr material.
  103268. */
  103269. export class PBRAnisotropicConfiguration {
  103270. private _isEnabled;
  103271. /**
  103272. * Defines if the anisotropy is enabled in the material.
  103273. */
  103274. isEnabled: boolean;
  103275. /**
  103276. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  103277. */
  103278. intensity: number;
  103279. /**
  103280. * Defines if the effect is along the tangents, bitangents or in between.
  103281. * By default, the effect is "strectching" the highlights along the tangents.
  103282. */
  103283. direction: Vector2;
  103284. private _texture;
  103285. /**
  103286. * Stores the anisotropy values in a texture.
  103287. * rg is direction (like normal from -1 to 1)
  103288. * b is a intensity
  103289. */
  103290. texture: Nullable<BaseTexture>;
  103291. /** @hidden */
  103292. private _internalMarkAllSubMeshesAsTexturesDirty;
  103293. /** @hidden */
  103294. _markAllSubMeshesAsTexturesDirty(): void;
  103295. /**
  103296. * Instantiate a new istance of anisotropy configuration.
  103297. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  103298. */
  103299. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  103300. /**
  103301. * Specifies that the submesh is ready to be used.
  103302. * @param defines the list of "defines" to update.
  103303. * @param scene defines the scene the material belongs to.
  103304. * @returns - boolean indicating that the submesh is ready or not.
  103305. */
  103306. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  103307. /**
  103308. * Checks to see if a texture is used in the material.
  103309. * @param defines the list of "defines" to update.
  103310. * @param mesh the mesh we are preparing the defines for.
  103311. * @param scene defines the scene the material belongs to.
  103312. */
  103313. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  103314. /**
  103315. * Binds the material data.
  103316. * @param uniformBuffer defines the Uniform buffer to fill in.
  103317. * @param scene defines the scene the material belongs to.
  103318. * @param isFrozen defines wether the material is frozen or not.
  103319. */
  103320. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  103321. /**
  103322. * Checks to see if a texture is used in the material.
  103323. * @param texture - Base texture to use.
  103324. * @returns - Boolean specifying if a texture is used in the material.
  103325. */
  103326. hasTexture(texture: BaseTexture): boolean;
  103327. /**
  103328. * Returns an array of the actively used textures.
  103329. * @param activeTextures Array of BaseTextures
  103330. */
  103331. getActiveTextures(activeTextures: BaseTexture[]): void;
  103332. /**
  103333. * Returns the animatable textures.
  103334. * @param animatables Array of animatable textures.
  103335. */
  103336. getAnimatables(animatables: IAnimatable[]): void;
  103337. /**
  103338. * Disposes the resources of the material.
  103339. * @param forceDisposeTextures - Forces the disposal of all textures.
  103340. */
  103341. dispose(forceDisposeTextures?: boolean): void;
  103342. /**
  103343. * Get the current class name of the texture useful for serialization or dynamic coding.
  103344. * @returns "PBRAnisotropicConfiguration"
  103345. */
  103346. getClassName(): string;
  103347. /**
  103348. * Add fallbacks to the effect fallbacks list.
  103349. * @param defines defines the Base texture to use.
  103350. * @param fallbacks defines the current fallback list.
  103351. * @param currentRank defines the current fallback rank.
  103352. * @returns the new fallback rank.
  103353. */
  103354. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  103355. /**
  103356. * Add the required uniforms to the current list.
  103357. * @param uniforms defines the current uniform list.
  103358. */
  103359. static AddUniforms(uniforms: string[]): void;
  103360. /**
  103361. * Add the required uniforms to the current buffer.
  103362. * @param uniformBuffer defines the current uniform buffer.
  103363. */
  103364. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  103365. /**
  103366. * Add the required samplers to the current list.
  103367. * @param samplers defines the current sampler list.
  103368. */
  103369. static AddSamplers(samplers: string[]): void;
  103370. /**
  103371. * Makes a duplicate of the current configuration into another one.
  103372. * @param anisotropicConfiguration define the config where to copy the info
  103373. */
  103374. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  103375. /**
  103376. * Serializes this anisotropy configuration.
  103377. * @returns - An object with the serialized config.
  103378. */
  103379. serialize(): any;
  103380. /**
  103381. * Parses a anisotropy Configuration from a serialized object.
  103382. * @param source - Serialized object.
  103383. */
  103384. parse(source: any): void;
  103385. }
  103386. }
  103387. declare module BABYLON {
  103388. /**
  103389. * @hidden
  103390. */
  103391. export interface IMaterialBRDFDefines {
  103392. BRDF_V_HEIGHT_CORRELATED: boolean;
  103393. MS_BRDF_ENERGY_CONSERVATION: boolean;
  103394. /** @hidden */
  103395. _areMiscDirty: boolean;
  103396. }
  103397. /**
  103398. * Define the code related to the BRDF parameters of the pbr material.
  103399. */
  103400. export class PBRBRDFConfiguration {
  103401. /**
  103402. * Default value used for the energy conservation.
  103403. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  103404. */
  103405. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  103406. /**
  103407. * Default value used for the Smith Visibility Height Correlated mode.
  103408. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  103409. */
  103410. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  103411. private _useEnergyConservation;
  103412. /**
  103413. * Defines if the material uses energy conservation.
  103414. */
  103415. useEnergyConservation: boolean;
  103416. private _useSmithVisibilityHeightCorrelated;
  103417. /**
  103418. * LEGACY Mode set to false
  103419. * Defines if the material uses height smith correlated visibility term.
  103420. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  103421. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  103422. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  103423. * Not relying on height correlated will also disable energy conservation.
  103424. */
  103425. useSmithVisibilityHeightCorrelated: boolean;
  103426. /** @hidden */
  103427. private _internalMarkAllSubMeshesAsMiscDirty;
  103428. /** @hidden */
  103429. _markAllSubMeshesAsMiscDirty(): void;
  103430. /**
  103431. * Instantiate a new istance of clear coat configuration.
  103432. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  103433. */
  103434. constructor(markAllSubMeshesAsMiscDirty: () => void);
  103435. /**
  103436. * Checks to see if a texture is used in the material.
  103437. * @param defines the list of "defines" to update.
  103438. */
  103439. prepareDefines(defines: IMaterialBRDFDefines): void;
  103440. /**
  103441. * Get the current class name of the texture useful for serialization or dynamic coding.
  103442. * @returns "PBRClearCoatConfiguration"
  103443. */
  103444. getClassName(): string;
  103445. /**
  103446. * Makes a duplicate of the current configuration into another one.
  103447. * @param brdfConfiguration define the config where to copy the info
  103448. */
  103449. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  103450. /**
  103451. * Serializes this BRDF configuration.
  103452. * @returns - An object with the serialized config.
  103453. */
  103454. serialize(): any;
  103455. /**
  103456. * Parses a BRDF Configuration from a serialized object.
  103457. * @param source - Serialized object.
  103458. */
  103459. parse(source: any): void;
  103460. }
  103461. }
  103462. declare module BABYLON {
  103463. /**
  103464. * @hidden
  103465. */
  103466. export interface IMaterialSheenDefines {
  103467. SHEEN: boolean;
  103468. SHEEN_TEXTURE: boolean;
  103469. SHEEN_TEXTUREDIRECTUV: number;
  103470. SHEEN_LINKWITHALBEDO: boolean;
  103471. /** @hidden */
  103472. _areTexturesDirty: boolean;
  103473. }
  103474. /**
  103475. * Define the code related to the Sheen parameters of the pbr material.
  103476. */
  103477. export class PBRSheenConfiguration {
  103478. private _isEnabled;
  103479. /**
  103480. * Defines if the material uses sheen.
  103481. */
  103482. isEnabled: boolean;
  103483. private _linkSheenWithAlbedo;
  103484. /**
  103485. * Defines if the sheen is linked to the sheen color.
  103486. */
  103487. linkSheenWithAlbedo: boolean;
  103488. /**
  103489. * Defines the sheen intensity.
  103490. */
  103491. intensity: number;
  103492. /**
  103493. * Defines the sheen color.
  103494. */
  103495. color: Color3;
  103496. private _texture;
  103497. /**
  103498. * Stores the sheen tint values in a texture.
  103499. * rgb is tint
  103500. * a is a intensity
  103501. */
  103502. texture: Nullable<BaseTexture>;
  103503. /** @hidden */
  103504. private _internalMarkAllSubMeshesAsTexturesDirty;
  103505. /** @hidden */
  103506. _markAllSubMeshesAsTexturesDirty(): void;
  103507. /**
  103508. * Instantiate a new istance of clear coat configuration.
  103509. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  103510. */
  103511. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  103512. /**
  103513. * Specifies that the submesh is ready to be used.
  103514. * @param defines the list of "defines" to update.
  103515. * @param scene defines the scene the material belongs to.
  103516. * @returns - boolean indicating that the submesh is ready or not.
  103517. */
  103518. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  103519. /**
  103520. * Checks to see if a texture is used in the material.
  103521. * @param defines the list of "defines" to update.
  103522. * @param scene defines the scene the material belongs to.
  103523. */
  103524. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  103525. /**
  103526. * Binds the material data.
  103527. * @param uniformBuffer defines the Uniform buffer to fill in.
  103528. * @param scene defines the scene the material belongs to.
  103529. * @param isFrozen defines wether the material is frozen or not.
  103530. */
  103531. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  103532. /**
  103533. * Checks to see if a texture is used in the material.
  103534. * @param texture - Base texture to use.
  103535. * @returns - Boolean specifying if a texture is used in the material.
  103536. */
  103537. hasTexture(texture: BaseTexture): boolean;
  103538. /**
  103539. * Returns an array of the actively used textures.
  103540. * @param activeTextures Array of BaseTextures
  103541. */
  103542. getActiveTextures(activeTextures: BaseTexture[]): void;
  103543. /**
  103544. * Returns the animatable textures.
  103545. * @param animatables Array of animatable textures.
  103546. */
  103547. getAnimatables(animatables: IAnimatable[]): void;
  103548. /**
  103549. * Disposes the resources of the material.
  103550. * @param forceDisposeTextures - Forces the disposal of all textures.
  103551. */
  103552. dispose(forceDisposeTextures?: boolean): void;
  103553. /**
  103554. * Get the current class name of the texture useful for serialization or dynamic coding.
  103555. * @returns "PBRSheenConfiguration"
  103556. */
  103557. getClassName(): string;
  103558. /**
  103559. * Add fallbacks to the effect fallbacks list.
  103560. * @param defines defines the Base texture to use.
  103561. * @param fallbacks defines the current fallback list.
  103562. * @param currentRank defines the current fallback rank.
  103563. * @returns the new fallback rank.
  103564. */
  103565. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  103566. /**
  103567. * Add the required uniforms to the current list.
  103568. * @param uniforms defines the current uniform list.
  103569. */
  103570. static AddUniforms(uniforms: string[]): void;
  103571. /**
  103572. * Add the required uniforms to the current buffer.
  103573. * @param uniformBuffer defines the current uniform buffer.
  103574. */
  103575. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  103576. /**
  103577. * Add the required samplers to the current list.
  103578. * @param samplers defines the current sampler list.
  103579. */
  103580. static AddSamplers(samplers: string[]): void;
  103581. /**
  103582. * Makes a duplicate of the current configuration into another one.
  103583. * @param sheenConfiguration define the config where to copy the info
  103584. */
  103585. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  103586. /**
  103587. * Serializes this BRDF configuration.
  103588. * @returns - An object with the serialized config.
  103589. */
  103590. serialize(): any;
  103591. /**
  103592. * Parses a Sheen Configuration from a serialized object.
  103593. * @param source - Serialized object.
  103594. */
  103595. parse(source: any): void;
  103596. }
  103597. }
  103598. declare module BABYLON {
  103599. /**
  103600. * @hidden
  103601. */
  103602. export interface IMaterialSubSurfaceDefines {
  103603. SUBSURFACE: boolean;
  103604. SS_REFRACTION: boolean;
  103605. SS_TRANSLUCENCY: boolean;
  103606. SS_SCATERRING: boolean;
  103607. SS_THICKNESSANDMASK_TEXTURE: boolean;
  103608. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  103609. SS_REFRACTIONMAP_3D: boolean;
  103610. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  103611. SS_LODINREFRACTIONALPHA: boolean;
  103612. SS_GAMMAREFRACTION: boolean;
  103613. SS_RGBDREFRACTION: boolean;
  103614. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  103615. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  103616. /** @hidden */
  103617. _areTexturesDirty: boolean;
  103618. }
  103619. /**
  103620. * Define the code related to the sub surface parameters of the pbr material.
  103621. */
  103622. export class PBRSubSurfaceConfiguration {
  103623. private _isRefractionEnabled;
  103624. /**
  103625. * Defines if the refraction is enabled in the material.
  103626. */
  103627. isRefractionEnabled: boolean;
  103628. private _isTranslucencyEnabled;
  103629. /**
  103630. * Defines if the translucency is enabled in the material.
  103631. */
  103632. isTranslucencyEnabled: boolean;
  103633. private _isScatteringEnabled;
  103634. /**
  103635. * Defines the refraction intensity of the material.
  103636. * The refraction when enabled replaces the Diffuse part of the material.
  103637. * The intensity helps transitionning between diffuse and refraction.
  103638. */
  103639. refractionIntensity: number;
  103640. /**
  103641. * Defines the translucency intensity of the material.
  103642. * When translucency has been enabled, this defines how much of the "translucency"
  103643. * is addded to the diffuse part of the material.
  103644. */
  103645. translucencyIntensity: number;
  103646. /**
  103647. * Defines the scattering intensity of the material.
  103648. * When scattering has been enabled, this defines how much of the "scattered light"
  103649. * is addded to the diffuse part of the material.
  103650. */
  103651. scatteringIntensity: number;
  103652. private _thicknessTexture;
  103653. /**
  103654. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  103655. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  103656. * 0 would mean minimumThickness
  103657. * 1 would mean maximumThickness
  103658. * The other channels might be use as a mask to vary the different effects intensity.
  103659. */
  103660. thicknessTexture: Nullable<BaseTexture>;
  103661. private _refractionTexture;
  103662. /**
  103663. * Defines the texture to use for refraction.
  103664. */
  103665. refractionTexture: Nullable<BaseTexture>;
  103666. private _indexOfRefraction;
  103667. /**
  103668. * Defines the indice of refraction used in the material.
  103669. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  103670. */
  103671. indexOfRefraction: number;
  103672. private _invertRefractionY;
  103673. /**
  103674. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  103675. */
  103676. invertRefractionY: boolean;
  103677. private _linkRefractionWithTransparency;
  103678. /**
  103679. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  103680. * Materials half opaque for instance using refraction could benefit from this control.
  103681. */
  103682. linkRefractionWithTransparency: boolean;
  103683. /**
  103684. * Defines the minimum thickness stored in the thickness map.
  103685. * If no thickness map is defined, this value will be used to simulate thickness.
  103686. */
  103687. minimumThickness: number;
  103688. /**
  103689. * Defines the maximum thickness stored in the thickness map.
  103690. */
  103691. maximumThickness: number;
  103692. /**
  103693. * Defines the volume tint of the material.
  103694. * This is used for both translucency and scattering.
  103695. */
  103696. tintColor: Color3;
  103697. /**
  103698. * Defines the distance at which the tint color should be found in the media.
  103699. * This is used for refraction only.
  103700. */
  103701. tintColorAtDistance: number;
  103702. /**
  103703. * Defines how far each channel transmit through the media.
  103704. * It is defined as a color to simplify it selection.
  103705. */
  103706. diffusionDistance: Color3;
  103707. private _useMaskFromThicknessTexture;
  103708. /**
  103709. * Stores the intensity of the different subsurface effects in the thickness texture.
  103710. * * the green channel is the translucency intensity.
  103711. * * the blue channel is the scattering intensity.
  103712. * * the alpha channel is the refraction intensity.
  103713. */
  103714. useMaskFromThicknessTexture: boolean;
  103715. /** @hidden */
  103716. private _internalMarkAllSubMeshesAsTexturesDirty;
  103717. /** @hidden */
  103718. _markAllSubMeshesAsTexturesDirty(): void;
  103719. /**
  103720. * Instantiate a new istance of sub surface configuration.
  103721. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  103722. */
  103723. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  103724. /**
  103725. * Gets wehter the submesh is ready to be used or not.
  103726. * @param defines the list of "defines" to update.
  103727. * @param scene defines the scene the material belongs to.
  103728. * @returns - boolean indicating that the submesh is ready or not.
  103729. */
  103730. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  103731. /**
  103732. * Checks to see if a texture is used in the material.
  103733. * @param defines the list of "defines" to update.
  103734. * @param scene defines the scene to the material belongs to.
  103735. */
  103736. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  103737. /**
  103738. * Binds the material data.
  103739. * @param uniformBuffer defines the Uniform buffer to fill in.
  103740. * @param scene defines the scene the material belongs to.
  103741. * @param engine defines the engine the material belongs to.
  103742. * @param isFrozen defines wether the material is frozen or not.
  103743. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  103744. */
  103745. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  103746. /**
  103747. * Unbinds the material from the mesh.
  103748. * @param activeEffect defines the effect that should be unbound from.
  103749. * @returns true if unbound, otherwise false
  103750. */
  103751. unbind(activeEffect: Effect): boolean;
  103752. /**
  103753. * Returns the texture used for refraction or null if none is used.
  103754. * @param scene defines the scene the material belongs to.
  103755. * @returns - Refraction texture if present. If no refraction texture and refraction
  103756. * is linked with transparency, returns environment texture. Otherwise, returns null.
  103757. */
  103758. private _getRefractionTexture;
  103759. /**
  103760. * Returns true if alpha blending should be disabled.
  103761. */
  103762. readonly disableAlphaBlending: boolean;
  103763. /**
  103764. * Fills the list of render target textures.
  103765. * @param renderTargets the list of render targets to update
  103766. */
  103767. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  103768. /**
  103769. * Checks to see if a texture is used in the material.
  103770. * @param texture - Base texture to use.
  103771. * @returns - Boolean specifying if a texture is used in the material.
  103772. */
  103773. hasTexture(texture: BaseTexture): boolean;
  103774. /**
  103775. * Gets a boolean indicating that current material needs to register RTT
  103776. * @returns true if this uses a render target otherwise false.
  103777. */
  103778. hasRenderTargetTextures(): boolean;
  103779. /**
  103780. * Returns an array of the actively used textures.
  103781. * @param activeTextures Array of BaseTextures
  103782. */
  103783. getActiveTextures(activeTextures: BaseTexture[]): void;
  103784. /**
  103785. * Returns the animatable textures.
  103786. * @param animatables Array of animatable textures.
  103787. */
  103788. getAnimatables(animatables: IAnimatable[]): void;
  103789. /**
  103790. * Disposes the resources of the material.
  103791. * @param forceDisposeTextures - Forces the disposal of all textures.
  103792. */
  103793. dispose(forceDisposeTextures?: boolean): void;
  103794. /**
  103795. * Get the current class name of the texture useful for serialization or dynamic coding.
  103796. * @returns "PBRSubSurfaceConfiguration"
  103797. */
  103798. getClassName(): string;
  103799. /**
  103800. * Add fallbacks to the effect fallbacks list.
  103801. * @param defines defines the Base texture to use.
  103802. * @param fallbacks defines the current fallback list.
  103803. * @param currentRank defines the current fallback rank.
  103804. * @returns the new fallback rank.
  103805. */
  103806. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  103807. /**
  103808. * Add the required uniforms to the current list.
  103809. * @param uniforms defines the current uniform list.
  103810. */
  103811. static AddUniforms(uniforms: string[]): void;
  103812. /**
  103813. * Add the required samplers to the current list.
  103814. * @param samplers defines the current sampler list.
  103815. */
  103816. static AddSamplers(samplers: string[]): void;
  103817. /**
  103818. * Add the required uniforms to the current buffer.
  103819. * @param uniformBuffer defines the current uniform buffer.
  103820. */
  103821. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  103822. /**
  103823. * Makes a duplicate of the current configuration into another one.
  103824. * @param configuration define the config where to copy the info
  103825. */
  103826. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  103827. /**
  103828. * Serializes this Sub Surface configuration.
  103829. * @returns - An object with the serialized config.
  103830. */
  103831. serialize(): any;
  103832. /**
  103833. * Parses a Sub Surface Configuration from a serialized object.
  103834. * @param source - Serialized object.
  103835. */
  103836. parse(source: any): void;
  103837. }
  103838. }
  103839. declare module BABYLON {
  103840. /** @hidden */
  103841. export var pbrFragmentDeclaration: {
  103842. name: string;
  103843. shader: string;
  103844. };
  103845. }
  103846. declare module BABYLON {
  103847. /** @hidden */
  103848. export var pbrUboDeclaration: {
  103849. name: string;
  103850. shader: string;
  103851. };
  103852. }
  103853. declare module BABYLON {
  103854. /** @hidden */
  103855. export var pbrFragmentExtraDeclaration: {
  103856. name: string;
  103857. shader: string;
  103858. };
  103859. }
  103860. declare module BABYLON {
  103861. /** @hidden */
  103862. export var pbrFragmentSamplersDeclaration: {
  103863. name: string;
  103864. shader: string;
  103865. };
  103866. }
  103867. declare module BABYLON {
  103868. /** @hidden */
  103869. export var pbrHelperFunctions: {
  103870. name: string;
  103871. shader: string;
  103872. };
  103873. }
  103874. declare module BABYLON {
  103875. /** @hidden */
  103876. export var harmonicsFunctions: {
  103877. name: string;
  103878. shader: string;
  103879. };
  103880. }
  103881. declare module BABYLON {
  103882. /** @hidden */
  103883. export var pbrDirectLightingSetupFunctions: {
  103884. name: string;
  103885. shader: string;
  103886. };
  103887. }
  103888. declare module BABYLON {
  103889. /** @hidden */
  103890. export var pbrDirectLightingFalloffFunctions: {
  103891. name: string;
  103892. shader: string;
  103893. };
  103894. }
  103895. declare module BABYLON {
  103896. /** @hidden */
  103897. export var pbrBRDFFunctions: {
  103898. name: string;
  103899. shader: string;
  103900. };
  103901. }
  103902. declare module BABYLON {
  103903. /** @hidden */
  103904. export var pbrDirectLightingFunctions: {
  103905. name: string;
  103906. shader: string;
  103907. };
  103908. }
  103909. declare module BABYLON {
  103910. /** @hidden */
  103911. export var pbrIBLFunctions: {
  103912. name: string;
  103913. shader: string;
  103914. };
  103915. }
  103916. declare module BABYLON {
  103917. /** @hidden */
  103918. export var pbrDebug: {
  103919. name: string;
  103920. shader: string;
  103921. };
  103922. }
  103923. declare module BABYLON {
  103924. /** @hidden */
  103925. export var pbrPixelShader: {
  103926. name: string;
  103927. shader: string;
  103928. };
  103929. }
  103930. declare module BABYLON {
  103931. /** @hidden */
  103932. export var pbrVertexDeclaration: {
  103933. name: string;
  103934. shader: string;
  103935. };
  103936. }
  103937. declare module BABYLON {
  103938. /** @hidden */
  103939. export var pbrVertexShader: {
  103940. name: string;
  103941. shader: string;
  103942. };
  103943. }
  103944. declare module BABYLON {
  103945. /**
  103946. * Manages the defines for the PBR Material.
  103947. * @hidden
  103948. */
  103949. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  103950. PBR: boolean;
  103951. MAINUV1: boolean;
  103952. MAINUV2: boolean;
  103953. UV1: boolean;
  103954. UV2: boolean;
  103955. ALBEDO: boolean;
  103956. ALBEDODIRECTUV: number;
  103957. VERTEXCOLOR: boolean;
  103958. AMBIENT: boolean;
  103959. AMBIENTDIRECTUV: number;
  103960. AMBIENTINGRAYSCALE: boolean;
  103961. OPACITY: boolean;
  103962. VERTEXALPHA: boolean;
  103963. OPACITYDIRECTUV: number;
  103964. OPACITYRGB: boolean;
  103965. ALPHATEST: boolean;
  103966. DEPTHPREPASS: boolean;
  103967. ALPHABLEND: boolean;
  103968. ALPHAFROMALBEDO: boolean;
  103969. ALPHATESTVALUE: string;
  103970. SPECULAROVERALPHA: boolean;
  103971. RADIANCEOVERALPHA: boolean;
  103972. ALPHAFRESNEL: boolean;
  103973. LINEARALPHAFRESNEL: boolean;
  103974. PREMULTIPLYALPHA: boolean;
  103975. EMISSIVE: boolean;
  103976. EMISSIVEDIRECTUV: number;
  103977. REFLECTIVITY: boolean;
  103978. REFLECTIVITYDIRECTUV: number;
  103979. SPECULARTERM: boolean;
  103980. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  103981. MICROSURFACEAUTOMATIC: boolean;
  103982. LODBASEDMICROSFURACE: boolean;
  103983. MICROSURFACEMAP: boolean;
  103984. MICROSURFACEMAPDIRECTUV: number;
  103985. METALLICWORKFLOW: boolean;
  103986. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  103987. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  103988. METALLNESSSTOREINMETALMAPBLUE: boolean;
  103989. AOSTOREINMETALMAPRED: boolean;
  103990. ENVIRONMENTBRDF: boolean;
  103991. ENVIRONMENTBRDF_RGBD: boolean;
  103992. NORMAL: boolean;
  103993. TANGENT: boolean;
  103994. BUMP: boolean;
  103995. BUMPDIRECTUV: number;
  103996. OBJECTSPACE_NORMALMAP: boolean;
  103997. PARALLAX: boolean;
  103998. PARALLAXOCCLUSION: boolean;
  103999. NORMALXYSCALE: boolean;
  104000. LIGHTMAP: boolean;
  104001. LIGHTMAPDIRECTUV: number;
  104002. USELIGHTMAPASSHADOWMAP: boolean;
  104003. GAMMALIGHTMAP: boolean;
  104004. REFLECTION: boolean;
  104005. REFLECTIONMAP_3D: boolean;
  104006. REFLECTIONMAP_SPHERICAL: boolean;
  104007. REFLECTIONMAP_PLANAR: boolean;
  104008. REFLECTIONMAP_CUBIC: boolean;
  104009. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  104010. REFLECTIONMAP_PROJECTION: boolean;
  104011. REFLECTIONMAP_SKYBOX: boolean;
  104012. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  104013. REFLECTIONMAP_EXPLICIT: boolean;
  104014. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  104015. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  104016. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  104017. INVERTCUBICMAP: boolean;
  104018. USESPHERICALFROMREFLECTIONMAP: boolean;
  104019. USESPHERICALINVERTEX: boolean;
  104020. REFLECTIONMAP_OPPOSITEZ: boolean;
  104021. LODINREFLECTIONALPHA: boolean;
  104022. GAMMAREFLECTION: boolean;
  104023. RGBDREFLECTION: boolean;
  104024. RADIANCEOCCLUSION: boolean;
  104025. HORIZONOCCLUSION: boolean;
  104026. INSTANCES: boolean;
  104027. NUM_BONE_INFLUENCERS: number;
  104028. BonesPerMesh: number;
  104029. BONETEXTURE: boolean;
  104030. NONUNIFORMSCALING: boolean;
  104031. MORPHTARGETS: boolean;
  104032. MORPHTARGETS_NORMAL: boolean;
  104033. MORPHTARGETS_TANGENT: boolean;
  104034. NUM_MORPH_INFLUENCERS: number;
  104035. IMAGEPROCESSING: boolean;
  104036. VIGNETTE: boolean;
  104037. VIGNETTEBLENDMODEMULTIPLY: boolean;
  104038. VIGNETTEBLENDMODEOPAQUE: boolean;
  104039. TONEMAPPING: boolean;
  104040. TONEMAPPING_ACES: boolean;
  104041. CONTRAST: boolean;
  104042. COLORCURVES: boolean;
  104043. COLORGRADING: boolean;
  104044. COLORGRADING3D: boolean;
  104045. SAMPLER3DGREENDEPTH: boolean;
  104046. SAMPLER3DBGRMAP: boolean;
  104047. IMAGEPROCESSINGPOSTPROCESS: boolean;
  104048. EXPOSURE: boolean;
  104049. MULTIVIEW: boolean;
  104050. USEPHYSICALLIGHTFALLOFF: boolean;
  104051. USEGLTFLIGHTFALLOFF: boolean;
  104052. TWOSIDEDLIGHTING: boolean;
  104053. SHADOWFLOAT: boolean;
  104054. CLIPPLANE: boolean;
  104055. CLIPPLANE2: boolean;
  104056. CLIPPLANE3: boolean;
  104057. CLIPPLANE4: boolean;
  104058. POINTSIZE: boolean;
  104059. FOG: boolean;
  104060. LOGARITHMICDEPTH: boolean;
  104061. FORCENORMALFORWARD: boolean;
  104062. SPECULARAA: boolean;
  104063. CLEARCOAT: boolean;
  104064. CLEARCOAT_DEFAULTIOR: boolean;
  104065. CLEARCOAT_TEXTURE: boolean;
  104066. CLEARCOAT_TEXTUREDIRECTUV: number;
  104067. CLEARCOAT_BUMP: boolean;
  104068. CLEARCOAT_BUMPDIRECTUV: number;
  104069. CLEARCOAT_TINT: boolean;
  104070. CLEARCOAT_TINT_TEXTURE: boolean;
  104071. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  104072. ANISOTROPIC: boolean;
  104073. ANISOTROPIC_TEXTURE: boolean;
  104074. ANISOTROPIC_TEXTUREDIRECTUV: number;
  104075. BRDF_V_HEIGHT_CORRELATED: boolean;
  104076. MS_BRDF_ENERGY_CONSERVATION: boolean;
  104077. SHEEN: boolean;
  104078. SHEEN_TEXTURE: boolean;
  104079. SHEEN_TEXTUREDIRECTUV: number;
  104080. SHEEN_LINKWITHALBEDO: boolean;
  104081. SUBSURFACE: boolean;
  104082. SS_REFRACTION: boolean;
  104083. SS_TRANSLUCENCY: boolean;
  104084. SS_SCATERRING: boolean;
  104085. SS_THICKNESSANDMASK_TEXTURE: boolean;
  104086. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  104087. SS_REFRACTIONMAP_3D: boolean;
  104088. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  104089. SS_LODINREFRACTIONALPHA: boolean;
  104090. SS_GAMMAREFRACTION: boolean;
  104091. SS_RGBDREFRACTION: boolean;
  104092. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  104093. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  104094. UNLIT: boolean;
  104095. DEBUGMODE: number;
  104096. /**
  104097. * Initializes the PBR Material defines.
  104098. */
  104099. constructor();
  104100. /**
  104101. * Resets the PBR Material defines.
  104102. */
  104103. reset(): void;
  104104. }
  104105. /**
  104106. * The Physically based material base class of BJS.
  104107. *
  104108. * This offers the main features of a standard PBR material.
  104109. * For more information, please refer to the documentation :
  104110. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  104111. */
  104112. export abstract class PBRBaseMaterial extends PushMaterial {
  104113. /**
  104114. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  104115. */
  104116. static readonly PBRMATERIAL_OPAQUE: number;
  104117. /**
  104118. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  104119. */
  104120. static readonly PBRMATERIAL_ALPHATEST: number;
  104121. /**
  104122. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104123. */
  104124. static readonly PBRMATERIAL_ALPHABLEND: number;
  104125. /**
  104126. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104127. * They are also discarded below the alpha cutoff threshold to improve performances.
  104128. */
  104129. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  104130. /**
  104131. * Defines the default value of how much AO map is occluding the analytical lights
  104132. * (point spot...).
  104133. */
  104134. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  104135. /**
  104136. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  104137. */
  104138. static readonly LIGHTFALLOFF_PHYSICAL: number;
  104139. /**
  104140. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  104141. * to enhance interoperability with other engines.
  104142. */
  104143. static readonly LIGHTFALLOFF_GLTF: number;
  104144. /**
  104145. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  104146. * to enhance interoperability with other materials.
  104147. */
  104148. static readonly LIGHTFALLOFF_STANDARD: number;
  104149. /**
  104150. * Intensity of the direct lights e.g. the four lights available in your scene.
  104151. * This impacts both the direct diffuse and specular highlights.
  104152. */
  104153. protected _directIntensity: number;
  104154. /**
  104155. * Intensity of the emissive part of the material.
  104156. * This helps controlling the emissive effect without modifying the emissive color.
  104157. */
  104158. protected _emissiveIntensity: number;
  104159. /**
  104160. * Intensity of the environment e.g. how much the environment will light the object
  104161. * either through harmonics for rough material or through the refelction for shiny ones.
  104162. */
  104163. protected _environmentIntensity: number;
  104164. /**
  104165. * This is a special control allowing the reduction of the specular highlights coming from the
  104166. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  104167. */
  104168. protected _specularIntensity: number;
  104169. /**
  104170. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  104171. */
  104172. private _lightingInfos;
  104173. /**
  104174. * Debug Control allowing disabling the bump map on this material.
  104175. */
  104176. protected _disableBumpMap: boolean;
  104177. /**
  104178. * AKA Diffuse Texture in standard nomenclature.
  104179. */
  104180. protected _albedoTexture: BaseTexture;
  104181. /**
  104182. * AKA Occlusion Texture in other nomenclature.
  104183. */
  104184. protected _ambientTexture: BaseTexture;
  104185. /**
  104186. * AKA Occlusion Texture Intensity in other nomenclature.
  104187. */
  104188. protected _ambientTextureStrength: number;
  104189. /**
  104190. * Defines how much the AO map is occluding the analytical lights (point spot...).
  104191. * 1 means it completely occludes it
  104192. * 0 mean it has no impact
  104193. */
  104194. protected _ambientTextureImpactOnAnalyticalLights: number;
  104195. /**
  104196. * Stores the alpha values in a texture.
  104197. */
  104198. protected _opacityTexture: BaseTexture;
  104199. /**
  104200. * Stores the reflection values in a texture.
  104201. */
  104202. protected _reflectionTexture: BaseTexture;
  104203. /**
  104204. * Stores the emissive values in a texture.
  104205. */
  104206. protected _emissiveTexture: BaseTexture;
  104207. /**
  104208. * AKA Specular texture in other nomenclature.
  104209. */
  104210. protected _reflectivityTexture: BaseTexture;
  104211. /**
  104212. * Used to switch from specular/glossiness to metallic/roughness workflow.
  104213. */
  104214. protected _metallicTexture: BaseTexture;
  104215. /**
  104216. * Specifies the metallic scalar of the metallic/roughness workflow.
  104217. * Can also be used to scale the metalness values of the metallic texture.
  104218. */
  104219. protected _metallic: Nullable<number>;
  104220. /**
  104221. * Specifies the roughness scalar of the metallic/roughness workflow.
  104222. * Can also be used to scale the roughness values of the metallic texture.
  104223. */
  104224. protected _roughness: Nullable<number>;
  104225. /**
  104226. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  104227. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  104228. */
  104229. protected _microSurfaceTexture: BaseTexture;
  104230. /**
  104231. * Stores surface normal data used to displace a mesh in a texture.
  104232. */
  104233. protected _bumpTexture: BaseTexture;
  104234. /**
  104235. * Stores the pre-calculated light information of a mesh in a texture.
  104236. */
  104237. protected _lightmapTexture: BaseTexture;
  104238. /**
  104239. * The color of a material in ambient lighting.
  104240. */
  104241. protected _ambientColor: Color3;
  104242. /**
  104243. * AKA Diffuse Color in other nomenclature.
  104244. */
  104245. protected _albedoColor: Color3;
  104246. /**
  104247. * AKA Specular Color in other nomenclature.
  104248. */
  104249. protected _reflectivityColor: Color3;
  104250. /**
  104251. * The color applied when light is reflected from a material.
  104252. */
  104253. protected _reflectionColor: Color3;
  104254. /**
  104255. * The color applied when light is emitted from a material.
  104256. */
  104257. protected _emissiveColor: Color3;
  104258. /**
  104259. * AKA Glossiness in other nomenclature.
  104260. */
  104261. protected _microSurface: number;
  104262. /**
  104263. * Specifies that the material will use the light map as a show map.
  104264. */
  104265. protected _useLightmapAsShadowmap: boolean;
  104266. /**
  104267. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  104268. * makes the reflect vector face the model (under horizon).
  104269. */
  104270. protected _useHorizonOcclusion: boolean;
  104271. /**
  104272. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  104273. * too much the area relying on ambient texture to define their ambient occlusion.
  104274. */
  104275. protected _useRadianceOcclusion: boolean;
  104276. /**
  104277. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  104278. */
  104279. protected _useAlphaFromAlbedoTexture: boolean;
  104280. /**
  104281. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  104282. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  104283. */
  104284. protected _useSpecularOverAlpha: boolean;
  104285. /**
  104286. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  104287. */
  104288. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  104289. /**
  104290. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  104291. */
  104292. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  104293. /**
  104294. * Specifies if the metallic texture contains the roughness information in its green channel.
  104295. */
  104296. protected _useRoughnessFromMetallicTextureGreen: boolean;
  104297. /**
  104298. * Specifies if the metallic texture contains the metallness information in its blue channel.
  104299. */
  104300. protected _useMetallnessFromMetallicTextureBlue: boolean;
  104301. /**
  104302. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  104303. */
  104304. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  104305. /**
  104306. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  104307. */
  104308. protected _useAmbientInGrayScale: boolean;
  104309. /**
  104310. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  104311. * The material will try to infer what glossiness each pixel should be.
  104312. */
  104313. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  104314. /**
  104315. * Defines the falloff type used in this material.
  104316. * It by default is Physical.
  104317. */
  104318. protected _lightFalloff: number;
  104319. /**
  104320. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  104321. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  104322. */
  104323. protected _useRadianceOverAlpha: boolean;
  104324. /**
  104325. * Allows using an object space normal map (instead of tangent space).
  104326. */
  104327. protected _useObjectSpaceNormalMap: boolean;
  104328. /**
  104329. * Allows using the bump map in parallax mode.
  104330. */
  104331. protected _useParallax: boolean;
  104332. /**
  104333. * Allows using the bump map in parallax occlusion mode.
  104334. */
  104335. protected _useParallaxOcclusion: boolean;
  104336. /**
  104337. * Controls the scale bias of the parallax mode.
  104338. */
  104339. protected _parallaxScaleBias: number;
  104340. /**
  104341. * If sets to true, disables all the lights affecting the material.
  104342. */
  104343. protected _disableLighting: boolean;
  104344. /**
  104345. * Number of Simultaneous lights allowed on the material.
  104346. */
  104347. protected _maxSimultaneousLights: number;
  104348. /**
  104349. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  104350. */
  104351. protected _invertNormalMapX: boolean;
  104352. /**
  104353. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  104354. */
  104355. protected _invertNormalMapY: boolean;
  104356. /**
  104357. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  104358. */
  104359. protected _twoSidedLighting: boolean;
  104360. /**
  104361. * Defines the alpha limits in alpha test mode.
  104362. */
  104363. protected _alphaCutOff: number;
  104364. /**
  104365. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  104366. */
  104367. protected _forceAlphaTest: boolean;
  104368. /**
  104369. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  104370. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  104371. */
  104372. protected _useAlphaFresnel: boolean;
  104373. /**
  104374. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  104375. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  104376. */
  104377. protected _useLinearAlphaFresnel: boolean;
  104378. /**
  104379. * The transparency mode of the material.
  104380. */
  104381. protected _transparencyMode: Nullable<number>;
  104382. /**
  104383. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  104384. * from cos thetav and roughness:
  104385. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  104386. */
  104387. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  104388. /**
  104389. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  104390. */
  104391. protected _forceIrradianceInFragment: boolean;
  104392. /**
  104393. * Force normal to face away from face.
  104394. */
  104395. protected _forceNormalForward: boolean;
  104396. /**
  104397. * Enables specular anti aliasing in the PBR shader.
  104398. * It will both interacts on the Geometry for analytical and IBL lighting.
  104399. * It also prefilter the roughness map based on the bump values.
  104400. */
  104401. protected _enableSpecularAntiAliasing: boolean;
  104402. /**
  104403. * Default configuration related to image processing available in the PBR Material.
  104404. */
  104405. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  104406. /**
  104407. * Keep track of the image processing observer to allow dispose and replace.
  104408. */
  104409. private _imageProcessingObserver;
  104410. /**
  104411. * Attaches a new image processing configuration to the PBR Material.
  104412. * @param configuration
  104413. */
  104414. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  104415. /**
  104416. * Stores the available render targets.
  104417. */
  104418. private _renderTargets;
  104419. /**
  104420. * Sets the global ambient color for the material used in lighting calculations.
  104421. */
  104422. private _globalAmbientColor;
  104423. /**
  104424. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  104425. */
  104426. private _useLogarithmicDepth;
  104427. /**
  104428. * If set to true, no lighting calculations will be applied.
  104429. */
  104430. private _unlit;
  104431. private _debugMode;
  104432. /**
  104433. * @hidden
  104434. * This is reserved for the inspector.
  104435. * Defines the material debug mode.
  104436. * It helps seeing only some components of the material while troubleshooting.
  104437. */
  104438. debugMode: number;
  104439. /**
  104440. * @hidden
  104441. * This is reserved for the inspector.
  104442. * Specify from where on screen the debug mode should start.
  104443. * The value goes from -1 (full screen) to 1 (not visible)
  104444. * It helps with side by side comparison against the final render
  104445. * This defaults to -1
  104446. */
  104447. private debugLimit;
  104448. /**
  104449. * @hidden
  104450. * This is reserved for the inspector.
  104451. * As the default viewing range might not be enough (if the ambient is really small for instance)
  104452. * You can use the factor to better multiply the final value.
  104453. */
  104454. private debugFactor;
  104455. /**
  104456. * Defines the clear coat layer parameters for the material.
  104457. */
  104458. readonly clearCoat: PBRClearCoatConfiguration;
  104459. /**
  104460. * Defines the anisotropic parameters for the material.
  104461. */
  104462. readonly anisotropy: PBRAnisotropicConfiguration;
  104463. /**
  104464. * Defines the BRDF parameters for the material.
  104465. */
  104466. readonly brdf: PBRBRDFConfiguration;
  104467. /**
  104468. * Defines the Sheen parameters for the material.
  104469. */
  104470. readonly sheen: PBRSheenConfiguration;
  104471. /**
  104472. * Defines the SubSurface parameters for the material.
  104473. */
  104474. readonly subSurface: PBRSubSurfaceConfiguration;
  104475. /**
  104476. * Custom callback helping to override the default shader used in the material.
  104477. */
  104478. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  104479. /**
  104480. * Instantiates a new PBRMaterial instance.
  104481. *
  104482. * @param name The material name
  104483. * @param scene The scene the material will be use in.
  104484. */
  104485. constructor(name: string, scene: Scene);
  104486. /**
  104487. * Gets a boolean indicating that current material needs to register RTT
  104488. */
  104489. readonly hasRenderTargetTextures: boolean;
  104490. /**
  104491. * Gets the name of the material class.
  104492. */
  104493. getClassName(): string;
  104494. /**
  104495. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  104496. */
  104497. /**
  104498. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  104499. */
  104500. useLogarithmicDepth: boolean;
  104501. /**
  104502. * Gets the current transparency mode.
  104503. */
  104504. /**
  104505. * Sets the transparency mode of the material.
  104506. *
  104507. * | Value | Type | Description |
  104508. * | ----- | ----------------------------------- | ----------- |
  104509. * | 0 | OPAQUE | |
  104510. * | 1 | ALPHATEST | |
  104511. * | 2 | ALPHABLEND | |
  104512. * | 3 | ALPHATESTANDBLEND | |
  104513. *
  104514. */
  104515. transparencyMode: Nullable<number>;
  104516. /**
  104517. * Returns true if alpha blending should be disabled.
  104518. */
  104519. private readonly _disableAlphaBlending;
  104520. /**
  104521. * Specifies whether or not this material should be rendered in alpha blend mode.
  104522. */
  104523. needAlphaBlending(): boolean;
  104524. /**
  104525. * Specifies if the mesh will require alpha blending.
  104526. * @param mesh - BJS mesh.
  104527. */
  104528. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  104529. /**
  104530. * Specifies whether or not this material should be rendered in alpha test mode.
  104531. */
  104532. needAlphaTesting(): boolean;
  104533. /**
  104534. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  104535. */
  104536. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  104537. /**
  104538. * Gets the texture used for the alpha test.
  104539. */
  104540. getAlphaTestTexture(): BaseTexture;
  104541. /**
  104542. * Specifies that the submesh is ready to be used.
  104543. * @param mesh - BJS mesh.
  104544. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  104545. * @param useInstances - Specifies that instances should be used.
  104546. * @returns - boolean indicating that the submesh is ready or not.
  104547. */
  104548. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  104549. /**
  104550. * Specifies if the material uses metallic roughness workflow.
  104551. * @returns boolean specifiying if the material uses metallic roughness workflow.
  104552. */
  104553. isMetallicWorkflow(): boolean;
  104554. private _prepareEffect;
  104555. private _prepareDefines;
  104556. /**
  104557. * Force shader compilation
  104558. */
  104559. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  104560. clipPlane: boolean;
  104561. }>): void;
  104562. /**
  104563. * Initializes the uniform buffer layout for the shader.
  104564. */
  104565. buildUniformLayout(): void;
  104566. /**
  104567. * Unbinds the material from the mesh
  104568. */
  104569. unbind(): void;
  104570. /**
  104571. * Binds the submesh data.
  104572. * @param world - The world matrix.
  104573. * @param mesh - The BJS mesh.
  104574. * @param subMesh - A submesh of the BJS mesh.
  104575. */
  104576. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  104577. /**
  104578. * Returns the animatable textures.
  104579. * @returns - Array of animatable textures.
  104580. */
  104581. getAnimatables(): IAnimatable[];
  104582. /**
  104583. * Returns the texture used for reflections.
  104584. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  104585. */
  104586. private _getReflectionTexture;
  104587. /**
  104588. * Returns an array of the actively used textures.
  104589. * @returns - Array of BaseTextures
  104590. */
  104591. getActiveTextures(): BaseTexture[];
  104592. /**
  104593. * Checks to see if a texture is used in the material.
  104594. * @param texture - Base texture to use.
  104595. * @returns - Boolean specifying if a texture is used in the material.
  104596. */
  104597. hasTexture(texture: BaseTexture): boolean;
  104598. /**
  104599. * Disposes the resources of the material.
  104600. * @param forceDisposeEffect - Forces the disposal of effects.
  104601. * @param forceDisposeTextures - Forces the disposal of all textures.
  104602. */
  104603. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  104604. }
  104605. }
  104606. declare module BABYLON {
  104607. /**
  104608. * The Physically based material of BJS.
  104609. *
  104610. * This offers the main features of a standard PBR material.
  104611. * For more information, please refer to the documentation :
  104612. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  104613. */
  104614. export class PBRMaterial extends PBRBaseMaterial {
  104615. /**
  104616. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  104617. */
  104618. static readonly PBRMATERIAL_OPAQUE: number;
  104619. /**
  104620. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  104621. */
  104622. static readonly PBRMATERIAL_ALPHATEST: number;
  104623. /**
  104624. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104625. */
  104626. static readonly PBRMATERIAL_ALPHABLEND: number;
  104627. /**
  104628. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104629. * They are also discarded below the alpha cutoff threshold to improve performances.
  104630. */
  104631. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  104632. /**
  104633. * Defines the default value of how much AO map is occluding the analytical lights
  104634. * (point spot...).
  104635. */
  104636. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  104637. /**
  104638. * Intensity of the direct lights e.g. the four lights available in your scene.
  104639. * This impacts both the direct diffuse and specular highlights.
  104640. */
  104641. directIntensity: number;
  104642. /**
  104643. * Intensity of the emissive part of the material.
  104644. * This helps controlling the emissive effect without modifying the emissive color.
  104645. */
  104646. emissiveIntensity: number;
  104647. /**
  104648. * Intensity of the environment e.g. how much the environment will light the object
  104649. * either through harmonics for rough material or through the refelction for shiny ones.
  104650. */
  104651. environmentIntensity: number;
  104652. /**
  104653. * This is a special control allowing the reduction of the specular highlights coming from the
  104654. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  104655. */
  104656. specularIntensity: number;
  104657. /**
  104658. * Debug Control allowing disabling the bump map on this material.
  104659. */
  104660. disableBumpMap: boolean;
  104661. /**
  104662. * AKA Diffuse Texture in standard nomenclature.
  104663. */
  104664. albedoTexture: BaseTexture;
  104665. /**
  104666. * AKA Occlusion Texture in other nomenclature.
  104667. */
  104668. ambientTexture: BaseTexture;
  104669. /**
  104670. * AKA Occlusion Texture Intensity in other nomenclature.
  104671. */
  104672. ambientTextureStrength: number;
  104673. /**
  104674. * Defines how much the AO map is occluding the analytical lights (point spot...).
  104675. * 1 means it completely occludes it
  104676. * 0 mean it has no impact
  104677. */
  104678. ambientTextureImpactOnAnalyticalLights: number;
  104679. /**
  104680. * Stores the alpha values in a texture.
  104681. */
  104682. opacityTexture: BaseTexture;
  104683. /**
  104684. * Stores the reflection values in a texture.
  104685. */
  104686. reflectionTexture: Nullable<BaseTexture>;
  104687. /**
  104688. * Stores the emissive values in a texture.
  104689. */
  104690. emissiveTexture: BaseTexture;
  104691. /**
  104692. * AKA Specular texture in other nomenclature.
  104693. */
  104694. reflectivityTexture: BaseTexture;
  104695. /**
  104696. * Used to switch from specular/glossiness to metallic/roughness workflow.
  104697. */
  104698. metallicTexture: BaseTexture;
  104699. /**
  104700. * Specifies the metallic scalar of the metallic/roughness workflow.
  104701. * Can also be used to scale the metalness values of the metallic texture.
  104702. */
  104703. metallic: Nullable<number>;
  104704. /**
  104705. * Specifies the roughness scalar of the metallic/roughness workflow.
  104706. * Can also be used to scale the roughness values of the metallic texture.
  104707. */
  104708. roughness: Nullable<number>;
  104709. /**
  104710. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  104711. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  104712. */
  104713. microSurfaceTexture: BaseTexture;
  104714. /**
  104715. * Stores surface normal data used to displace a mesh in a texture.
  104716. */
  104717. bumpTexture: BaseTexture;
  104718. /**
  104719. * Stores the pre-calculated light information of a mesh in a texture.
  104720. */
  104721. lightmapTexture: BaseTexture;
  104722. /**
  104723. * Stores the refracted light information in a texture.
  104724. */
  104725. refractionTexture: Nullable<BaseTexture>;
  104726. /**
  104727. * The color of a material in ambient lighting.
  104728. */
  104729. ambientColor: Color3;
  104730. /**
  104731. * AKA Diffuse Color in other nomenclature.
  104732. */
  104733. albedoColor: Color3;
  104734. /**
  104735. * AKA Specular Color in other nomenclature.
  104736. */
  104737. reflectivityColor: Color3;
  104738. /**
  104739. * The color reflected from the material.
  104740. */
  104741. reflectionColor: Color3;
  104742. /**
  104743. * The color emitted from the material.
  104744. */
  104745. emissiveColor: Color3;
  104746. /**
  104747. * AKA Glossiness in other nomenclature.
  104748. */
  104749. microSurface: number;
  104750. /**
  104751. * source material index of refraction (IOR)' / 'destination material IOR.
  104752. */
  104753. indexOfRefraction: number;
  104754. /**
  104755. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  104756. */
  104757. invertRefractionY: boolean;
  104758. /**
  104759. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  104760. * Materials half opaque for instance using refraction could benefit from this control.
  104761. */
  104762. linkRefractionWithTransparency: boolean;
  104763. /**
  104764. * If true, the light map contains occlusion information instead of lighting info.
  104765. */
  104766. useLightmapAsShadowmap: boolean;
  104767. /**
  104768. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  104769. */
  104770. useAlphaFromAlbedoTexture: boolean;
  104771. /**
  104772. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  104773. */
  104774. forceAlphaTest: boolean;
  104775. /**
  104776. * Defines the alpha limits in alpha test mode.
  104777. */
  104778. alphaCutOff: number;
  104779. /**
  104780. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  104781. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  104782. */
  104783. useSpecularOverAlpha: boolean;
  104784. /**
  104785. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  104786. */
  104787. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  104788. /**
  104789. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  104790. */
  104791. useRoughnessFromMetallicTextureAlpha: boolean;
  104792. /**
  104793. * Specifies if the metallic texture contains the roughness information in its green channel.
  104794. */
  104795. useRoughnessFromMetallicTextureGreen: boolean;
  104796. /**
  104797. * Specifies if the metallic texture contains the metallness information in its blue channel.
  104798. */
  104799. useMetallnessFromMetallicTextureBlue: boolean;
  104800. /**
  104801. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  104802. */
  104803. useAmbientOcclusionFromMetallicTextureRed: boolean;
  104804. /**
  104805. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  104806. */
  104807. useAmbientInGrayScale: boolean;
  104808. /**
  104809. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  104810. * The material will try to infer what glossiness each pixel should be.
  104811. */
  104812. useAutoMicroSurfaceFromReflectivityMap: boolean;
  104813. /**
  104814. * BJS is using an harcoded light falloff based on a manually sets up range.
  104815. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  104816. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  104817. */
  104818. /**
  104819. * BJS is using an harcoded light falloff based on a manually sets up range.
  104820. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  104821. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  104822. */
  104823. usePhysicalLightFalloff: boolean;
  104824. /**
  104825. * In order to support the falloff compatibility with gltf, a special mode has been added
  104826. * to reproduce the gltf light falloff.
  104827. */
  104828. /**
  104829. * In order to support the falloff compatibility with gltf, a special mode has been added
  104830. * to reproduce the gltf light falloff.
  104831. */
  104832. useGLTFLightFalloff: boolean;
  104833. /**
  104834. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  104835. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  104836. */
  104837. useRadianceOverAlpha: boolean;
  104838. /**
  104839. * Allows using an object space normal map (instead of tangent space).
  104840. */
  104841. useObjectSpaceNormalMap: boolean;
  104842. /**
  104843. * Allows using the bump map in parallax mode.
  104844. */
  104845. useParallax: boolean;
  104846. /**
  104847. * Allows using the bump map in parallax occlusion mode.
  104848. */
  104849. useParallaxOcclusion: boolean;
  104850. /**
  104851. * Controls the scale bias of the parallax mode.
  104852. */
  104853. parallaxScaleBias: number;
  104854. /**
  104855. * If sets to true, disables all the lights affecting the material.
  104856. */
  104857. disableLighting: boolean;
  104858. /**
  104859. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  104860. */
  104861. forceIrradianceInFragment: boolean;
  104862. /**
  104863. * Number of Simultaneous lights allowed on the material.
  104864. */
  104865. maxSimultaneousLights: number;
  104866. /**
  104867. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  104868. */
  104869. invertNormalMapX: boolean;
  104870. /**
  104871. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  104872. */
  104873. invertNormalMapY: boolean;
  104874. /**
  104875. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  104876. */
  104877. twoSidedLighting: boolean;
  104878. /**
  104879. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  104880. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  104881. */
  104882. useAlphaFresnel: boolean;
  104883. /**
  104884. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  104885. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  104886. */
  104887. useLinearAlphaFresnel: boolean;
  104888. /**
  104889. * Let user defines the brdf lookup texture used for IBL.
  104890. * A default 8bit version is embedded but you could point at :
  104891. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  104892. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  104893. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  104894. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  104895. */
  104896. environmentBRDFTexture: Nullable<BaseTexture>;
  104897. /**
  104898. * Force normal to face away from face.
  104899. */
  104900. forceNormalForward: boolean;
  104901. /**
  104902. * Enables specular anti aliasing in the PBR shader.
  104903. * It will both interacts on the Geometry for analytical and IBL lighting.
  104904. * It also prefilter the roughness map based on the bump values.
  104905. */
  104906. enableSpecularAntiAliasing: boolean;
  104907. /**
  104908. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  104909. * makes the reflect vector face the model (under horizon).
  104910. */
  104911. useHorizonOcclusion: boolean;
  104912. /**
  104913. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  104914. * too much the area relying on ambient texture to define their ambient occlusion.
  104915. */
  104916. useRadianceOcclusion: boolean;
  104917. /**
  104918. * If set to true, no lighting calculations will be applied.
  104919. */
  104920. unlit: boolean;
  104921. /**
  104922. * Gets the image processing configuration used either in this material.
  104923. */
  104924. /**
  104925. * Sets the Default image processing configuration used either in the this material.
  104926. *
  104927. * If sets to null, the scene one is in use.
  104928. */
  104929. imageProcessingConfiguration: ImageProcessingConfiguration;
  104930. /**
  104931. * Gets wether the color curves effect is enabled.
  104932. */
  104933. /**
  104934. * Sets wether the color curves effect is enabled.
  104935. */
  104936. cameraColorCurvesEnabled: boolean;
  104937. /**
  104938. * Gets wether the color grading effect is enabled.
  104939. */
  104940. /**
  104941. * Gets wether the color grading effect is enabled.
  104942. */
  104943. cameraColorGradingEnabled: boolean;
  104944. /**
  104945. * Gets wether tonemapping is enabled or not.
  104946. */
  104947. /**
  104948. * Sets wether tonemapping is enabled or not
  104949. */
  104950. cameraToneMappingEnabled: boolean;
  104951. /**
  104952. * The camera exposure used on this material.
  104953. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  104954. * This corresponds to a photographic exposure.
  104955. */
  104956. /**
  104957. * The camera exposure used on this material.
  104958. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  104959. * This corresponds to a photographic exposure.
  104960. */
  104961. cameraExposure: number;
  104962. /**
  104963. * Gets The camera contrast used on this material.
  104964. */
  104965. /**
  104966. * Sets The camera contrast used on this material.
  104967. */
  104968. cameraContrast: number;
  104969. /**
  104970. * Gets the Color Grading 2D Lookup Texture.
  104971. */
  104972. /**
  104973. * Sets the Color Grading 2D Lookup Texture.
  104974. */
  104975. cameraColorGradingTexture: Nullable<BaseTexture>;
  104976. /**
  104977. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  104978. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  104979. * 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;
  104980. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  104981. */
  104982. /**
  104983. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  104984. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  104985. * 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;
  104986. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  104987. */
  104988. cameraColorCurves: Nullable<ColorCurves>;
  104989. /**
  104990. * Instantiates a new PBRMaterial instance.
  104991. *
  104992. * @param name The material name
  104993. * @param scene The scene the material will be use in.
  104994. */
  104995. constructor(name: string, scene: Scene);
  104996. /**
  104997. * Returns the name of this material class.
  104998. */
  104999. getClassName(): string;
  105000. /**
  105001. * Makes a duplicate of the current material.
  105002. * @param name - name to use for the new material.
  105003. */
  105004. clone(name: string): PBRMaterial;
  105005. /**
  105006. * Serializes this PBR Material.
  105007. * @returns - An object with the serialized material.
  105008. */
  105009. serialize(): any;
  105010. /**
  105011. * Parses a PBR Material from a serialized object.
  105012. * @param source - Serialized object.
  105013. * @param scene - BJS scene instance.
  105014. * @param rootUrl - url for the scene object
  105015. * @returns - PBRMaterial
  105016. */
  105017. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  105018. }
  105019. }
  105020. declare module BABYLON {
  105021. /**
  105022. * Direct draw surface info
  105023. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  105024. */
  105025. export interface DDSInfo {
  105026. /**
  105027. * Width of the texture
  105028. */
  105029. width: number;
  105030. /**
  105031. * Width of the texture
  105032. */
  105033. height: number;
  105034. /**
  105035. * Number of Mipmaps for the texture
  105036. * @see https://en.wikipedia.org/wiki/Mipmap
  105037. */
  105038. mipmapCount: number;
  105039. /**
  105040. * If the textures format is a known fourCC format
  105041. * @see https://www.fourcc.org/
  105042. */
  105043. isFourCC: boolean;
  105044. /**
  105045. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  105046. */
  105047. isRGB: boolean;
  105048. /**
  105049. * If the texture is a lumincance format
  105050. */
  105051. isLuminance: boolean;
  105052. /**
  105053. * If this is a cube texture
  105054. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  105055. */
  105056. isCube: boolean;
  105057. /**
  105058. * If the texture is a compressed format eg. FOURCC_DXT1
  105059. */
  105060. isCompressed: boolean;
  105061. /**
  105062. * The dxgiFormat of the texture
  105063. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  105064. */
  105065. dxgiFormat: number;
  105066. /**
  105067. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  105068. */
  105069. textureType: number;
  105070. /**
  105071. * Sphericle polynomial created for the dds texture
  105072. */
  105073. sphericalPolynomial?: SphericalPolynomial;
  105074. }
  105075. /**
  105076. * Class used to provide DDS decompression tools
  105077. */
  105078. export class DDSTools {
  105079. /**
  105080. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  105081. */
  105082. static StoreLODInAlphaChannel: boolean;
  105083. /**
  105084. * Gets DDS information from an array buffer
  105085. * @param arrayBuffer defines the array buffer to read data from
  105086. * @returns the DDS information
  105087. */
  105088. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  105089. private static _FloatView;
  105090. private static _Int32View;
  105091. private static _ToHalfFloat;
  105092. private static _FromHalfFloat;
  105093. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  105094. private static _GetHalfFloatRGBAArrayBuffer;
  105095. private static _GetFloatRGBAArrayBuffer;
  105096. private static _GetFloatAsUIntRGBAArrayBuffer;
  105097. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  105098. private static _GetRGBAArrayBuffer;
  105099. private static _ExtractLongWordOrder;
  105100. private static _GetRGBArrayBuffer;
  105101. private static _GetLuminanceArrayBuffer;
  105102. /**
  105103. * Uploads DDS Levels to a Babylon Texture
  105104. * @hidden
  105105. */
  105106. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  105107. }
  105108. interface Engine {
  105109. /**
  105110. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  105111. * @param rootUrl defines the url where the file to load is located
  105112. * @param scene defines the current scene
  105113. * @param lodScale defines scale to apply to the mip map selection
  105114. * @param lodOffset defines offset to apply to the mip map selection
  105115. * @param onLoad defines an optional callback raised when the texture is loaded
  105116. * @param onError defines an optional callback raised if there is an issue to load the texture
  105117. * @param format defines the format of the data
  105118. * @param forcedExtension defines the extension to use to pick the right loader
  105119. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  105120. * @returns the cube texture as an InternalTexture
  105121. */
  105122. 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;
  105123. }
  105124. }
  105125. declare module BABYLON {
  105126. /**
  105127. * Implementation of the DDS Texture Loader.
  105128. * @hidden
  105129. */
  105130. export class _DDSTextureLoader implements IInternalTextureLoader {
  105131. /**
  105132. * Defines wether the loader supports cascade loading the different faces.
  105133. */
  105134. readonly supportCascades: boolean;
  105135. /**
  105136. * This returns if the loader support the current file information.
  105137. * @param extension defines the file extension of the file being loaded
  105138. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105139. * @param fallback defines the fallback internal texture if any
  105140. * @param isBase64 defines whether the texture is encoded as a base64
  105141. * @param isBuffer defines whether the texture data are stored as a buffer
  105142. * @returns true if the loader can load the specified file
  105143. */
  105144. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  105145. /**
  105146. * Transform the url before loading if required.
  105147. * @param rootUrl the url of the texture
  105148. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105149. * @returns the transformed texture
  105150. */
  105151. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  105152. /**
  105153. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  105154. * @param rootUrl the url of the texture
  105155. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105156. * @returns the fallback texture
  105157. */
  105158. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  105159. /**
  105160. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  105161. * @param data contains the texture data
  105162. * @param texture defines the BabylonJS internal texture
  105163. * @param createPolynomials will be true if polynomials have been requested
  105164. * @param onLoad defines the callback to trigger once the texture is ready
  105165. * @param onError defines the callback to trigger in case of error
  105166. */
  105167. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  105168. /**
  105169. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  105170. * @param data contains the texture data
  105171. * @param texture defines the BabylonJS internal texture
  105172. * @param callback defines the method to call once ready to upload
  105173. */
  105174. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  105175. }
  105176. }
  105177. declare module BABYLON {
  105178. /** @hidden */
  105179. export var rgbdEncodePixelShader: {
  105180. name: string;
  105181. shader: string;
  105182. };
  105183. }
  105184. declare module BABYLON {
  105185. /**
  105186. * Raw texture data and descriptor sufficient for WebGL texture upload
  105187. */
  105188. export interface EnvironmentTextureInfo {
  105189. /**
  105190. * Version of the environment map
  105191. */
  105192. version: number;
  105193. /**
  105194. * Width of image
  105195. */
  105196. width: number;
  105197. /**
  105198. * Irradiance information stored in the file.
  105199. */
  105200. irradiance: any;
  105201. /**
  105202. * Specular information stored in the file.
  105203. */
  105204. specular: any;
  105205. }
  105206. /**
  105207. * Sets of helpers addressing the serialization and deserialization of environment texture
  105208. * stored in a BabylonJS env file.
  105209. * Those files are usually stored as .env files.
  105210. */
  105211. export class EnvironmentTextureTools {
  105212. /**
  105213. * Magic number identifying the env file.
  105214. */
  105215. private static _MagicBytes;
  105216. /**
  105217. * Gets the environment info from an env file.
  105218. * @param data The array buffer containing the .env bytes.
  105219. * @returns the environment file info (the json header) if successfully parsed.
  105220. */
  105221. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  105222. /**
  105223. * Creates an environment texture from a loaded cube texture.
  105224. * @param texture defines the cube texture to convert in env file
  105225. * @return a promise containing the environment data if succesfull.
  105226. */
  105227. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  105228. /**
  105229. * Creates a JSON representation of the spherical data.
  105230. * @param texture defines the texture containing the polynomials
  105231. * @return the JSON representation of the spherical info
  105232. */
  105233. private static _CreateEnvTextureIrradiance;
  105234. /**
  105235. * Uploads the texture info contained in the env file to the GPU.
  105236. * @param texture defines the internal texture to upload to
  105237. * @param arrayBuffer defines the buffer cotaining the data to load
  105238. * @param info defines the texture info retrieved through the GetEnvInfo method
  105239. * @returns a promise
  105240. */
  105241. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  105242. /**
  105243. * Uploads the levels of image data to the GPU.
  105244. * @param texture defines the internal texture to upload to
  105245. * @param imageData defines the array buffer views of image data [mipmap][face]
  105246. * @returns a promise
  105247. */
  105248. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  105249. /**
  105250. * Uploads spherical polynomials information to the texture.
  105251. * @param texture defines the texture we are trying to upload the information to
  105252. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  105253. */
  105254. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  105255. /** @hidden */
  105256. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  105257. }
  105258. }
  105259. declare module BABYLON {
  105260. /**
  105261. * Implementation of the ENV Texture Loader.
  105262. * @hidden
  105263. */
  105264. export class _ENVTextureLoader implements IInternalTextureLoader {
  105265. /**
  105266. * Defines wether the loader supports cascade loading the different faces.
  105267. */
  105268. readonly supportCascades: boolean;
  105269. /**
  105270. * This returns if the loader support the current file information.
  105271. * @param extension defines the file extension of the file being loaded
  105272. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105273. * @param fallback defines the fallback internal texture if any
  105274. * @param isBase64 defines whether the texture is encoded as a base64
  105275. * @param isBuffer defines whether the texture data are stored as a buffer
  105276. * @returns true if the loader can load the specified file
  105277. */
  105278. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  105279. /**
  105280. * Transform the url before loading if required.
  105281. * @param rootUrl the url of the texture
  105282. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105283. * @returns the transformed texture
  105284. */
  105285. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  105286. /**
  105287. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  105288. * @param rootUrl the url of the texture
  105289. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105290. * @returns the fallback texture
  105291. */
  105292. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  105293. /**
  105294. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  105295. * @param data contains the texture data
  105296. * @param texture defines the BabylonJS internal texture
  105297. * @param createPolynomials will be true if polynomials have been requested
  105298. * @param onLoad defines the callback to trigger once the texture is ready
  105299. * @param onError defines the callback to trigger in case of error
  105300. */
  105301. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  105302. /**
  105303. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  105304. * @param data contains the texture data
  105305. * @param texture defines the BabylonJS internal texture
  105306. * @param callback defines the method to call once ready to upload
  105307. */
  105308. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  105309. }
  105310. }
  105311. declare module BABYLON {
  105312. /**
  105313. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  105314. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  105315. */
  105316. export class KhronosTextureContainer {
  105317. /** contents of the KTX container file */
  105318. arrayBuffer: any;
  105319. private static HEADER_LEN;
  105320. private static COMPRESSED_2D;
  105321. private static COMPRESSED_3D;
  105322. private static TEX_2D;
  105323. private static TEX_3D;
  105324. /**
  105325. * Gets the openGL type
  105326. */
  105327. glType: number;
  105328. /**
  105329. * Gets the openGL type size
  105330. */
  105331. glTypeSize: number;
  105332. /**
  105333. * Gets the openGL format
  105334. */
  105335. glFormat: number;
  105336. /**
  105337. * Gets the openGL internal format
  105338. */
  105339. glInternalFormat: number;
  105340. /**
  105341. * Gets the base internal format
  105342. */
  105343. glBaseInternalFormat: number;
  105344. /**
  105345. * Gets image width in pixel
  105346. */
  105347. pixelWidth: number;
  105348. /**
  105349. * Gets image height in pixel
  105350. */
  105351. pixelHeight: number;
  105352. /**
  105353. * Gets image depth in pixels
  105354. */
  105355. pixelDepth: number;
  105356. /**
  105357. * Gets the number of array elements
  105358. */
  105359. numberOfArrayElements: number;
  105360. /**
  105361. * Gets the number of faces
  105362. */
  105363. numberOfFaces: number;
  105364. /**
  105365. * Gets the number of mipmap levels
  105366. */
  105367. numberOfMipmapLevels: number;
  105368. /**
  105369. * Gets the bytes of key value data
  105370. */
  105371. bytesOfKeyValueData: number;
  105372. /**
  105373. * Gets the load type
  105374. */
  105375. loadType: number;
  105376. /**
  105377. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  105378. */
  105379. isInvalid: boolean;
  105380. /**
  105381. * Creates a new KhronosTextureContainer
  105382. * @param arrayBuffer contents of the KTX container file
  105383. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  105384. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  105385. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  105386. */
  105387. constructor(
  105388. /** contents of the KTX container file */
  105389. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  105390. /**
  105391. * Uploads KTX content to a Babylon Texture.
  105392. * It is assumed that the texture has already been created & is currently bound
  105393. * @hidden
  105394. */
  105395. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  105396. private _upload2DCompressedLevels;
  105397. }
  105398. }
  105399. declare module BABYLON {
  105400. /**
  105401. * Implementation of the KTX Texture Loader.
  105402. * @hidden
  105403. */
  105404. export class _KTXTextureLoader implements IInternalTextureLoader {
  105405. /**
  105406. * Defines wether the loader supports cascade loading the different faces.
  105407. */
  105408. readonly supportCascades: boolean;
  105409. /**
  105410. * This returns if the loader support the current file information.
  105411. * @param extension defines the file extension of the file being loaded
  105412. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105413. * @param fallback defines the fallback internal texture if any
  105414. * @param isBase64 defines whether the texture is encoded as a base64
  105415. * @param isBuffer defines whether the texture data are stored as a buffer
  105416. * @returns true if the loader can load the specified file
  105417. */
  105418. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  105419. /**
  105420. * Transform the url before loading if required.
  105421. * @param rootUrl the url of the texture
  105422. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105423. * @returns the transformed texture
  105424. */
  105425. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  105426. /**
  105427. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  105428. * @param rootUrl the url of the texture
  105429. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105430. * @returns the fallback texture
  105431. */
  105432. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  105433. /**
  105434. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  105435. * @param data contains the texture data
  105436. * @param texture defines the BabylonJS internal texture
  105437. * @param createPolynomials will be true if polynomials have been requested
  105438. * @param onLoad defines the callback to trigger once the texture is ready
  105439. * @param onError defines the callback to trigger in case of error
  105440. */
  105441. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  105442. /**
  105443. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  105444. * @param data contains the texture data
  105445. * @param texture defines the BabylonJS internal texture
  105446. * @param callback defines the method to call once ready to upload
  105447. */
  105448. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  105449. }
  105450. }
  105451. declare module BABYLON {
  105452. /** @hidden */
  105453. export var _forceSceneHelpersToBundle: boolean;
  105454. interface Scene {
  105455. /**
  105456. * Creates a default light for the scene.
  105457. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  105458. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  105459. */
  105460. createDefaultLight(replace?: boolean): void;
  105461. /**
  105462. * Creates a default camera for the scene.
  105463. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  105464. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  105465. * @param replace has default false, when true replaces the active camera in the scene
  105466. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  105467. */
  105468. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  105469. /**
  105470. * Creates a default camera and a default light.
  105471. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  105472. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  105473. * @param replace has the default false, when true replaces the active camera/light in the scene
  105474. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  105475. */
  105476. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  105477. /**
  105478. * Creates a new sky box
  105479. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  105480. * @param environmentTexture defines the texture to use as environment texture
  105481. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  105482. * @param scale defines the overall scale of the skybox
  105483. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  105484. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  105485. * @returns a new mesh holding the sky box
  105486. */
  105487. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  105488. /**
  105489. * Creates a new environment
  105490. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  105491. * @param options defines the options you can use to configure the environment
  105492. * @returns the new EnvironmentHelper
  105493. */
  105494. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  105495. /**
  105496. * Creates a new VREXperienceHelper
  105497. * @see http://doc.babylonjs.com/how_to/webvr_helper
  105498. * @param webVROptions defines the options used to create the new VREXperienceHelper
  105499. * @returns a new VREXperienceHelper
  105500. */
  105501. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  105502. /**
  105503. * Creates a new XREXperienceHelper
  105504. * @see http://doc.babylonjs.com/how_to/webxr
  105505. * @returns a promise for a new XREXperienceHelper
  105506. */
  105507. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  105508. }
  105509. }
  105510. declare module BABYLON {
  105511. /**
  105512. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  105513. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  105514. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  105515. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  105516. */
  105517. export class VideoDome extends TransformNode {
  105518. /**
  105519. * Define the video source as a Monoscopic panoramic 360 video.
  105520. */
  105521. static readonly MODE_MONOSCOPIC: number;
  105522. /**
  105523. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  105524. */
  105525. static readonly MODE_TOPBOTTOM: number;
  105526. /**
  105527. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  105528. */
  105529. static readonly MODE_SIDEBYSIDE: number;
  105530. private _useDirectMapping;
  105531. /**
  105532. * The video texture being displayed on the sphere
  105533. */
  105534. protected _videoTexture: VideoTexture;
  105535. /**
  105536. * Gets the video texture being displayed on the sphere
  105537. */
  105538. readonly videoTexture: VideoTexture;
  105539. /**
  105540. * The skybox material
  105541. */
  105542. protected _material: BackgroundMaterial;
  105543. /**
  105544. * The surface used for the skybox
  105545. */
  105546. protected _mesh: Mesh;
  105547. /**
  105548. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  105549. * Also see the options.resolution property.
  105550. */
  105551. fovMultiplier: number;
  105552. private _videoMode;
  105553. /**
  105554. * Gets or set the current video mode for the video. It can be:
  105555. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  105556. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  105557. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  105558. */
  105559. videoMode: number;
  105560. /**
  105561. * Oberserver used in Stereoscopic VR Mode.
  105562. */
  105563. private _onBeforeCameraRenderObserver;
  105564. /**
  105565. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  105566. * @param name Element's name, child elements will append suffixes for their own names.
  105567. * @param urlsOrVideo defines the url(s) or the video element to use
  105568. * @param options An object containing optional or exposed sub element properties
  105569. */
  105570. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  105571. resolution?: number;
  105572. clickToPlay?: boolean;
  105573. autoPlay?: boolean;
  105574. loop?: boolean;
  105575. size?: number;
  105576. poster?: string;
  105577. faceForward?: boolean;
  105578. useDirectMapping?: boolean;
  105579. }, scene: Scene);
  105580. private _changeVideoMode;
  105581. /**
  105582. * Releases resources associated with this node.
  105583. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  105584. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  105585. */
  105586. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  105587. }
  105588. }
  105589. declare module BABYLON {
  105590. /**
  105591. * This class can be used to get instrumentation data from a Babylon engine
  105592. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  105593. */
  105594. export class EngineInstrumentation implements IDisposable {
  105595. /**
  105596. * Define the instrumented engine.
  105597. */
  105598. engine: Engine;
  105599. private _captureGPUFrameTime;
  105600. private _gpuFrameTimeToken;
  105601. private _gpuFrameTime;
  105602. private _captureShaderCompilationTime;
  105603. private _shaderCompilationTime;
  105604. private _onBeginFrameObserver;
  105605. private _onEndFrameObserver;
  105606. private _onBeforeShaderCompilationObserver;
  105607. private _onAfterShaderCompilationObserver;
  105608. /**
  105609. * Gets the perf counter used for GPU frame time
  105610. */
  105611. readonly gpuFrameTimeCounter: PerfCounter;
  105612. /**
  105613. * Gets the GPU frame time capture status
  105614. */
  105615. /**
  105616. * Enable or disable the GPU frame time capture
  105617. */
  105618. captureGPUFrameTime: boolean;
  105619. /**
  105620. * Gets the perf counter used for shader compilation time
  105621. */
  105622. readonly shaderCompilationTimeCounter: PerfCounter;
  105623. /**
  105624. * Gets the shader compilation time capture status
  105625. */
  105626. /**
  105627. * Enable or disable the shader compilation time capture
  105628. */
  105629. captureShaderCompilationTime: boolean;
  105630. /**
  105631. * Instantiates a new engine instrumentation.
  105632. * This class can be used to get instrumentation data from a Babylon engine
  105633. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  105634. * @param engine Defines the engine to instrument
  105635. */
  105636. constructor(
  105637. /**
  105638. * Define the instrumented engine.
  105639. */
  105640. engine: Engine);
  105641. /**
  105642. * Dispose and release associated resources.
  105643. */
  105644. dispose(): void;
  105645. }
  105646. }
  105647. declare module BABYLON {
  105648. /**
  105649. * This class can be used to get instrumentation data from a Babylon engine
  105650. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  105651. */
  105652. export class SceneInstrumentation implements IDisposable {
  105653. /**
  105654. * Defines the scene to instrument
  105655. */
  105656. scene: Scene;
  105657. private _captureActiveMeshesEvaluationTime;
  105658. private _activeMeshesEvaluationTime;
  105659. private _captureRenderTargetsRenderTime;
  105660. private _renderTargetsRenderTime;
  105661. private _captureFrameTime;
  105662. private _frameTime;
  105663. private _captureRenderTime;
  105664. private _renderTime;
  105665. private _captureInterFrameTime;
  105666. private _interFrameTime;
  105667. private _captureParticlesRenderTime;
  105668. private _particlesRenderTime;
  105669. private _captureSpritesRenderTime;
  105670. private _spritesRenderTime;
  105671. private _capturePhysicsTime;
  105672. private _physicsTime;
  105673. private _captureAnimationsTime;
  105674. private _animationsTime;
  105675. private _captureCameraRenderTime;
  105676. private _cameraRenderTime;
  105677. private _onBeforeActiveMeshesEvaluationObserver;
  105678. private _onAfterActiveMeshesEvaluationObserver;
  105679. private _onBeforeRenderTargetsRenderObserver;
  105680. private _onAfterRenderTargetsRenderObserver;
  105681. private _onAfterRenderObserver;
  105682. private _onBeforeDrawPhaseObserver;
  105683. private _onAfterDrawPhaseObserver;
  105684. private _onBeforeAnimationsObserver;
  105685. private _onBeforeParticlesRenderingObserver;
  105686. private _onAfterParticlesRenderingObserver;
  105687. private _onBeforeSpritesRenderingObserver;
  105688. private _onAfterSpritesRenderingObserver;
  105689. private _onBeforePhysicsObserver;
  105690. private _onAfterPhysicsObserver;
  105691. private _onAfterAnimationsObserver;
  105692. private _onBeforeCameraRenderObserver;
  105693. private _onAfterCameraRenderObserver;
  105694. /**
  105695. * Gets the perf counter used for active meshes evaluation time
  105696. */
  105697. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  105698. /**
  105699. * Gets the active meshes evaluation time capture status
  105700. */
  105701. /**
  105702. * Enable or disable the active meshes evaluation time capture
  105703. */
  105704. captureActiveMeshesEvaluationTime: boolean;
  105705. /**
  105706. * Gets the perf counter used for render targets render time
  105707. */
  105708. readonly renderTargetsRenderTimeCounter: PerfCounter;
  105709. /**
  105710. * Gets the render targets render time capture status
  105711. */
  105712. /**
  105713. * Enable or disable the render targets render time capture
  105714. */
  105715. captureRenderTargetsRenderTime: boolean;
  105716. /**
  105717. * Gets the perf counter used for particles render time
  105718. */
  105719. readonly particlesRenderTimeCounter: PerfCounter;
  105720. /**
  105721. * Gets the particles render time capture status
  105722. */
  105723. /**
  105724. * Enable or disable the particles render time capture
  105725. */
  105726. captureParticlesRenderTime: boolean;
  105727. /**
  105728. * Gets the perf counter used for sprites render time
  105729. */
  105730. readonly spritesRenderTimeCounter: PerfCounter;
  105731. /**
  105732. * Gets the sprites render time capture status
  105733. */
  105734. /**
  105735. * Enable or disable the sprites render time capture
  105736. */
  105737. captureSpritesRenderTime: boolean;
  105738. /**
  105739. * Gets the perf counter used for physics time
  105740. */
  105741. readonly physicsTimeCounter: PerfCounter;
  105742. /**
  105743. * Gets the physics time capture status
  105744. */
  105745. /**
  105746. * Enable or disable the physics time capture
  105747. */
  105748. capturePhysicsTime: boolean;
  105749. /**
  105750. * Gets the perf counter used for animations time
  105751. */
  105752. readonly animationsTimeCounter: PerfCounter;
  105753. /**
  105754. * Gets the animations time capture status
  105755. */
  105756. /**
  105757. * Enable or disable the animations time capture
  105758. */
  105759. captureAnimationsTime: boolean;
  105760. /**
  105761. * Gets the perf counter used for frame time capture
  105762. */
  105763. readonly frameTimeCounter: PerfCounter;
  105764. /**
  105765. * Gets the frame time capture status
  105766. */
  105767. /**
  105768. * Enable or disable the frame time capture
  105769. */
  105770. captureFrameTime: boolean;
  105771. /**
  105772. * Gets the perf counter used for inter-frames time capture
  105773. */
  105774. readonly interFrameTimeCounter: PerfCounter;
  105775. /**
  105776. * Gets the inter-frames time capture status
  105777. */
  105778. /**
  105779. * Enable or disable the inter-frames time capture
  105780. */
  105781. captureInterFrameTime: boolean;
  105782. /**
  105783. * Gets the perf counter used for render time capture
  105784. */
  105785. readonly renderTimeCounter: PerfCounter;
  105786. /**
  105787. * Gets the render time capture status
  105788. */
  105789. /**
  105790. * Enable or disable the render time capture
  105791. */
  105792. captureRenderTime: boolean;
  105793. /**
  105794. * Gets the perf counter used for camera render time capture
  105795. */
  105796. readonly cameraRenderTimeCounter: PerfCounter;
  105797. /**
  105798. * Gets the camera render time capture status
  105799. */
  105800. /**
  105801. * Enable or disable the camera render time capture
  105802. */
  105803. captureCameraRenderTime: boolean;
  105804. /**
  105805. * Gets the perf counter used for draw calls
  105806. */
  105807. readonly drawCallsCounter: PerfCounter;
  105808. /**
  105809. * Instantiates a new scene instrumentation.
  105810. * This class can be used to get instrumentation data from a Babylon engine
  105811. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  105812. * @param scene Defines the scene to instrument
  105813. */
  105814. constructor(
  105815. /**
  105816. * Defines the scene to instrument
  105817. */
  105818. scene: Scene);
  105819. /**
  105820. * Dispose and release associated resources.
  105821. */
  105822. dispose(): void;
  105823. }
  105824. }
  105825. declare module BABYLON {
  105826. /** @hidden */
  105827. export var glowMapGenerationPixelShader: {
  105828. name: string;
  105829. shader: string;
  105830. };
  105831. }
  105832. declare module BABYLON {
  105833. /** @hidden */
  105834. export var glowMapGenerationVertexShader: {
  105835. name: string;
  105836. shader: string;
  105837. };
  105838. }
  105839. declare module BABYLON {
  105840. /**
  105841. * Effect layer options. This helps customizing the behaviour
  105842. * of the effect layer.
  105843. */
  105844. export interface IEffectLayerOptions {
  105845. /**
  105846. * Multiplication factor apply to the canvas size to compute the render target size
  105847. * used to generated the objects (the smaller the faster).
  105848. */
  105849. mainTextureRatio: number;
  105850. /**
  105851. * Enforces a fixed size texture to ensure effect stability across devices.
  105852. */
  105853. mainTextureFixedSize?: number;
  105854. /**
  105855. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  105856. */
  105857. alphaBlendingMode: number;
  105858. /**
  105859. * The camera attached to the layer.
  105860. */
  105861. camera: Nullable<Camera>;
  105862. /**
  105863. * The rendering group to draw the layer in.
  105864. */
  105865. renderingGroupId: number;
  105866. }
  105867. /**
  105868. * The effect layer Helps adding post process effect blended with the main pass.
  105869. *
  105870. * This can be for instance use to generate glow or higlight effects on the scene.
  105871. *
  105872. * The effect layer class can not be used directly and is intented to inherited from to be
  105873. * customized per effects.
  105874. */
  105875. export abstract class EffectLayer {
  105876. private _vertexBuffers;
  105877. private _indexBuffer;
  105878. private _cachedDefines;
  105879. private _effectLayerMapGenerationEffect;
  105880. private _effectLayerOptions;
  105881. private _mergeEffect;
  105882. protected _scene: Scene;
  105883. protected _engine: Engine;
  105884. protected _maxSize: number;
  105885. protected _mainTextureDesiredSize: ISize;
  105886. protected _mainTexture: RenderTargetTexture;
  105887. protected _shouldRender: boolean;
  105888. protected _postProcesses: PostProcess[];
  105889. protected _textures: BaseTexture[];
  105890. protected _emissiveTextureAndColor: {
  105891. texture: Nullable<BaseTexture>;
  105892. color: Color4;
  105893. };
  105894. /**
  105895. * The name of the layer
  105896. */
  105897. name: string;
  105898. /**
  105899. * The clear color of the texture used to generate the glow map.
  105900. */
  105901. neutralColor: Color4;
  105902. /**
  105903. * Specifies wether the highlight layer is enabled or not.
  105904. */
  105905. isEnabled: boolean;
  105906. /**
  105907. * Gets the camera attached to the layer.
  105908. */
  105909. readonly camera: Nullable<Camera>;
  105910. /**
  105911. * Gets the rendering group id the layer should render in.
  105912. */
  105913. readonly renderingGroupId: number;
  105914. /**
  105915. * An event triggered when the effect layer has been disposed.
  105916. */
  105917. onDisposeObservable: Observable<EffectLayer>;
  105918. /**
  105919. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  105920. */
  105921. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  105922. /**
  105923. * An event triggered when the generated texture is being merged in the scene.
  105924. */
  105925. onBeforeComposeObservable: Observable<EffectLayer>;
  105926. /**
  105927. * An event triggered when the generated texture has been merged in the scene.
  105928. */
  105929. onAfterComposeObservable: Observable<EffectLayer>;
  105930. /**
  105931. * An event triggered when the efffect layer changes its size.
  105932. */
  105933. onSizeChangedObservable: Observable<EffectLayer>;
  105934. /** @hidden */
  105935. static _SceneComponentInitialization: (scene: Scene) => void;
  105936. /**
  105937. * Instantiates a new effect Layer and references it in the scene.
  105938. * @param name The name of the layer
  105939. * @param scene The scene to use the layer in
  105940. */
  105941. constructor(
  105942. /** The Friendly of the effect in the scene */
  105943. name: string, scene: Scene);
  105944. /**
  105945. * Get the effect name of the layer.
  105946. * @return The effect name
  105947. */
  105948. abstract getEffectName(): string;
  105949. /**
  105950. * Checks for the readiness of the element composing the layer.
  105951. * @param subMesh the mesh to check for
  105952. * @param useInstances specify wether or not to use instances to render the mesh
  105953. * @return true if ready otherwise, false
  105954. */
  105955. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  105956. /**
  105957. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  105958. * @returns true if the effect requires stencil during the main canvas render pass.
  105959. */
  105960. abstract needStencil(): boolean;
  105961. /**
  105962. * Create the merge effect. This is the shader use to blit the information back
  105963. * to the main canvas at the end of the scene rendering.
  105964. * @returns The effect containing the shader used to merge the effect on the main canvas
  105965. */
  105966. protected abstract _createMergeEffect(): Effect;
  105967. /**
  105968. * Creates the render target textures and post processes used in the effect layer.
  105969. */
  105970. protected abstract _createTextureAndPostProcesses(): void;
  105971. /**
  105972. * Implementation specific of rendering the generating effect on the main canvas.
  105973. * @param effect The effect used to render through
  105974. */
  105975. protected abstract _internalRender(effect: Effect): void;
  105976. /**
  105977. * Sets the required values for both the emissive texture and and the main color.
  105978. */
  105979. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  105980. /**
  105981. * Free any resources and references associated to a mesh.
  105982. * Internal use
  105983. * @param mesh The mesh to free.
  105984. */
  105985. abstract _disposeMesh(mesh: Mesh): void;
  105986. /**
  105987. * Serializes this layer (Glow or Highlight for example)
  105988. * @returns a serialized layer object
  105989. */
  105990. abstract serialize?(): any;
  105991. /**
  105992. * Initializes the effect layer with the required options.
  105993. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  105994. */
  105995. protected _init(options: Partial<IEffectLayerOptions>): void;
  105996. /**
  105997. * Generates the index buffer of the full screen quad blending to the main canvas.
  105998. */
  105999. private _generateIndexBuffer;
  106000. /**
  106001. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  106002. */
  106003. private _genrateVertexBuffer;
  106004. /**
  106005. * Sets the main texture desired size which is the closest power of two
  106006. * of the engine canvas size.
  106007. */
  106008. private _setMainTextureSize;
  106009. /**
  106010. * Creates the main texture for the effect layer.
  106011. */
  106012. protected _createMainTexture(): void;
  106013. /**
  106014. * Adds specific effects defines.
  106015. * @param defines The defines to add specifics to.
  106016. */
  106017. protected _addCustomEffectDefines(defines: string[]): void;
  106018. /**
  106019. * Checks for the readiness of the element composing the layer.
  106020. * @param subMesh the mesh to check for
  106021. * @param useInstances specify wether or not to use instances to render the mesh
  106022. * @param emissiveTexture the associated emissive texture used to generate the glow
  106023. * @return true if ready otherwise, false
  106024. */
  106025. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  106026. /**
  106027. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  106028. */
  106029. render(): void;
  106030. /**
  106031. * Determine if a given mesh will be used in the current effect.
  106032. * @param mesh mesh to test
  106033. * @returns true if the mesh will be used
  106034. */
  106035. hasMesh(mesh: AbstractMesh): boolean;
  106036. /**
  106037. * Returns true if the layer contains information to display, otherwise false.
  106038. * @returns true if the glow layer should be rendered
  106039. */
  106040. shouldRender(): boolean;
  106041. /**
  106042. * Returns true if the mesh should render, otherwise false.
  106043. * @param mesh The mesh to render
  106044. * @returns true if it should render otherwise false
  106045. */
  106046. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  106047. /**
  106048. * Returns true if the mesh can be rendered, otherwise false.
  106049. * @param mesh The mesh to render
  106050. * @param material The material used on the mesh
  106051. * @returns true if it can be rendered otherwise false
  106052. */
  106053. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  106054. /**
  106055. * Returns true if the mesh should render, otherwise false.
  106056. * @param mesh The mesh to render
  106057. * @returns true if it should render otherwise false
  106058. */
  106059. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  106060. /**
  106061. * Renders the submesh passed in parameter to the generation map.
  106062. */
  106063. protected _renderSubMesh(subMesh: SubMesh): void;
  106064. /**
  106065. * Rebuild the required buffers.
  106066. * @hidden Internal use only.
  106067. */
  106068. _rebuild(): void;
  106069. /**
  106070. * Dispose only the render target textures and post process.
  106071. */
  106072. private _disposeTextureAndPostProcesses;
  106073. /**
  106074. * Dispose the highlight layer and free resources.
  106075. */
  106076. dispose(): void;
  106077. /**
  106078. * Gets the class name of the effect layer
  106079. * @returns the string with the class name of the effect layer
  106080. */
  106081. getClassName(): string;
  106082. /**
  106083. * Creates an effect layer from parsed effect layer data
  106084. * @param parsedEffectLayer defines effect layer data
  106085. * @param scene defines the current scene
  106086. * @param rootUrl defines the root URL containing the effect layer information
  106087. * @returns a parsed effect Layer
  106088. */
  106089. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  106090. }
  106091. }
  106092. declare module BABYLON {
  106093. interface AbstractScene {
  106094. /**
  106095. * The list of effect layers (highlights/glow) added to the scene
  106096. * @see http://doc.babylonjs.com/how_to/highlight_layer
  106097. * @see http://doc.babylonjs.com/how_to/glow_layer
  106098. */
  106099. effectLayers: Array<EffectLayer>;
  106100. /**
  106101. * Removes the given effect layer from this scene.
  106102. * @param toRemove defines the effect layer to remove
  106103. * @returns the index of the removed effect layer
  106104. */
  106105. removeEffectLayer(toRemove: EffectLayer): number;
  106106. /**
  106107. * Adds the given effect layer to this scene
  106108. * @param newEffectLayer defines the effect layer to add
  106109. */
  106110. addEffectLayer(newEffectLayer: EffectLayer): void;
  106111. }
  106112. /**
  106113. * Defines the layer scene component responsible to manage any effect layers
  106114. * in a given scene.
  106115. */
  106116. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  106117. /**
  106118. * The component name helpfull to identify the component in the list of scene components.
  106119. */
  106120. readonly name: string;
  106121. /**
  106122. * The scene the component belongs to.
  106123. */
  106124. scene: Scene;
  106125. private _engine;
  106126. private _renderEffects;
  106127. private _needStencil;
  106128. private _previousStencilState;
  106129. /**
  106130. * Creates a new instance of the component for the given scene
  106131. * @param scene Defines the scene to register the component in
  106132. */
  106133. constructor(scene: Scene);
  106134. /**
  106135. * Registers the component in a given scene
  106136. */
  106137. register(): void;
  106138. /**
  106139. * Rebuilds the elements related to this component in case of
  106140. * context lost for instance.
  106141. */
  106142. rebuild(): void;
  106143. /**
  106144. * Serializes the component data to the specified json object
  106145. * @param serializationObject The object to serialize to
  106146. */
  106147. serialize(serializationObject: any): void;
  106148. /**
  106149. * Adds all the element from the container to the scene
  106150. * @param container the container holding the elements
  106151. */
  106152. addFromContainer(container: AbstractScene): void;
  106153. /**
  106154. * Removes all the elements in the container from the scene
  106155. * @param container contains the elements to remove
  106156. * @param dispose if the removed element should be disposed (default: false)
  106157. */
  106158. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  106159. /**
  106160. * Disposes the component and the associated ressources.
  106161. */
  106162. dispose(): void;
  106163. private _isReadyForMesh;
  106164. private _renderMainTexture;
  106165. private _setStencil;
  106166. private _setStencilBack;
  106167. private _draw;
  106168. private _drawCamera;
  106169. private _drawRenderingGroup;
  106170. }
  106171. }
  106172. declare module BABYLON {
  106173. /** @hidden */
  106174. export var glowMapMergePixelShader: {
  106175. name: string;
  106176. shader: string;
  106177. };
  106178. }
  106179. declare module BABYLON {
  106180. /** @hidden */
  106181. export var glowMapMergeVertexShader: {
  106182. name: string;
  106183. shader: string;
  106184. };
  106185. }
  106186. declare module BABYLON {
  106187. interface AbstractScene {
  106188. /**
  106189. * Return a the first highlight layer of the scene with a given name.
  106190. * @param name The name of the highlight layer to look for.
  106191. * @return The highlight layer if found otherwise null.
  106192. */
  106193. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  106194. }
  106195. /**
  106196. * Glow layer options. This helps customizing the behaviour
  106197. * of the glow layer.
  106198. */
  106199. export interface IGlowLayerOptions {
  106200. /**
  106201. * Multiplication factor apply to the canvas size to compute the render target size
  106202. * used to generated the glowing objects (the smaller the faster).
  106203. */
  106204. mainTextureRatio: number;
  106205. /**
  106206. * Enforces a fixed size texture to ensure resize independant blur.
  106207. */
  106208. mainTextureFixedSize?: number;
  106209. /**
  106210. * How big is the kernel of the blur texture.
  106211. */
  106212. blurKernelSize: number;
  106213. /**
  106214. * The camera attached to the layer.
  106215. */
  106216. camera: Nullable<Camera>;
  106217. /**
  106218. * Enable MSAA by chosing the number of samples.
  106219. */
  106220. mainTextureSamples?: number;
  106221. /**
  106222. * The rendering group to draw the layer in.
  106223. */
  106224. renderingGroupId: number;
  106225. }
  106226. /**
  106227. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  106228. *
  106229. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  106230. * glowy meshes to your scene.
  106231. *
  106232. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  106233. */
  106234. export class GlowLayer extends EffectLayer {
  106235. /**
  106236. * Effect Name of the layer.
  106237. */
  106238. static readonly EffectName: string;
  106239. /**
  106240. * The default blur kernel size used for the glow.
  106241. */
  106242. static DefaultBlurKernelSize: number;
  106243. /**
  106244. * The default texture size ratio used for the glow.
  106245. */
  106246. static DefaultTextureRatio: number;
  106247. /**
  106248. * Sets the kernel size of the blur.
  106249. */
  106250. /**
  106251. * Gets the kernel size of the blur.
  106252. */
  106253. blurKernelSize: number;
  106254. /**
  106255. * Sets the glow intensity.
  106256. */
  106257. /**
  106258. * Gets the glow intensity.
  106259. */
  106260. intensity: number;
  106261. private _options;
  106262. private _intensity;
  106263. private _horizontalBlurPostprocess1;
  106264. private _verticalBlurPostprocess1;
  106265. private _horizontalBlurPostprocess2;
  106266. private _verticalBlurPostprocess2;
  106267. private _blurTexture1;
  106268. private _blurTexture2;
  106269. private _postProcesses1;
  106270. private _postProcesses2;
  106271. private _includedOnlyMeshes;
  106272. private _excludedMeshes;
  106273. /**
  106274. * Callback used to let the user override the color selection on a per mesh basis
  106275. */
  106276. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  106277. /**
  106278. * Callback used to let the user override the texture selection on a per mesh basis
  106279. */
  106280. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  106281. /**
  106282. * Instantiates a new glow Layer and references it to the scene.
  106283. * @param name The name of the layer
  106284. * @param scene The scene to use the layer in
  106285. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  106286. */
  106287. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  106288. /**
  106289. * Get the effect name of the layer.
  106290. * @return The effect name
  106291. */
  106292. getEffectName(): string;
  106293. /**
  106294. * Create the merge effect. This is the shader use to blit the information back
  106295. * to the main canvas at the end of the scene rendering.
  106296. */
  106297. protected _createMergeEffect(): Effect;
  106298. /**
  106299. * Creates the render target textures and post processes used in the glow layer.
  106300. */
  106301. protected _createTextureAndPostProcesses(): void;
  106302. /**
  106303. * Checks for the readiness of the element composing the layer.
  106304. * @param subMesh the mesh to check for
  106305. * @param useInstances specify wether or not to use instances to render the mesh
  106306. * @param emissiveTexture the associated emissive texture used to generate the glow
  106307. * @return true if ready otherwise, false
  106308. */
  106309. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  106310. /**
  106311. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  106312. */
  106313. needStencil(): boolean;
  106314. /**
  106315. * Returns true if the mesh can be rendered, otherwise false.
  106316. * @param mesh The mesh to render
  106317. * @param material The material used on the mesh
  106318. * @returns true if it can be rendered otherwise false
  106319. */
  106320. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  106321. /**
  106322. * Implementation specific of rendering the generating effect on the main canvas.
  106323. * @param effect The effect used to render through
  106324. */
  106325. protected _internalRender(effect: Effect): void;
  106326. /**
  106327. * Sets the required values for both the emissive texture and and the main color.
  106328. */
  106329. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  106330. /**
  106331. * Returns true if the mesh should render, otherwise false.
  106332. * @param mesh The mesh to render
  106333. * @returns true if it should render otherwise false
  106334. */
  106335. protected _shouldRenderMesh(mesh: Mesh): boolean;
  106336. /**
  106337. * Adds specific effects defines.
  106338. * @param defines The defines to add specifics to.
  106339. */
  106340. protected _addCustomEffectDefines(defines: string[]): void;
  106341. /**
  106342. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  106343. * @param mesh The mesh to exclude from the glow layer
  106344. */
  106345. addExcludedMesh(mesh: Mesh): void;
  106346. /**
  106347. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  106348. * @param mesh The mesh to remove
  106349. */
  106350. removeExcludedMesh(mesh: Mesh): void;
  106351. /**
  106352. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  106353. * @param mesh The mesh to include in the glow layer
  106354. */
  106355. addIncludedOnlyMesh(mesh: Mesh): void;
  106356. /**
  106357. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  106358. * @param mesh The mesh to remove
  106359. */
  106360. removeIncludedOnlyMesh(mesh: Mesh): void;
  106361. /**
  106362. * Determine if a given mesh will be used in the glow layer
  106363. * @param mesh The mesh to test
  106364. * @returns true if the mesh will be highlighted by the current glow layer
  106365. */
  106366. hasMesh(mesh: AbstractMesh): boolean;
  106367. /**
  106368. * Free any resources and references associated to a mesh.
  106369. * Internal use
  106370. * @param mesh The mesh to free.
  106371. * @hidden
  106372. */
  106373. _disposeMesh(mesh: Mesh): void;
  106374. /**
  106375. * Gets the class name of the effect layer
  106376. * @returns the string with the class name of the effect layer
  106377. */
  106378. getClassName(): string;
  106379. /**
  106380. * Serializes this glow layer
  106381. * @returns a serialized glow layer object
  106382. */
  106383. serialize(): any;
  106384. /**
  106385. * Creates a Glow Layer from parsed glow layer data
  106386. * @param parsedGlowLayer defines glow layer data
  106387. * @param scene defines the current scene
  106388. * @param rootUrl defines the root URL containing the glow layer information
  106389. * @returns a parsed Glow Layer
  106390. */
  106391. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  106392. }
  106393. }
  106394. declare module BABYLON {
  106395. /** @hidden */
  106396. export var glowBlurPostProcessPixelShader: {
  106397. name: string;
  106398. shader: string;
  106399. };
  106400. }
  106401. declare module BABYLON {
  106402. interface AbstractScene {
  106403. /**
  106404. * Return a the first highlight layer of the scene with a given name.
  106405. * @param name The name of the highlight layer to look for.
  106406. * @return The highlight layer if found otherwise null.
  106407. */
  106408. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  106409. }
  106410. /**
  106411. * Highlight layer options. This helps customizing the behaviour
  106412. * of the highlight layer.
  106413. */
  106414. export interface IHighlightLayerOptions {
  106415. /**
  106416. * Multiplication factor apply to the canvas size to compute the render target size
  106417. * used to generated the glowing objects (the smaller the faster).
  106418. */
  106419. mainTextureRatio: number;
  106420. /**
  106421. * Enforces a fixed size texture to ensure resize independant blur.
  106422. */
  106423. mainTextureFixedSize?: number;
  106424. /**
  106425. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  106426. * of the picture to blur (the smaller the faster).
  106427. */
  106428. blurTextureSizeRatio: number;
  106429. /**
  106430. * How big in texel of the blur texture is the vertical blur.
  106431. */
  106432. blurVerticalSize: number;
  106433. /**
  106434. * How big in texel of the blur texture is the horizontal blur.
  106435. */
  106436. blurHorizontalSize: number;
  106437. /**
  106438. * Alpha blending mode used to apply the blur. Default is combine.
  106439. */
  106440. alphaBlendingMode: number;
  106441. /**
  106442. * The camera attached to the layer.
  106443. */
  106444. camera: Nullable<Camera>;
  106445. /**
  106446. * Should we display highlight as a solid stroke?
  106447. */
  106448. isStroke?: boolean;
  106449. /**
  106450. * The rendering group to draw the layer in.
  106451. */
  106452. renderingGroupId: number;
  106453. }
  106454. /**
  106455. * The highlight layer Helps adding a glow effect around a mesh.
  106456. *
  106457. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  106458. * glowy meshes to your scene.
  106459. *
  106460. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  106461. */
  106462. export class HighlightLayer extends EffectLayer {
  106463. name: string;
  106464. /**
  106465. * Effect Name of the highlight layer.
  106466. */
  106467. static readonly EffectName: string;
  106468. /**
  106469. * The neutral color used during the preparation of the glow effect.
  106470. * This is black by default as the blend operation is a blend operation.
  106471. */
  106472. static NeutralColor: Color4;
  106473. /**
  106474. * Stencil value used for glowing meshes.
  106475. */
  106476. static GlowingMeshStencilReference: number;
  106477. /**
  106478. * Stencil value used for the other meshes in the scene.
  106479. */
  106480. static NormalMeshStencilReference: number;
  106481. /**
  106482. * Specifies whether or not the inner glow is ACTIVE in the layer.
  106483. */
  106484. innerGlow: boolean;
  106485. /**
  106486. * Specifies whether or not the outer glow is ACTIVE in the layer.
  106487. */
  106488. outerGlow: boolean;
  106489. /**
  106490. * Specifies the horizontal size of the blur.
  106491. */
  106492. /**
  106493. * Gets the horizontal size of the blur.
  106494. */
  106495. blurHorizontalSize: number;
  106496. /**
  106497. * Specifies the vertical size of the blur.
  106498. */
  106499. /**
  106500. * Gets the vertical size of the blur.
  106501. */
  106502. blurVerticalSize: number;
  106503. /**
  106504. * An event triggered when the highlight layer is being blurred.
  106505. */
  106506. onBeforeBlurObservable: Observable<HighlightLayer>;
  106507. /**
  106508. * An event triggered when the highlight layer has been blurred.
  106509. */
  106510. onAfterBlurObservable: Observable<HighlightLayer>;
  106511. private _instanceGlowingMeshStencilReference;
  106512. private _options;
  106513. private _downSamplePostprocess;
  106514. private _horizontalBlurPostprocess;
  106515. private _verticalBlurPostprocess;
  106516. private _blurTexture;
  106517. private _meshes;
  106518. private _excludedMeshes;
  106519. /**
  106520. * Instantiates a new highlight Layer and references it to the scene..
  106521. * @param name The name of the layer
  106522. * @param scene The scene to use the layer in
  106523. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  106524. */
  106525. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  106526. /**
  106527. * Get the effect name of the layer.
  106528. * @return The effect name
  106529. */
  106530. getEffectName(): string;
  106531. /**
  106532. * Create the merge effect. This is the shader use to blit the information back
  106533. * to the main canvas at the end of the scene rendering.
  106534. */
  106535. protected _createMergeEffect(): Effect;
  106536. /**
  106537. * Creates the render target textures and post processes used in the highlight layer.
  106538. */
  106539. protected _createTextureAndPostProcesses(): void;
  106540. /**
  106541. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  106542. */
  106543. needStencil(): boolean;
  106544. /**
  106545. * Checks for the readiness of the element composing the layer.
  106546. * @param subMesh the mesh to check for
  106547. * @param useInstances specify wether or not to use instances to render the mesh
  106548. * @param emissiveTexture the associated emissive texture used to generate the glow
  106549. * @return true if ready otherwise, false
  106550. */
  106551. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  106552. /**
  106553. * Implementation specific of rendering the generating effect on the main canvas.
  106554. * @param effect The effect used to render through
  106555. */
  106556. protected _internalRender(effect: Effect): void;
  106557. /**
  106558. * Returns true if the layer contains information to display, otherwise false.
  106559. */
  106560. shouldRender(): boolean;
  106561. /**
  106562. * Returns true if the mesh should render, otherwise false.
  106563. * @param mesh The mesh to render
  106564. * @returns true if it should render otherwise false
  106565. */
  106566. protected _shouldRenderMesh(mesh: Mesh): boolean;
  106567. /**
  106568. * Sets the required values for both the emissive texture and and the main color.
  106569. */
  106570. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  106571. /**
  106572. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  106573. * @param mesh The mesh to exclude from the highlight layer
  106574. */
  106575. addExcludedMesh(mesh: Mesh): void;
  106576. /**
  106577. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  106578. * @param mesh The mesh to highlight
  106579. */
  106580. removeExcludedMesh(mesh: Mesh): void;
  106581. /**
  106582. * Determine if a given mesh will be highlighted by the current HighlightLayer
  106583. * @param mesh mesh to test
  106584. * @returns true if the mesh will be highlighted by the current HighlightLayer
  106585. */
  106586. hasMesh(mesh: AbstractMesh): boolean;
  106587. /**
  106588. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  106589. * @param mesh The mesh to highlight
  106590. * @param color The color of the highlight
  106591. * @param glowEmissiveOnly Extract the glow from the emissive texture
  106592. */
  106593. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  106594. /**
  106595. * Remove a mesh from the highlight layer in order to make it stop glowing.
  106596. * @param mesh The mesh to highlight
  106597. */
  106598. removeMesh(mesh: Mesh): void;
  106599. /**
  106600. * Force the stencil to the normal expected value for none glowing parts
  106601. */
  106602. private _defaultStencilReference;
  106603. /**
  106604. * Free any resources and references associated to a mesh.
  106605. * Internal use
  106606. * @param mesh The mesh to free.
  106607. * @hidden
  106608. */
  106609. _disposeMesh(mesh: Mesh): void;
  106610. /**
  106611. * Dispose the highlight layer and free resources.
  106612. */
  106613. dispose(): void;
  106614. /**
  106615. * Gets the class name of the effect layer
  106616. * @returns the string with the class name of the effect layer
  106617. */
  106618. getClassName(): string;
  106619. /**
  106620. * Serializes this Highlight layer
  106621. * @returns a serialized Highlight layer object
  106622. */
  106623. serialize(): any;
  106624. /**
  106625. * Creates a Highlight layer from parsed Highlight layer data
  106626. * @param parsedHightlightLayer defines the Highlight layer data
  106627. * @param scene defines the current scene
  106628. * @param rootUrl defines the root URL containing the Highlight layer information
  106629. * @returns a parsed Highlight layer
  106630. */
  106631. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  106632. }
  106633. }
  106634. declare module BABYLON {
  106635. /** @hidden */
  106636. export var lensFlarePixelShader: {
  106637. name: string;
  106638. shader: string;
  106639. };
  106640. }
  106641. declare module BABYLON {
  106642. /** @hidden */
  106643. export var lensFlareVertexShader: {
  106644. name: string;
  106645. shader: string;
  106646. };
  106647. }
  106648. declare module BABYLON {
  106649. /**
  106650. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  106651. * It is usually composed of several `lensFlare`.
  106652. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106653. */
  106654. export class LensFlareSystem {
  106655. /**
  106656. * Define the name of the lens flare system
  106657. */
  106658. name: string;
  106659. /**
  106660. * List of lens flares used in this system.
  106661. */
  106662. lensFlares: LensFlare[];
  106663. /**
  106664. * Define a limit from the border the lens flare can be visible.
  106665. */
  106666. borderLimit: number;
  106667. /**
  106668. * Define a viewport border we do not want to see the lens flare in.
  106669. */
  106670. viewportBorder: number;
  106671. /**
  106672. * Define a predicate which could limit the list of meshes able to occlude the effect.
  106673. */
  106674. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  106675. /**
  106676. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  106677. */
  106678. layerMask: number;
  106679. /**
  106680. * Define the id of the lens flare system in the scene.
  106681. * (equal to name by default)
  106682. */
  106683. id: string;
  106684. private _scene;
  106685. private _emitter;
  106686. private _vertexBuffers;
  106687. private _indexBuffer;
  106688. private _effect;
  106689. private _positionX;
  106690. private _positionY;
  106691. private _isEnabled;
  106692. /** @hidden */
  106693. static _SceneComponentInitialization: (scene: Scene) => void;
  106694. /**
  106695. * Instantiates a lens flare system.
  106696. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  106697. * It is usually composed of several `lensFlare`.
  106698. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106699. * @param name Define the name of the lens flare system in the scene
  106700. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  106701. * @param scene Define the scene the lens flare system belongs to
  106702. */
  106703. constructor(
  106704. /**
  106705. * Define the name of the lens flare system
  106706. */
  106707. name: string, emitter: any, scene: Scene);
  106708. /**
  106709. * Define if the lens flare system is enabled.
  106710. */
  106711. isEnabled: boolean;
  106712. /**
  106713. * Get the scene the effects belongs to.
  106714. * @returns the scene holding the lens flare system
  106715. */
  106716. getScene(): Scene;
  106717. /**
  106718. * Get the emitter of the lens flare system.
  106719. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  106720. * @returns the emitter of the lens flare system
  106721. */
  106722. getEmitter(): any;
  106723. /**
  106724. * Set the emitter of the lens flare system.
  106725. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  106726. * @param newEmitter Define the new emitter of the system
  106727. */
  106728. setEmitter(newEmitter: any): void;
  106729. /**
  106730. * Get the lens flare system emitter position.
  106731. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  106732. * @returns the position
  106733. */
  106734. getEmitterPosition(): Vector3;
  106735. /**
  106736. * @hidden
  106737. */
  106738. computeEffectivePosition(globalViewport: Viewport): boolean;
  106739. /** @hidden */
  106740. _isVisible(): boolean;
  106741. /**
  106742. * @hidden
  106743. */
  106744. render(): boolean;
  106745. /**
  106746. * Dispose and release the lens flare with its associated resources.
  106747. */
  106748. dispose(): void;
  106749. /**
  106750. * Parse a lens flare system from a JSON repressentation
  106751. * @param parsedLensFlareSystem Define the JSON to parse
  106752. * @param scene Define the scene the parsed system should be instantiated in
  106753. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  106754. * @returns the parsed system
  106755. */
  106756. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  106757. /**
  106758. * Serialize the current Lens Flare System into a JSON representation.
  106759. * @returns the serialized JSON
  106760. */
  106761. serialize(): any;
  106762. }
  106763. }
  106764. declare module BABYLON {
  106765. /**
  106766. * This represents one of the lens effect in a `lensFlareSystem`.
  106767. * It controls one of the indiviual texture used in the effect.
  106768. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106769. */
  106770. export class LensFlare {
  106771. /**
  106772. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  106773. */
  106774. size: number;
  106775. /**
  106776. * 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.
  106777. */
  106778. position: number;
  106779. /**
  106780. * Define the lens color.
  106781. */
  106782. color: Color3;
  106783. /**
  106784. * Define the lens texture.
  106785. */
  106786. texture: Nullable<Texture>;
  106787. /**
  106788. * Define the alpha mode to render this particular lens.
  106789. */
  106790. alphaMode: number;
  106791. private _system;
  106792. /**
  106793. * Creates a new Lens Flare.
  106794. * This represents one of the lens effect in a `lensFlareSystem`.
  106795. * It controls one of the indiviual texture used in the effect.
  106796. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106797. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  106798. * @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.
  106799. * @param color Define the lens color
  106800. * @param imgUrl Define the lens texture url
  106801. * @param system Define the `lensFlareSystem` this flare is part of
  106802. * @returns The newly created Lens Flare
  106803. */
  106804. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  106805. /**
  106806. * Instantiates a new Lens Flare.
  106807. * This represents one of the lens effect in a `lensFlareSystem`.
  106808. * It controls one of the indiviual texture used in the effect.
  106809. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106810. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  106811. * @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.
  106812. * @param color Define the lens color
  106813. * @param imgUrl Define the lens texture url
  106814. * @param system Define the `lensFlareSystem` this flare is part of
  106815. */
  106816. constructor(
  106817. /**
  106818. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  106819. */
  106820. size: number,
  106821. /**
  106822. * 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.
  106823. */
  106824. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  106825. /**
  106826. * Dispose and release the lens flare with its associated resources.
  106827. */
  106828. dispose(): void;
  106829. }
  106830. }
  106831. declare module BABYLON {
  106832. interface AbstractScene {
  106833. /**
  106834. * The list of lens flare system added to the scene
  106835. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106836. */
  106837. lensFlareSystems: Array<LensFlareSystem>;
  106838. /**
  106839. * Removes the given lens flare system from this scene.
  106840. * @param toRemove The lens flare system to remove
  106841. * @returns The index of the removed lens flare system
  106842. */
  106843. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  106844. /**
  106845. * Adds the given lens flare system to this scene
  106846. * @param newLensFlareSystem The lens flare system to add
  106847. */
  106848. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  106849. /**
  106850. * Gets a lens flare system using its name
  106851. * @param name defines the name to look for
  106852. * @returns the lens flare system or null if not found
  106853. */
  106854. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  106855. /**
  106856. * Gets a lens flare system using its id
  106857. * @param id defines the id to look for
  106858. * @returns the lens flare system or null if not found
  106859. */
  106860. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  106861. }
  106862. /**
  106863. * Defines the lens flare scene component responsible to manage any lens flares
  106864. * in a given scene.
  106865. */
  106866. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  106867. /**
  106868. * The component name helpfull to identify the component in the list of scene components.
  106869. */
  106870. readonly name: string;
  106871. /**
  106872. * The scene the component belongs to.
  106873. */
  106874. scene: Scene;
  106875. /**
  106876. * Creates a new instance of the component for the given scene
  106877. * @param scene Defines the scene to register the component in
  106878. */
  106879. constructor(scene: Scene);
  106880. /**
  106881. * Registers the component in a given scene
  106882. */
  106883. register(): void;
  106884. /**
  106885. * Rebuilds the elements related to this component in case of
  106886. * context lost for instance.
  106887. */
  106888. rebuild(): void;
  106889. /**
  106890. * Adds all the element from the container to the scene
  106891. * @param container the container holding the elements
  106892. */
  106893. addFromContainer(container: AbstractScene): void;
  106894. /**
  106895. * Removes all the elements in the container from the scene
  106896. * @param container contains the elements to remove
  106897. * @param dispose if the removed element should be disposed (default: false)
  106898. */
  106899. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  106900. /**
  106901. * Serializes the component data to the specified json object
  106902. * @param serializationObject The object to serialize to
  106903. */
  106904. serialize(serializationObject: any): void;
  106905. /**
  106906. * Disposes the component and the associated ressources.
  106907. */
  106908. dispose(): void;
  106909. private _draw;
  106910. }
  106911. }
  106912. declare module BABYLON {
  106913. /**
  106914. * Defines the shadow generator component responsible to manage any shadow generators
  106915. * in a given scene.
  106916. */
  106917. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  106918. /**
  106919. * The component name helpfull to identify the component in the list of scene components.
  106920. */
  106921. readonly name: string;
  106922. /**
  106923. * The scene the component belongs to.
  106924. */
  106925. scene: Scene;
  106926. /**
  106927. * Creates a new instance of the component for the given scene
  106928. * @param scene Defines the scene to register the component in
  106929. */
  106930. constructor(scene: Scene);
  106931. /**
  106932. * Registers the component in a given scene
  106933. */
  106934. register(): void;
  106935. /**
  106936. * Rebuilds the elements related to this component in case of
  106937. * context lost for instance.
  106938. */
  106939. rebuild(): void;
  106940. /**
  106941. * Serializes the component data to the specified json object
  106942. * @param serializationObject The object to serialize to
  106943. */
  106944. serialize(serializationObject: any): void;
  106945. /**
  106946. * Adds all the element from the container to the scene
  106947. * @param container the container holding the elements
  106948. */
  106949. addFromContainer(container: AbstractScene): void;
  106950. /**
  106951. * Removes all the elements in the container from the scene
  106952. * @param container contains the elements to remove
  106953. * @param dispose if the removed element should be disposed (default: false)
  106954. */
  106955. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  106956. /**
  106957. * Rebuilds the elements related to this component in case of
  106958. * context lost for instance.
  106959. */
  106960. dispose(): void;
  106961. private _gatherRenderTargets;
  106962. }
  106963. }
  106964. declare module BABYLON {
  106965. /**
  106966. * A point light is a light defined by an unique point in world space.
  106967. * The light is emitted in every direction from this point.
  106968. * A good example of a point light is a standard light bulb.
  106969. * Documentation: https://doc.babylonjs.com/babylon101/lights
  106970. */
  106971. export class PointLight extends ShadowLight {
  106972. private _shadowAngle;
  106973. /**
  106974. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  106975. * This specifies what angle the shadow will use to be created.
  106976. *
  106977. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  106978. */
  106979. /**
  106980. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  106981. * This specifies what angle the shadow will use to be created.
  106982. *
  106983. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  106984. */
  106985. shadowAngle: number;
  106986. /**
  106987. * Gets the direction if it has been set.
  106988. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  106989. */
  106990. /**
  106991. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  106992. */
  106993. direction: Vector3;
  106994. /**
  106995. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  106996. * A PointLight emits the light in every direction.
  106997. * It can cast shadows.
  106998. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  106999. * ```javascript
  107000. * var pointLight = new PointLight("pl", camera.position, scene);
  107001. * ```
  107002. * Documentation : https://doc.babylonjs.com/babylon101/lights
  107003. * @param name The light friendly name
  107004. * @param position The position of the point light in the scene
  107005. * @param scene The scene the lights belongs to
  107006. */
  107007. constructor(name: string, position: Vector3, scene: Scene);
  107008. /**
  107009. * Returns the string "PointLight"
  107010. * @returns the class name
  107011. */
  107012. getClassName(): string;
  107013. /**
  107014. * Returns the integer 0.
  107015. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  107016. */
  107017. getTypeID(): number;
  107018. /**
  107019. * Specifies wether or not the shadowmap should be a cube texture.
  107020. * @returns true if the shadowmap needs to be a cube texture.
  107021. */
  107022. needCube(): boolean;
  107023. /**
  107024. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  107025. * @param faceIndex The index of the face we are computed the direction to generate shadow
  107026. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  107027. */
  107028. getShadowDirection(faceIndex?: number): Vector3;
  107029. /**
  107030. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  107031. * - fov = PI / 2
  107032. * - aspect ratio : 1.0
  107033. * - z-near and far equal to the active camera minZ and maxZ.
  107034. * Returns the PointLight.
  107035. */
  107036. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  107037. protected _buildUniformLayout(): void;
  107038. /**
  107039. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  107040. * @param effect The effect to update
  107041. * @param lightIndex The index of the light in the effect to update
  107042. * @returns The point light
  107043. */
  107044. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  107045. /**
  107046. * Prepares the list of defines specific to the light type.
  107047. * @param defines the list of defines
  107048. * @param lightIndex defines the index of the light for the effect
  107049. */
  107050. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  107051. }
  107052. }
  107053. declare module BABYLON {
  107054. /**
  107055. * Header information of HDR texture files.
  107056. */
  107057. export interface HDRInfo {
  107058. /**
  107059. * The height of the texture in pixels.
  107060. */
  107061. height: number;
  107062. /**
  107063. * The width of the texture in pixels.
  107064. */
  107065. width: number;
  107066. /**
  107067. * The index of the beginning of the data in the binary file.
  107068. */
  107069. dataPosition: number;
  107070. }
  107071. /**
  107072. * This groups tools to convert HDR texture to native colors array.
  107073. */
  107074. export class HDRTools {
  107075. private static Ldexp;
  107076. private static Rgbe2float;
  107077. private static readStringLine;
  107078. /**
  107079. * Reads header information from an RGBE texture stored in a native array.
  107080. * More information on this format are available here:
  107081. * https://en.wikipedia.org/wiki/RGBE_image_format
  107082. *
  107083. * @param uint8array The binary file stored in native array.
  107084. * @return The header information.
  107085. */
  107086. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  107087. /**
  107088. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  107089. * This RGBE texture needs to store the information as a panorama.
  107090. *
  107091. * More information on this format are available here:
  107092. * https://en.wikipedia.org/wiki/RGBE_image_format
  107093. *
  107094. * @param buffer The binary file stored in an array buffer.
  107095. * @param size The expected size of the extracted cubemap.
  107096. * @return The Cube Map information.
  107097. */
  107098. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  107099. /**
  107100. * Returns the pixels data extracted from an RGBE texture.
  107101. * This pixels will be stored left to right up to down in the R G B order in one array.
  107102. *
  107103. * More information on this format are available here:
  107104. * https://en.wikipedia.org/wiki/RGBE_image_format
  107105. *
  107106. * @param uint8array The binary file stored in an array buffer.
  107107. * @param hdrInfo The header information of the file.
  107108. * @return The pixels data in RGB right to left up to down order.
  107109. */
  107110. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  107111. private static RGBE_ReadPixels_RLE;
  107112. }
  107113. }
  107114. declare module BABYLON {
  107115. /**
  107116. * This represents a texture coming from an HDR input.
  107117. *
  107118. * The only supported format is currently panorama picture stored in RGBE format.
  107119. * Example of such files can be found on HDRLib: http://hdrlib.com/
  107120. */
  107121. export class HDRCubeTexture extends BaseTexture {
  107122. private static _facesMapping;
  107123. private _generateHarmonics;
  107124. private _noMipmap;
  107125. private _textureMatrix;
  107126. private _size;
  107127. private _onLoad;
  107128. private _onError;
  107129. /**
  107130. * The texture URL.
  107131. */
  107132. url: string;
  107133. /**
  107134. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  107135. */
  107136. coordinatesMode: number;
  107137. protected _isBlocking: boolean;
  107138. /**
  107139. * Sets wether or not the texture is blocking during loading.
  107140. */
  107141. /**
  107142. * Gets wether or not the texture is blocking during loading.
  107143. */
  107144. isBlocking: boolean;
  107145. protected _rotationY: number;
  107146. /**
  107147. * Sets texture matrix rotation angle around Y axis in radians.
  107148. */
  107149. /**
  107150. * Gets texture matrix rotation angle around Y axis radians.
  107151. */
  107152. rotationY: number;
  107153. /**
  107154. * Gets or sets the center of the bounding box associated with the cube texture
  107155. * It must define where the camera used to render the texture was set
  107156. */
  107157. boundingBoxPosition: Vector3;
  107158. private _boundingBoxSize;
  107159. /**
  107160. * Gets or sets the size of the bounding box associated with the cube texture
  107161. * When defined, the cubemap will switch to local mode
  107162. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  107163. * @example https://www.babylonjs-playground.com/#RNASML
  107164. */
  107165. boundingBoxSize: Vector3;
  107166. /**
  107167. * Instantiates an HDRTexture from the following parameters.
  107168. *
  107169. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  107170. * @param scene The scene the texture will be used in
  107171. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  107172. * @param noMipmap Forces to not generate the mipmap if true
  107173. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  107174. * @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)
  107175. * @param reserved Reserved flag for internal use.
  107176. */
  107177. 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>);
  107178. /**
  107179. * Get the current class name of the texture useful for serialization or dynamic coding.
  107180. * @returns "HDRCubeTexture"
  107181. */
  107182. getClassName(): string;
  107183. /**
  107184. * Occurs when the file is raw .hdr file.
  107185. */
  107186. private loadTexture;
  107187. clone(): HDRCubeTexture;
  107188. delayLoad(): void;
  107189. /**
  107190. * Get the texture reflection matrix used to rotate/transform the reflection.
  107191. * @returns the reflection matrix
  107192. */
  107193. getReflectionTextureMatrix(): Matrix;
  107194. /**
  107195. * Set the texture reflection matrix used to rotate/transform the reflection.
  107196. * @param value Define the reflection matrix to set
  107197. */
  107198. setReflectionTextureMatrix(value: Matrix): void;
  107199. /**
  107200. * Parses a JSON representation of an HDR Texture in order to create the texture
  107201. * @param parsedTexture Define the JSON representation
  107202. * @param scene Define the scene the texture should be created in
  107203. * @param rootUrl Define the root url in case we need to load relative dependencies
  107204. * @returns the newly created texture after parsing
  107205. */
  107206. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  107207. serialize(): any;
  107208. }
  107209. }
  107210. declare module BABYLON {
  107211. /**
  107212. * Class used to control physics engine
  107213. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  107214. */
  107215. export class PhysicsEngine implements IPhysicsEngine {
  107216. private _physicsPlugin;
  107217. /**
  107218. * Global value used to control the smallest number supported by the simulation
  107219. */
  107220. static Epsilon: number;
  107221. private _impostors;
  107222. private _joints;
  107223. /**
  107224. * Gets the gravity vector used by the simulation
  107225. */
  107226. gravity: Vector3;
  107227. /**
  107228. * Factory used to create the default physics plugin.
  107229. * @returns The default physics plugin
  107230. */
  107231. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  107232. /**
  107233. * Creates a new Physics Engine
  107234. * @param gravity defines the gravity vector used by the simulation
  107235. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  107236. */
  107237. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  107238. /**
  107239. * Sets the gravity vector used by the simulation
  107240. * @param gravity defines the gravity vector to use
  107241. */
  107242. setGravity(gravity: Vector3): void;
  107243. /**
  107244. * Set the time step of the physics engine.
  107245. * Default is 1/60.
  107246. * To slow it down, enter 1/600 for example.
  107247. * To speed it up, 1/30
  107248. * @param newTimeStep defines the new timestep to apply to this world.
  107249. */
  107250. setTimeStep(newTimeStep?: number): void;
  107251. /**
  107252. * Get the time step of the physics engine.
  107253. * @returns the current time step
  107254. */
  107255. getTimeStep(): number;
  107256. /**
  107257. * Release all resources
  107258. */
  107259. dispose(): void;
  107260. /**
  107261. * Gets the name of the current physics plugin
  107262. * @returns the name of the plugin
  107263. */
  107264. getPhysicsPluginName(): string;
  107265. /**
  107266. * Adding a new impostor for the impostor tracking.
  107267. * This will be done by the impostor itself.
  107268. * @param impostor the impostor to add
  107269. */
  107270. addImpostor(impostor: PhysicsImpostor): void;
  107271. /**
  107272. * Remove an impostor from the engine.
  107273. * This impostor and its mesh will not longer be updated by the physics engine.
  107274. * @param impostor the impostor to remove
  107275. */
  107276. removeImpostor(impostor: PhysicsImpostor): void;
  107277. /**
  107278. * Add a joint to the physics engine
  107279. * @param mainImpostor defines the main impostor to which the joint is added.
  107280. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  107281. * @param joint defines the joint that will connect both impostors.
  107282. */
  107283. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  107284. /**
  107285. * Removes a joint from the simulation
  107286. * @param mainImpostor defines the impostor used with the joint
  107287. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  107288. * @param joint defines the joint to remove
  107289. */
  107290. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  107291. /**
  107292. * Called by the scene. No need to call it.
  107293. * @param delta defines the timespam between frames
  107294. */
  107295. _step(delta: number): void;
  107296. /**
  107297. * Gets the current plugin used to run the simulation
  107298. * @returns current plugin
  107299. */
  107300. getPhysicsPlugin(): IPhysicsEnginePlugin;
  107301. /**
  107302. * Gets the list of physic impostors
  107303. * @returns an array of PhysicsImpostor
  107304. */
  107305. getImpostors(): Array<PhysicsImpostor>;
  107306. /**
  107307. * Gets the impostor for a physics enabled object
  107308. * @param object defines the object impersonated by the impostor
  107309. * @returns the PhysicsImpostor or null if not found
  107310. */
  107311. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  107312. /**
  107313. * Gets the impostor for a physics body object
  107314. * @param body defines physics body used by the impostor
  107315. * @returns the PhysicsImpostor or null if not found
  107316. */
  107317. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  107318. /**
  107319. * Does a raycast in the physics world
  107320. * @param from when should the ray start?
  107321. * @param to when should the ray end?
  107322. * @returns PhysicsRaycastResult
  107323. */
  107324. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107325. }
  107326. }
  107327. declare module BABYLON {
  107328. /** @hidden */
  107329. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  107330. private _useDeltaForWorldStep;
  107331. world: any;
  107332. name: string;
  107333. private _physicsMaterials;
  107334. private _fixedTimeStep;
  107335. private _cannonRaycastResult;
  107336. private _raycastResult;
  107337. private _removeAfterStep;
  107338. BJSCANNON: any;
  107339. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  107340. setGravity(gravity: Vector3): void;
  107341. setTimeStep(timeStep: number): void;
  107342. getTimeStep(): number;
  107343. executeStep(delta: number): void;
  107344. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107345. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107346. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107347. private _processChildMeshes;
  107348. removePhysicsBody(impostor: PhysicsImpostor): void;
  107349. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  107350. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  107351. private _addMaterial;
  107352. private _checkWithEpsilon;
  107353. private _createShape;
  107354. private _createHeightmap;
  107355. private _minus90X;
  107356. private _plus90X;
  107357. private _tmpPosition;
  107358. private _tmpDeltaPosition;
  107359. private _tmpUnityRotation;
  107360. private _updatePhysicsBodyTransformation;
  107361. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107362. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107363. isSupported(): boolean;
  107364. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107365. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107366. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107367. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107368. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107369. getBodyMass(impostor: PhysicsImpostor): number;
  107370. getBodyFriction(impostor: PhysicsImpostor): number;
  107371. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107372. getBodyRestitution(impostor: PhysicsImpostor): number;
  107373. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107374. sleepBody(impostor: PhysicsImpostor): void;
  107375. wakeUpBody(impostor: PhysicsImpostor): void;
  107376. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  107377. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  107378. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  107379. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107380. getRadius(impostor: PhysicsImpostor): number;
  107381. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107382. dispose(): void;
  107383. private _extendNamespace;
  107384. /**
  107385. * Does a raycast in the physics world
  107386. * @param from when should the ray start?
  107387. * @param to when should the ray end?
  107388. * @returns PhysicsRaycastResult
  107389. */
  107390. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107391. }
  107392. }
  107393. declare module BABYLON {
  107394. /** @hidden */
  107395. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  107396. world: any;
  107397. name: string;
  107398. BJSOIMO: any;
  107399. private _raycastResult;
  107400. constructor(iterations?: number, oimoInjection?: any);
  107401. setGravity(gravity: Vector3): void;
  107402. setTimeStep(timeStep: number): void;
  107403. getTimeStep(): number;
  107404. private _tmpImpostorsArray;
  107405. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  107406. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107407. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107408. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107409. private _tmpPositionVector;
  107410. removePhysicsBody(impostor: PhysicsImpostor): void;
  107411. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  107412. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  107413. isSupported(): boolean;
  107414. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107415. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107416. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107417. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107418. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107419. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107420. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107421. getBodyMass(impostor: PhysicsImpostor): number;
  107422. getBodyFriction(impostor: PhysicsImpostor): number;
  107423. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107424. getBodyRestitution(impostor: PhysicsImpostor): number;
  107425. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107426. sleepBody(impostor: PhysicsImpostor): void;
  107427. wakeUpBody(impostor: PhysicsImpostor): void;
  107428. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  107429. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  107430. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  107431. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107432. getRadius(impostor: PhysicsImpostor): number;
  107433. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107434. dispose(): void;
  107435. /**
  107436. * Does a raycast in the physics world
  107437. * @param from when should the ray start?
  107438. * @param to when should the ray end?
  107439. * @returns PhysicsRaycastResult
  107440. */
  107441. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107442. }
  107443. }
  107444. declare module BABYLON {
  107445. /**
  107446. * Class containing static functions to help procedurally build meshes
  107447. */
  107448. export class RibbonBuilder {
  107449. /**
  107450. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  107451. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  107452. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  107453. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  107454. * * 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
  107455. * * 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
  107456. * * 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
  107457. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107458. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107459. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107460. * * 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
  107461. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  107462. * * 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
  107463. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  107464. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107465. * @param name defines the name of the mesh
  107466. * @param options defines the options used to create the mesh
  107467. * @param scene defines the hosting scene
  107468. * @returns the ribbon mesh
  107469. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  107470. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107471. */
  107472. static CreateRibbon(name: string, options: {
  107473. pathArray: Vector3[][];
  107474. closeArray?: boolean;
  107475. closePath?: boolean;
  107476. offset?: number;
  107477. updatable?: boolean;
  107478. sideOrientation?: number;
  107479. frontUVs?: Vector4;
  107480. backUVs?: Vector4;
  107481. instance?: Mesh;
  107482. invertUV?: boolean;
  107483. uvs?: Vector2[];
  107484. colors?: Color4[];
  107485. }, scene?: Nullable<Scene>): Mesh;
  107486. }
  107487. }
  107488. declare module BABYLON {
  107489. /**
  107490. * Class containing static functions to help procedurally build meshes
  107491. */
  107492. export class ShapeBuilder {
  107493. /**
  107494. * 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.
  107495. * * 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.
  107496. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  107497. * * 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.
  107498. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  107499. * * 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
  107500. * * 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
  107501. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  107502. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107503. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107504. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  107505. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107506. * @param name defines the name of the mesh
  107507. * @param options defines the options used to create the mesh
  107508. * @param scene defines the hosting scene
  107509. * @returns the extruded shape mesh
  107510. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107511. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107512. */
  107513. static ExtrudeShape(name: string, options: {
  107514. shape: Vector3[];
  107515. path: Vector3[];
  107516. scale?: number;
  107517. rotation?: number;
  107518. cap?: number;
  107519. updatable?: boolean;
  107520. sideOrientation?: number;
  107521. frontUVs?: Vector4;
  107522. backUVs?: Vector4;
  107523. instance?: Mesh;
  107524. invertUV?: boolean;
  107525. }, scene?: Nullable<Scene>): Mesh;
  107526. /**
  107527. * Creates an custom extruded shape mesh.
  107528. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  107529. * * 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.
  107530. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  107531. * * 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
  107532. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  107533. * * 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
  107534. * * It must returns a float value that will be the scale value applied to the shape on each path point
  107535. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  107536. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  107537. * * 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
  107538. * * 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
  107539. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  107540. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107541. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107542. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107543. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107544. * @param name defines the name of the mesh
  107545. * @param options defines the options used to create the mesh
  107546. * @param scene defines the hosting scene
  107547. * @returns the custom extruded shape mesh
  107548. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  107549. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107550. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107551. */
  107552. static ExtrudeShapeCustom(name: string, options: {
  107553. shape: Vector3[];
  107554. path: Vector3[];
  107555. scaleFunction?: any;
  107556. rotationFunction?: any;
  107557. ribbonCloseArray?: boolean;
  107558. ribbonClosePath?: boolean;
  107559. cap?: number;
  107560. updatable?: boolean;
  107561. sideOrientation?: number;
  107562. frontUVs?: Vector4;
  107563. backUVs?: Vector4;
  107564. instance?: Mesh;
  107565. invertUV?: boolean;
  107566. }, scene?: Nullable<Scene>): Mesh;
  107567. private static _ExtrudeShapeGeneric;
  107568. }
  107569. }
  107570. declare module BABYLON {
  107571. /**
  107572. * AmmoJS Physics plugin
  107573. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107574. * @see https://github.com/kripken/ammo.js/
  107575. */
  107576. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  107577. private _useDeltaForWorldStep;
  107578. /**
  107579. * Reference to the Ammo library
  107580. */
  107581. bjsAMMO: any;
  107582. /**
  107583. * Created ammoJS world which physics bodies are added to
  107584. */
  107585. world: any;
  107586. /**
  107587. * Name of the plugin
  107588. */
  107589. name: string;
  107590. private _timeStep;
  107591. private _fixedTimeStep;
  107592. private _maxSteps;
  107593. private _tmpQuaternion;
  107594. private _tmpAmmoTransform;
  107595. private _tmpAmmoQuaternion;
  107596. private _tmpAmmoConcreteContactResultCallback;
  107597. private _collisionConfiguration;
  107598. private _dispatcher;
  107599. private _overlappingPairCache;
  107600. private _solver;
  107601. private _softBodySolver;
  107602. private _tmpAmmoVectorA;
  107603. private _tmpAmmoVectorB;
  107604. private _tmpAmmoVectorC;
  107605. private _tmpAmmoVectorD;
  107606. private _tmpContactCallbackResult;
  107607. private _tmpAmmoVectorRCA;
  107608. private _tmpAmmoVectorRCB;
  107609. private _raycastResult;
  107610. private static readonly DISABLE_COLLISION_FLAG;
  107611. private static readonly KINEMATIC_FLAG;
  107612. private static readonly DISABLE_DEACTIVATION_FLAG;
  107613. /**
  107614. * Initializes the ammoJS plugin
  107615. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  107616. * @param ammoInjection can be used to inject your own ammo reference
  107617. */
  107618. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  107619. /**
  107620. * Sets the gravity of the physics world (m/(s^2))
  107621. * @param gravity Gravity to set
  107622. */
  107623. setGravity(gravity: Vector3): void;
  107624. /**
  107625. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  107626. * @param timeStep timestep to use in seconds
  107627. */
  107628. setTimeStep(timeStep: number): void;
  107629. /**
  107630. * 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)
  107631. * @param fixedTimeStep fixedTimeStep to use in seconds
  107632. */
  107633. setFixedTimeStep(fixedTimeStep: number): void;
  107634. /**
  107635. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  107636. * @param maxSteps the maximum number of steps by the physics engine per frame
  107637. */
  107638. setMaxSteps(maxSteps: number): void;
  107639. /**
  107640. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  107641. * @returns the current timestep in seconds
  107642. */
  107643. getTimeStep(): number;
  107644. private _isImpostorInContact;
  107645. private _isImpostorPairInContact;
  107646. private _stepSimulation;
  107647. /**
  107648. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  107649. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  107650. * After the step the babylon meshes are set to the position of the physics imposters
  107651. * @param delta amount of time to step forward
  107652. * @param impostors array of imposters to update before/after the step
  107653. */
  107654. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  107655. /**
  107656. * Update babylon mesh to match physics world object
  107657. * @param impostor imposter to match
  107658. */
  107659. private _afterSoftStep;
  107660. /**
  107661. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  107662. * @param impostor imposter to match
  107663. */
  107664. private _ropeStep;
  107665. /**
  107666. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  107667. * @param impostor imposter to match
  107668. */
  107669. private _softbodyOrClothStep;
  107670. private _tmpVector;
  107671. private _tmpMatrix;
  107672. /**
  107673. * Applies an impulse on the imposter
  107674. * @param impostor imposter to apply impulse to
  107675. * @param force amount of force to be applied to the imposter
  107676. * @param contactPoint the location to apply the impulse on the imposter
  107677. */
  107678. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107679. /**
  107680. * Applies a force on the imposter
  107681. * @param impostor imposter to apply force
  107682. * @param force amount of force to be applied to the imposter
  107683. * @param contactPoint the location to apply the force on the imposter
  107684. */
  107685. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107686. /**
  107687. * Creates a physics body using the plugin
  107688. * @param impostor the imposter to create the physics body on
  107689. */
  107690. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107691. /**
  107692. * Removes the physics body from the imposter and disposes of the body's memory
  107693. * @param impostor imposter to remove the physics body from
  107694. */
  107695. removePhysicsBody(impostor: PhysicsImpostor): void;
  107696. /**
  107697. * Generates a joint
  107698. * @param impostorJoint the imposter joint to create the joint with
  107699. */
  107700. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  107701. /**
  107702. * Removes a joint
  107703. * @param impostorJoint the imposter joint to remove the joint from
  107704. */
  107705. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  107706. private _addMeshVerts;
  107707. /**
  107708. * Initialise the soft body vertices to match its object's (mesh) vertices
  107709. * Softbody vertices (nodes) are in world space and to match this
  107710. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  107711. * @param impostor to create the softbody for
  107712. */
  107713. private _softVertexData;
  107714. /**
  107715. * Create an impostor's soft body
  107716. * @param impostor to create the softbody for
  107717. */
  107718. private _createSoftbody;
  107719. /**
  107720. * Create cloth for an impostor
  107721. * @param impostor to create the softbody for
  107722. */
  107723. private _createCloth;
  107724. /**
  107725. * Create rope for an impostor
  107726. * @param impostor to create the softbody for
  107727. */
  107728. private _createRope;
  107729. private _addHullVerts;
  107730. private _createShape;
  107731. /**
  107732. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  107733. * @param impostor imposter containing the physics body and babylon object
  107734. */
  107735. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107736. /**
  107737. * Sets the babylon object's position/rotation from the physics body's position/rotation
  107738. * @param impostor imposter containing the physics body and babylon object
  107739. * @param newPosition new position
  107740. * @param newRotation new rotation
  107741. */
  107742. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107743. /**
  107744. * If this plugin is supported
  107745. * @returns true if its supported
  107746. */
  107747. isSupported(): boolean;
  107748. /**
  107749. * Sets the linear velocity of the physics body
  107750. * @param impostor imposter to set the velocity on
  107751. * @param velocity velocity to set
  107752. */
  107753. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107754. /**
  107755. * Sets the angular velocity of the physics body
  107756. * @param impostor imposter to set the velocity on
  107757. * @param velocity velocity to set
  107758. */
  107759. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107760. /**
  107761. * gets the linear velocity
  107762. * @param impostor imposter to get linear velocity from
  107763. * @returns linear velocity
  107764. */
  107765. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107766. /**
  107767. * gets the angular velocity
  107768. * @param impostor imposter to get angular velocity from
  107769. * @returns angular velocity
  107770. */
  107771. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107772. /**
  107773. * Sets the mass of physics body
  107774. * @param impostor imposter to set the mass on
  107775. * @param mass mass to set
  107776. */
  107777. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107778. /**
  107779. * Gets the mass of the physics body
  107780. * @param impostor imposter to get the mass from
  107781. * @returns mass
  107782. */
  107783. getBodyMass(impostor: PhysicsImpostor): number;
  107784. /**
  107785. * Gets friction of the impostor
  107786. * @param impostor impostor to get friction from
  107787. * @returns friction value
  107788. */
  107789. getBodyFriction(impostor: PhysicsImpostor): number;
  107790. /**
  107791. * Sets friction of the impostor
  107792. * @param impostor impostor to set friction on
  107793. * @param friction friction value
  107794. */
  107795. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107796. /**
  107797. * Gets restitution of the impostor
  107798. * @param impostor impostor to get restitution from
  107799. * @returns restitution value
  107800. */
  107801. getBodyRestitution(impostor: PhysicsImpostor): number;
  107802. /**
  107803. * Sets resitution of the impostor
  107804. * @param impostor impostor to set resitution on
  107805. * @param restitution resitution value
  107806. */
  107807. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107808. /**
  107809. * Gets pressure inside the impostor
  107810. * @param impostor impostor to get pressure from
  107811. * @returns pressure value
  107812. */
  107813. getBodyPressure(impostor: PhysicsImpostor): number;
  107814. /**
  107815. * Sets pressure inside a soft body impostor
  107816. * Cloth and rope must remain 0 pressure
  107817. * @param impostor impostor to set pressure on
  107818. * @param pressure pressure value
  107819. */
  107820. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  107821. /**
  107822. * Gets stiffness of the impostor
  107823. * @param impostor impostor to get stiffness from
  107824. * @returns pressure value
  107825. */
  107826. getBodyStiffness(impostor: PhysicsImpostor): number;
  107827. /**
  107828. * Sets stiffness of the impostor
  107829. * @param impostor impostor to set stiffness on
  107830. * @param stiffness stiffness value from 0 to 1
  107831. */
  107832. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  107833. /**
  107834. * Gets velocityIterations of the impostor
  107835. * @param impostor impostor to get velocity iterations from
  107836. * @returns velocityIterations value
  107837. */
  107838. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  107839. /**
  107840. * Sets velocityIterations of the impostor
  107841. * @param impostor impostor to set velocity iterations on
  107842. * @param velocityIterations velocityIterations value
  107843. */
  107844. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  107845. /**
  107846. * Gets positionIterations of the impostor
  107847. * @param impostor impostor to get position iterations from
  107848. * @returns positionIterations value
  107849. */
  107850. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  107851. /**
  107852. * Sets positionIterations of the impostor
  107853. * @param impostor impostor to set position on
  107854. * @param positionIterations positionIterations value
  107855. */
  107856. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  107857. /**
  107858. * Append an anchor to a cloth object
  107859. * @param impostor is the cloth impostor to add anchor to
  107860. * @param otherImpostor is the rigid impostor to anchor to
  107861. * @param width ratio across width from 0 to 1
  107862. * @param height ratio up height from 0 to 1
  107863. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  107864. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  107865. */
  107866. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  107867. /**
  107868. * Append an hook to a rope object
  107869. * @param impostor is the rope impostor to add hook to
  107870. * @param otherImpostor is the rigid impostor to hook to
  107871. * @param length ratio along the rope from 0 to 1
  107872. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  107873. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  107874. */
  107875. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  107876. /**
  107877. * Sleeps the physics body and stops it from being active
  107878. * @param impostor impostor to sleep
  107879. */
  107880. sleepBody(impostor: PhysicsImpostor): void;
  107881. /**
  107882. * Activates the physics body
  107883. * @param impostor impostor to activate
  107884. */
  107885. wakeUpBody(impostor: PhysicsImpostor): void;
  107886. /**
  107887. * Updates the distance parameters of the joint
  107888. * @param joint joint to update
  107889. * @param maxDistance maximum distance of the joint
  107890. * @param minDistance minimum distance of the joint
  107891. */
  107892. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  107893. /**
  107894. * Sets a motor on the joint
  107895. * @param joint joint to set motor on
  107896. * @param speed speed of the motor
  107897. * @param maxForce maximum force of the motor
  107898. * @param motorIndex index of the motor
  107899. */
  107900. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  107901. /**
  107902. * Sets the motors limit
  107903. * @param joint joint to set limit on
  107904. * @param upperLimit upper limit
  107905. * @param lowerLimit lower limit
  107906. */
  107907. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  107908. /**
  107909. * Syncs the position and rotation of a mesh with the impostor
  107910. * @param mesh mesh to sync
  107911. * @param impostor impostor to update the mesh with
  107912. */
  107913. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107914. /**
  107915. * Gets the radius of the impostor
  107916. * @param impostor impostor to get radius from
  107917. * @returns the radius
  107918. */
  107919. getRadius(impostor: PhysicsImpostor): number;
  107920. /**
  107921. * Gets the box size of the impostor
  107922. * @param impostor impostor to get box size from
  107923. * @param result the resulting box size
  107924. */
  107925. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107926. /**
  107927. * Disposes of the impostor
  107928. */
  107929. dispose(): void;
  107930. /**
  107931. * Does a raycast in the physics world
  107932. * @param from when should the ray start?
  107933. * @param to when should the ray end?
  107934. * @returns PhysicsRaycastResult
  107935. */
  107936. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107937. }
  107938. }
  107939. declare module BABYLON {
  107940. interface AbstractScene {
  107941. /**
  107942. * The list of reflection probes added to the scene
  107943. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  107944. */
  107945. reflectionProbes: Array<ReflectionProbe>;
  107946. /**
  107947. * Removes the given reflection probe from this scene.
  107948. * @param toRemove The reflection probe to remove
  107949. * @returns The index of the removed reflection probe
  107950. */
  107951. removeReflectionProbe(toRemove: ReflectionProbe): number;
  107952. /**
  107953. * Adds the given reflection probe to this scene.
  107954. * @param newReflectionProbe The reflection probe to add
  107955. */
  107956. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  107957. }
  107958. /**
  107959. * Class used to generate realtime reflection / refraction cube textures
  107960. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  107961. */
  107962. export class ReflectionProbe {
  107963. /** defines the name of the probe */
  107964. name: string;
  107965. private _scene;
  107966. private _renderTargetTexture;
  107967. private _projectionMatrix;
  107968. private _viewMatrix;
  107969. private _target;
  107970. private _add;
  107971. private _attachedMesh;
  107972. private _invertYAxis;
  107973. /** Gets or sets probe position (center of the cube map) */
  107974. position: Vector3;
  107975. /**
  107976. * Creates a new reflection probe
  107977. * @param name defines the name of the probe
  107978. * @param size defines the texture resolution (for each face)
  107979. * @param scene defines the hosting scene
  107980. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  107981. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  107982. */
  107983. constructor(
  107984. /** defines the name of the probe */
  107985. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  107986. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  107987. samples: number;
  107988. /** Gets or sets the refresh rate to use (on every frame by default) */
  107989. refreshRate: number;
  107990. /**
  107991. * Gets the hosting scene
  107992. * @returns a Scene
  107993. */
  107994. getScene(): Scene;
  107995. /** Gets the internal CubeTexture used to render to */
  107996. readonly cubeTexture: RenderTargetTexture;
  107997. /** Gets the list of meshes to render */
  107998. readonly renderList: Nullable<AbstractMesh[]>;
  107999. /**
  108000. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  108001. * @param mesh defines the mesh to attach to
  108002. */
  108003. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  108004. /**
  108005. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  108006. * @param renderingGroupId The rendering group id corresponding to its index
  108007. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  108008. */
  108009. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  108010. /**
  108011. * Clean all associated resources
  108012. */
  108013. dispose(): void;
  108014. /**
  108015. * Converts the reflection probe information to a readable string for debug purpose.
  108016. * @param fullDetails Supports for multiple levels of logging within scene loading
  108017. * @returns the human readable reflection probe info
  108018. */
  108019. toString(fullDetails?: boolean): string;
  108020. /**
  108021. * Get the class name of the relfection probe.
  108022. * @returns "ReflectionProbe"
  108023. */
  108024. getClassName(): string;
  108025. /**
  108026. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  108027. * @returns The JSON representation of the texture
  108028. */
  108029. serialize(): any;
  108030. /**
  108031. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  108032. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  108033. * @param scene Define the scene the parsed reflection probe should be instantiated in
  108034. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  108035. * @returns The parsed reflection probe if successful
  108036. */
  108037. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  108038. }
  108039. }
  108040. declare module BABYLON {
  108041. /** @hidden */
  108042. export var _BabylonLoaderRegistered: boolean;
  108043. }
  108044. declare module BABYLON {
  108045. /**
  108046. * The Physically based simple base material of BJS.
  108047. *
  108048. * This enables better naming and convention enforcements on top of the pbrMaterial.
  108049. * It is used as the base class for both the specGloss and metalRough conventions.
  108050. */
  108051. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  108052. /**
  108053. * Number of Simultaneous lights allowed on the material.
  108054. */
  108055. maxSimultaneousLights: number;
  108056. /**
  108057. * If sets to true, disables all the lights affecting the material.
  108058. */
  108059. disableLighting: boolean;
  108060. /**
  108061. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  108062. */
  108063. environmentTexture: BaseTexture;
  108064. /**
  108065. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  108066. */
  108067. invertNormalMapX: boolean;
  108068. /**
  108069. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  108070. */
  108071. invertNormalMapY: boolean;
  108072. /**
  108073. * Normal map used in the model.
  108074. */
  108075. normalTexture: BaseTexture;
  108076. /**
  108077. * Emissivie color used to self-illuminate the model.
  108078. */
  108079. emissiveColor: Color3;
  108080. /**
  108081. * Emissivie texture used to self-illuminate the model.
  108082. */
  108083. emissiveTexture: BaseTexture;
  108084. /**
  108085. * Occlusion Channel Strenght.
  108086. */
  108087. occlusionStrength: number;
  108088. /**
  108089. * Occlusion Texture of the material (adding extra occlusion effects).
  108090. */
  108091. occlusionTexture: BaseTexture;
  108092. /**
  108093. * Defines the alpha limits in alpha test mode.
  108094. */
  108095. alphaCutOff: number;
  108096. /**
  108097. * Gets the current double sided mode.
  108098. */
  108099. /**
  108100. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108101. */
  108102. doubleSided: boolean;
  108103. /**
  108104. * Stores the pre-calculated light information of a mesh in a texture.
  108105. */
  108106. lightmapTexture: BaseTexture;
  108107. /**
  108108. * If true, the light map contains occlusion information instead of lighting info.
  108109. */
  108110. useLightmapAsShadowmap: boolean;
  108111. /**
  108112. * Instantiates a new PBRMaterial instance.
  108113. *
  108114. * @param name The material name
  108115. * @param scene The scene the material will be use in.
  108116. */
  108117. constructor(name: string, scene: Scene);
  108118. getClassName(): string;
  108119. }
  108120. }
  108121. declare module BABYLON {
  108122. /**
  108123. * The PBR material of BJS following the metal roughness convention.
  108124. *
  108125. * This fits to the PBR convention in the GLTF definition:
  108126. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  108127. */
  108128. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  108129. /**
  108130. * The base color has two different interpretations depending on the value of metalness.
  108131. * When the material is a metal, the base color is the specific measured reflectance value
  108132. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  108133. * of the material.
  108134. */
  108135. baseColor: Color3;
  108136. /**
  108137. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  108138. * well as opacity information in the alpha channel.
  108139. */
  108140. baseTexture: BaseTexture;
  108141. /**
  108142. * Specifies the metallic scalar value of the material.
  108143. * Can also be used to scale the metalness values of the metallic texture.
  108144. */
  108145. metallic: number;
  108146. /**
  108147. * Specifies the roughness scalar value of the material.
  108148. * Can also be used to scale the roughness values of the metallic texture.
  108149. */
  108150. roughness: number;
  108151. /**
  108152. * Texture containing both the metallic value in the B channel and the
  108153. * roughness value in the G channel to keep better precision.
  108154. */
  108155. metallicRoughnessTexture: BaseTexture;
  108156. /**
  108157. * Instantiates a new PBRMetalRoughnessMaterial instance.
  108158. *
  108159. * @param name The material name
  108160. * @param scene The scene the material will be use in.
  108161. */
  108162. constructor(name: string, scene: Scene);
  108163. /**
  108164. * Return the currrent class name of the material.
  108165. */
  108166. getClassName(): string;
  108167. /**
  108168. * Makes a duplicate of the current material.
  108169. * @param name - name to use for the new material.
  108170. */
  108171. clone(name: string): PBRMetallicRoughnessMaterial;
  108172. /**
  108173. * Serialize the material to a parsable JSON object.
  108174. */
  108175. serialize(): any;
  108176. /**
  108177. * Parses a JSON object correponding to the serialize function.
  108178. */
  108179. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  108180. }
  108181. }
  108182. declare module BABYLON {
  108183. /**
  108184. * The PBR material of BJS following the specular glossiness convention.
  108185. *
  108186. * This fits to the PBR convention in the GLTF definition:
  108187. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  108188. */
  108189. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  108190. /**
  108191. * Specifies the diffuse color of the material.
  108192. */
  108193. diffuseColor: Color3;
  108194. /**
  108195. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  108196. * channel.
  108197. */
  108198. diffuseTexture: BaseTexture;
  108199. /**
  108200. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  108201. */
  108202. specularColor: Color3;
  108203. /**
  108204. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  108205. */
  108206. glossiness: number;
  108207. /**
  108208. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  108209. */
  108210. specularGlossinessTexture: BaseTexture;
  108211. /**
  108212. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  108213. *
  108214. * @param name The material name
  108215. * @param scene The scene the material will be use in.
  108216. */
  108217. constructor(name: string, scene: Scene);
  108218. /**
  108219. * Return the currrent class name of the material.
  108220. */
  108221. getClassName(): string;
  108222. /**
  108223. * Makes a duplicate of the current material.
  108224. * @param name - name to use for the new material.
  108225. */
  108226. clone(name: string): PBRSpecularGlossinessMaterial;
  108227. /**
  108228. * Serialize the material to a parsable JSON object.
  108229. */
  108230. serialize(): any;
  108231. /**
  108232. * Parses a JSON object correponding to the serialize function.
  108233. */
  108234. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  108235. }
  108236. }
  108237. declare module BABYLON {
  108238. /**
  108239. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  108240. * It can help converting any input color in a desired output one. This can then be used to create effects
  108241. * from sepia, black and white to sixties or futuristic rendering...
  108242. *
  108243. * The only supported format is currently 3dl.
  108244. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  108245. */
  108246. export class ColorGradingTexture extends BaseTexture {
  108247. /**
  108248. * The current texture matrix. (will always be identity in color grading texture)
  108249. */
  108250. private _textureMatrix;
  108251. /**
  108252. * The texture URL.
  108253. */
  108254. url: string;
  108255. /**
  108256. * Empty line regex stored for GC.
  108257. */
  108258. private static _noneEmptyLineRegex;
  108259. private _engine;
  108260. /**
  108261. * Instantiates a ColorGradingTexture from the following parameters.
  108262. *
  108263. * @param url The location of the color gradind data (currently only supporting 3dl)
  108264. * @param scene The scene the texture will be used in
  108265. */
  108266. constructor(url: string, scene: Scene);
  108267. /**
  108268. * Returns the texture matrix used in most of the material.
  108269. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  108270. */
  108271. getTextureMatrix(): Matrix;
  108272. /**
  108273. * Occurs when the file being loaded is a .3dl LUT file.
  108274. */
  108275. private load3dlTexture;
  108276. /**
  108277. * Starts the loading process of the texture.
  108278. */
  108279. private loadTexture;
  108280. /**
  108281. * Clones the color gradind texture.
  108282. */
  108283. clone(): ColorGradingTexture;
  108284. /**
  108285. * Called during delayed load for textures.
  108286. */
  108287. delayLoad(): void;
  108288. /**
  108289. * Parses a color grading texture serialized by Babylon.
  108290. * @param parsedTexture The texture information being parsedTexture
  108291. * @param scene The scene to load the texture in
  108292. * @param rootUrl The root url of the data assets to load
  108293. * @return A color gradind texture
  108294. */
  108295. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  108296. /**
  108297. * Serializes the LUT texture to json format.
  108298. */
  108299. serialize(): any;
  108300. }
  108301. }
  108302. declare module BABYLON {
  108303. /**
  108304. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  108305. */
  108306. export class EquiRectangularCubeTexture extends BaseTexture {
  108307. /** The six faces of the cube. */
  108308. private static _FacesMapping;
  108309. private _noMipmap;
  108310. private _onLoad;
  108311. private _onError;
  108312. /** The size of the cubemap. */
  108313. private _size;
  108314. /** The buffer of the image. */
  108315. private _buffer;
  108316. /** The width of the input image. */
  108317. private _width;
  108318. /** The height of the input image. */
  108319. private _height;
  108320. /** The URL to the image. */
  108321. url: string;
  108322. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  108323. coordinatesMode: number;
  108324. /**
  108325. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  108326. * @param url The location of the image
  108327. * @param scene The scene the texture will be used in
  108328. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  108329. * @param noMipmap Forces to not generate the mipmap if true
  108330. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  108331. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  108332. * @param onLoad — defines a callback called when texture is loaded
  108333. * @param onError — defines a callback called if there is an error
  108334. */
  108335. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  108336. /**
  108337. * Load the image data, by putting the image on a canvas and extracting its buffer.
  108338. */
  108339. private loadImage;
  108340. /**
  108341. * Convert the image buffer into a cubemap and create a CubeTexture.
  108342. */
  108343. private loadTexture;
  108344. /**
  108345. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  108346. * @param buffer The ArrayBuffer that should be converted.
  108347. * @returns The buffer as Float32Array.
  108348. */
  108349. private getFloat32ArrayFromArrayBuffer;
  108350. /**
  108351. * Get the current class name of the texture useful for serialization or dynamic coding.
  108352. * @returns "EquiRectangularCubeTexture"
  108353. */
  108354. getClassName(): string;
  108355. /**
  108356. * Create a clone of the current EquiRectangularCubeTexture and return it.
  108357. * @returns A clone of the current EquiRectangularCubeTexture.
  108358. */
  108359. clone(): EquiRectangularCubeTexture;
  108360. }
  108361. }
  108362. declare module BABYLON {
  108363. /**
  108364. * Based on jsTGALoader - Javascript loader for TGA file
  108365. * By Vincent Thibault
  108366. * @see http://blog.robrowser.com/javascript-tga-loader.html
  108367. */
  108368. export class TGATools {
  108369. private static _TYPE_INDEXED;
  108370. private static _TYPE_RGB;
  108371. private static _TYPE_GREY;
  108372. private static _TYPE_RLE_INDEXED;
  108373. private static _TYPE_RLE_RGB;
  108374. private static _TYPE_RLE_GREY;
  108375. private static _ORIGIN_MASK;
  108376. private static _ORIGIN_SHIFT;
  108377. private static _ORIGIN_BL;
  108378. private static _ORIGIN_BR;
  108379. private static _ORIGIN_UL;
  108380. private static _ORIGIN_UR;
  108381. /**
  108382. * Gets the header of a TGA file
  108383. * @param data defines the TGA data
  108384. * @returns the header
  108385. */
  108386. static GetTGAHeader(data: Uint8Array): any;
  108387. /**
  108388. * Uploads TGA content to a Babylon Texture
  108389. * @hidden
  108390. */
  108391. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  108392. /** @hidden */
  108393. 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;
  108394. /** @hidden */
  108395. 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;
  108396. /** @hidden */
  108397. 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;
  108398. /** @hidden */
  108399. 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;
  108400. /** @hidden */
  108401. 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;
  108402. /** @hidden */
  108403. 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;
  108404. }
  108405. }
  108406. declare module BABYLON {
  108407. /**
  108408. * Implementation of the TGA Texture Loader.
  108409. * @hidden
  108410. */
  108411. export class _TGATextureLoader implements IInternalTextureLoader {
  108412. /**
  108413. * Defines wether the loader supports cascade loading the different faces.
  108414. */
  108415. readonly supportCascades: boolean;
  108416. /**
  108417. * This returns if the loader support the current file information.
  108418. * @param extension defines the file extension of the file being loaded
  108419. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108420. * @param fallback defines the fallback internal texture if any
  108421. * @param isBase64 defines whether the texture is encoded as a base64
  108422. * @param isBuffer defines whether the texture data are stored as a buffer
  108423. * @returns true if the loader can load the specified file
  108424. */
  108425. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  108426. /**
  108427. * Transform the url before loading if required.
  108428. * @param rootUrl the url of the texture
  108429. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108430. * @returns the transformed texture
  108431. */
  108432. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  108433. /**
  108434. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  108435. * @param rootUrl the url of the texture
  108436. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108437. * @returns the fallback texture
  108438. */
  108439. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  108440. /**
  108441. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  108442. * @param data contains the texture data
  108443. * @param texture defines the BabylonJS internal texture
  108444. * @param createPolynomials will be true if polynomials have been requested
  108445. * @param onLoad defines the callback to trigger once the texture is ready
  108446. * @param onError defines the callback to trigger in case of error
  108447. */
  108448. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  108449. /**
  108450. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  108451. * @param data contains the texture data
  108452. * @param texture defines the BabylonJS internal texture
  108453. * @param callback defines the method to call once ready to upload
  108454. */
  108455. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  108456. }
  108457. }
  108458. declare module BABYLON {
  108459. /**
  108460. * 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.
  108461. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  108462. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  108463. */
  108464. export class CustomProceduralTexture extends ProceduralTexture {
  108465. private _animate;
  108466. private _time;
  108467. private _config;
  108468. private _texturePath;
  108469. /**
  108470. * Instantiates a new Custom Procedural Texture.
  108471. * 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.
  108472. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  108473. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  108474. * @param name Define the name of the texture
  108475. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  108476. * @param size Define the size of the texture to create
  108477. * @param scene Define the scene the texture belongs to
  108478. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  108479. * @param generateMipMaps Define if the texture should creates mip maps or not
  108480. */
  108481. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  108482. private _loadJson;
  108483. /**
  108484. * Is the texture ready to be used ? (rendered at least once)
  108485. * @returns true if ready, otherwise, false.
  108486. */
  108487. isReady(): boolean;
  108488. /**
  108489. * Render the texture to its associated render target.
  108490. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  108491. */
  108492. render(useCameraPostProcess?: boolean): void;
  108493. /**
  108494. * Update the list of dependant textures samplers in the shader.
  108495. */
  108496. updateTextures(): void;
  108497. /**
  108498. * Update the uniform values of the procedural texture in the shader.
  108499. */
  108500. updateShaderUniforms(): void;
  108501. /**
  108502. * Define if the texture animates or not.
  108503. */
  108504. animate: boolean;
  108505. }
  108506. }
  108507. declare module BABYLON {
  108508. /** @hidden */
  108509. export var noisePixelShader: {
  108510. name: string;
  108511. shader: string;
  108512. };
  108513. }
  108514. declare module BABYLON {
  108515. /**
  108516. * Class used to generate noise procedural textures
  108517. */
  108518. export class NoiseProceduralTexture extends ProceduralTexture {
  108519. private _time;
  108520. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  108521. brightness: number;
  108522. /** Defines the number of octaves to process */
  108523. octaves: number;
  108524. /** Defines the level of persistence (0.8 by default) */
  108525. persistence: number;
  108526. /** Gets or sets animation speed factor (default is 1) */
  108527. animationSpeedFactor: number;
  108528. /**
  108529. * Creates a new NoiseProceduralTexture
  108530. * @param name defines the name fo the texture
  108531. * @param size defines the size of the texture (default is 256)
  108532. * @param scene defines the hosting scene
  108533. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  108534. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  108535. */
  108536. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  108537. private _updateShaderUniforms;
  108538. protected _getDefines(): string;
  108539. /** Generate the current state of the procedural texture */
  108540. render(useCameraPostProcess?: boolean): void;
  108541. /**
  108542. * Serializes this noise procedural texture
  108543. * @returns a serialized noise procedural texture object
  108544. */
  108545. serialize(): any;
  108546. /**
  108547. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  108548. * @param parsedTexture defines parsed texture data
  108549. * @param scene defines the current scene
  108550. * @param rootUrl defines the root URL containing noise procedural texture information
  108551. * @returns a parsed NoiseProceduralTexture
  108552. */
  108553. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  108554. }
  108555. }
  108556. declare module BABYLON {
  108557. /**
  108558. * Raw cube texture where the raw buffers are passed in
  108559. */
  108560. export class RawCubeTexture extends CubeTexture {
  108561. /**
  108562. * Creates a cube texture where the raw buffers are passed in.
  108563. * @param scene defines the scene the texture is attached to
  108564. * @param data defines the array of data to use to create each face
  108565. * @param size defines the size of the textures
  108566. * @param format defines the format of the data
  108567. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  108568. * @param generateMipMaps defines if the engine should generate the mip levels
  108569. * @param invertY defines if data must be stored with Y axis inverted
  108570. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  108571. * @param compression defines the compression used (null by default)
  108572. */
  108573. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  108574. /**
  108575. * Updates the raw cube texture.
  108576. * @param data defines the data to store
  108577. * @param format defines the data format
  108578. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  108579. * @param invertY defines if data must be stored with Y axis inverted
  108580. * @param compression defines the compression used (null by default)
  108581. * @param level defines which level of the texture to update
  108582. */
  108583. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  108584. /**
  108585. * Updates a raw cube texture with RGBD encoded data.
  108586. * @param data defines the array of data [mipmap][face] to use to create each face
  108587. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  108588. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  108589. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  108590. * @returns a promsie that resolves when the operation is complete
  108591. */
  108592. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  108593. /**
  108594. * Clones the raw cube texture.
  108595. * @return a new cube texture
  108596. */
  108597. clone(): CubeTexture;
  108598. /** @hidden */
  108599. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  108600. }
  108601. }
  108602. declare module BABYLON {
  108603. /**
  108604. * Class used to store 3D textures containing user data
  108605. */
  108606. export class RawTexture3D extends Texture {
  108607. /** Gets or sets the texture format to use */
  108608. format: number;
  108609. private _engine;
  108610. /**
  108611. * Create a new RawTexture3D
  108612. * @param data defines the data of the texture
  108613. * @param width defines the width of the texture
  108614. * @param height defines the height of the texture
  108615. * @param depth defines the depth of the texture
  108616. * @param format defines the texture format to use
  108617. * @param scene defines the hosting scene
  108618. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  108619. * @param invertY defines if texture must be stored with Y axis inverted
  108620. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  108621. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  108622. */
  108623. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  108624. /** Gets or sets the texture format to use */
  108625. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  108626. /**
  108627. * Update the texture with new data
  108628. * @param data defines the data to store in the texture
  108629. */
  108630. update(data: ArrayBufferView): void;
  108631. }
  108632. }
  108633. declare module BABYLON {
  108634. /**
  108635. * Creates a refraction texture used by refraction channel of the standard material.
  108636. * It is like a mirror but to see through a material.
  108637. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  108638. */
  108639. export class RefractionTexture extends RenderTargetTexture {
  108640. /**
  108641. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  108642. * 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.
  108643. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  108644. */
  108645. refractionPlane: Plane;
  108646. /**
  108647. * Define how deep under the surface we should see.
  108648. */
  108649. depth: number;
  108650. /**
  108651. * Creates a refraction texture used by refraction channel of the standard material.
  108652. * It is like a mirror but to see through a material.
  108653. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  108654. * @param name Define the texture name
  108655. * @param size Define the size of the underlying texture
  108656. * @param scene Define the scene the refraction belongs to
  108657. * @param generateMipMaps Define if we need to generate mips level for the refraction
  108658. */
  108659. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  108660. /**
  108661. * Clone the refraction texture.
  108662. * @returns the cloned texture
  108663. */
  108664. clone(): RefractionTexture;
  108665. /**
  108666. * Serialize the texture to a JSON representation you could use in Parse later on
  108667. * @returns the serialized JSON representation
  108668. */
  108669. serialize(): any;
  108670. }
  108671. }
  108672. declare module BABYLON {
  108673. /**
  108674. * Helper class to push actions to a pool of workers.
  108675. */
  108676. export class WorkerPool implements IDisposable {
  108677. private _workerInfos;
  108678. private _pendingActions;
  108679. /**
  108680. * Constructor
  108681. * @param workers Array of workers to use for actions
  108682. */
  108683. constructor(workers: Array<Worker>);
  108684. /**
  108685. * Terminates all workers and clears any pending actions.
  108686. */
  108687. dispose(): void;
  108688. /**
  108689. * Pushes an action to the worker pool. If all the workers are active, the action will be
  108690. * pended until a worker has completed its action.
  108691. * @param action The action to perform. Call onComplete when the action is complete.
  108692. */
  108693. push(action: (worker: Worker, onComplete: () => void) => void): void;
  108694. private _execute;
  108695. }
  108696. }
  108697. declare module BABYLON {
  108698. /**
  108699. * Configuration for Draco compression
  108700. */
  108701. export interface IDracoCompressionConfiguration {
  108702. /**
  108703. * Configuration for the decoder.
  108704. */
  108705. decoder?: {
  108706. /**
  108707. * The url to the WebAssembly module.
  108708. */
  108709. wasmUrl?: string;
  108710. /**
  108711. * The url to the WebAssembly binary.
  108712. */
  108713. wasmBinaryUrl?: string;
  108714. /**
  108715. * The url to the fallback JavaScript module.
  108716. */
  108717. fallbackUrl?: string;
  108718. };
  108719. }
  108720. /**
  108721. * Draco compression (https://google.github.io/draco/)
  108722. *
  108723. * This class wraps the Draco module.
  108724. *
  108725. * **Encoder**
  108726. *
  108727. * The encoder is not currently implemented.
  108728. *
  108729. * **Decoder**
  108730. *
  108731. * 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.
  108732. *
  108733. * To update the configuration, use the following code:
  108734. * ```javascript
  108735. * DracoCompression.Configuration = {
  108736. * decoder: {
  108737. * wasmUrl: "<url to the WebAssembly library>",
  108738. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  108739. * fallbackUrl: "<url to the fallback JavaScript library>",
  108740. * }
  108741. * };
  108742. * ```
  108743. *
  108744. * 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.
  108745. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  108746. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  108747. *
  108748. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  108749. * ```javascript
  108750. * var dracoCompression = new DracoCompression();
  108751. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  108752. * [VertexBuffer.PositionKind]: 0
  108753. * });
  108754. * ```
  108755. *
  108756. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  108757. */
  108758. export class DracoCompression implements IDisposable {
  108759. private _workerPoolPromise;
  108760. /**
  108761. * The configuration. Defaults to the following urls:
  108762. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  108763. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  108764. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  108765. */
  108766. static Configuration: IDracoCompressionConfiguration;
  108767. /**
  108768. * Returns true if the decoder is available.
  108769. */
  108770. static readonly DecoderAvailable: boolean;
  108771. /**
  108772. * Default number of workers to create when creating the draco compression object.
  108773. */
  108774. static DefaultNumWorkers: number;
  108775. private static GetDefaultNumWorkers;
  108776. /**
  108777. * Constructor
  108778. * @param numWorkers The number of workers for async operations
  108779. */
  108780. constructor(numWorkers?: number);
  108781. /**
  108782. * Stop all async operations and release resources.
  108783. */
  108784. dispose(): void;
  108785. /**
  108786. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  108787. * @returns a promise that resolves when ready
  108788. */
  108789. whenReadyAsync(): Promise<void>;
  108790. /**
  108791. * Decode Draco compressed mesh data to vertex data.
  108792. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  108793. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  108794. * @returns A promise that resolves with the decoded vertex data
  108795. */
  108796. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  108797. [kind: string]: number;
  108798. }): Promise<VertexData>;
  108799. /**
  108800. * The worker function that gets converted to a blob url to pass into a worker.
  108801. */
  108802. private static _Worker;
  108803. private _loadDecoderWasmBinaryAsync;
  108804. }
  108805. }
  108806. declare module BABYLON {
  108807. /**
  108808. * Class for building Constructive Solid Geometry
  108809. */
  108810. export class CSG {
  108811. private polygons;
  108812. /**
  108813. * The world matrix
  108814. */
  108815. matrix: Matrix;
  108816. /**
  108817. * Stores the position
  108818. */
  108819. position: Vector3;
  108820. /**
  108821. * Stores the rotation
  108822. */
  108823. rotation: Vector3;
  108824. /**
  108825. * Stores the rotation quaternion
  108826. */
  108827. rotationQuaternion: Nullable<Quaternion>;
  108828. /**
  108829. * Stores the scaling vector
  108830. */
  108831. scaling: Vector3;
  108832. /**
  108833. * Convert the Mesh to CSG
  108834. * @param mesh The Mesh to convert to CSG
  108835. * @returns A new CSG from the Mesh
  108836. */
  108837. static FromMesh(mesh: Mesh): CSG;
  108838. /**
  108839. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  108840. * @param polygons Polygons used to construct a CSG solid
  108841. */
  108842. private static FromPolygons;
  108843. /**
  108844. * Clones, or makes a deep copy, of the CSG
  108845. * @returns A new CSG
  108846. */
  108847. clone(): CSG;
  108848. /**
  108849. * Unions this CSG with another CSG
  108850. * @param csg The CSG to union against this CSG
  108851. * @returns The unioned CSG
  108852. */
  108853. union(csg: CSG): CSG;
  108854. /**
  108855. * Unions this CSG with another CSG in place
  108856. * @param csg The CSG to union against this CSG
  108857. */
  108858. unionInPlace(csg: CSG): void;
  108859. /**
  108860. * Subtracts this CSG with another CSG
  108861. * @param csg The CSG to subtract against this CSG
  108862. * @returns A new CSG
  108863. */
  108864. subtract(csg: CSG): CSG;
  108865. /**
  108866. * Subtracts this CSG with another CSG in place
  108867. * @param csg The CSG to subtact against this CSG
  108868. */
  108869. subtractInPlace(csg: CSG): void;
  108870. /**
  108871. * Intersect this CSG with another CSG
  108872. * @param csg The CSG to intersect against this CSG
  108873. * @returns A new CSG
  108874. */
  108875. intersect(csg: CSG): CSG;
  108876. /**
  108877. * Intersects this CSG with another CSG in place
  108878. * @param csg The CSG to intersect against this CSG
  108879. */
  108880. intersectInPlace(csg: CSG): void;
  108881. /**
  108882. * Return a new CSG solid with solid and empty space switched. This solid is
  108883. * not modified.
  108884. * @returns A new CSG solid with solid and empty space switched
  108885. */
  108886. inverse(): CSG;
  108887. /**
  108888. * Inverses the CSG in place
  108889. */
  108890. inverseInPlace(): void;
  108891. /**
  108892. * This is used to keep meshes transformations so they can be restored
  108893. * when we build back a Babylon Mesh
  108894. * NB : All CSG operations are performed in world coordinates
  108895. * @param csg The CSG to copy the transform attributes from
  108896. * @returns This CSG
  108897. */
  108898. copyTransformAttributes(csg: CSG): CSG;
  108899. /**
  108900. * Build Raw mesh from CSG
  108901. * Coordinates here are in world space
  108902. * @param name The name of the mesh geometry
  108903. * @param scene The Scene
  108904. * @param keepSubMeshes Specifies if the submeshes should be kept
  108905. * @returns A new Mesh
  108906. */
  108907. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  108908. /**
  108909. * Build Mesh from CSG taking material and transforms into account
  108910. * @param name The name of the Mesh
  108911. * @param material The material of the Mesh
  108912. * @param scene The Scene
  108913. * @param keepSubMeshes Specifies if submeshes should be kept
  108914. * @returns The new Mesh
  108915. */
  108916. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  108917. }
  108918. }
  108919. declare module BABYLON {
  108920. /**
  108921. * Class used to create a trail following a mesh
  108922. */
  108923. export class TrailMesh extends Mesh {
  108924. private _generator;
  108925. private _autoStart;
  108926. private _running;
  108927. private _diameter;
  108928. private _length;
  108929. private _sectionPolygonPointsCount;
  108930. private _sectionVectors;
  108931. private _sectionNormalVectors;
  108932. private _beforeRenderObserver;
  108933. /**
  108934. * @constructor
  108935. * @param name The value used by scene.getMeshByName() to do a lookup.
  108936. * @param generator The mesh to generate a trail.
  108937. * @param scene The scene to add this mesh to.
  108938. * @param diameter Diameter of trailing mesh. Default is 1.
  108939. * @param length Length of trailing mesh. Default is 60.
  108940. * @param autoStart Automatically start trailing mesh. Default true.
  108941. */
  108942. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  108943. /**
  108944. * "TrailMesh"
  108945. * @returns "TrailMesh"
  108946. */
  108947. getClassName(): string;
  108948. private _createMesh;
  108949. /**
  108950. * Start trailing mesh.
  108951. */
  108952. start(): void;
  108953. /**
  108954. * Stop trailing mesh.
  108955. */
  108956. stop(): void;
  108957. /**
  108958. * Update trailing mesh geometry.
  108959. */
  108960. update(): void;
  108961. /**
  108962. * Returns a new TrailMesh object.
  108963. * @param name is a string, the name given to the new mesh
  108964. * @param newGenerator use new generator object for cloned trail mesh
  108965. * @returns a new mesh
  108966. */
  108967. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  108968. /**
  108969. * Serializes this trail mesh
  108970. * @param serializationObject object to write serialization to
  108971. */
  108972. serialize(serializationObject: any): void;
  108973. /**
  108974. * Parses a serialized trail mesh
  108975. * @param parsedMesh the serialized mesh
  108976. * @param scene the scene to create the trail mesh in
  108977. * @returns the created trail mesh
  108978. */
  108979. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  108980. }
  108981. }
  108982. declare module BABYLON {
  108983. /**
  108984. * Class containing static functions to help procedurally build meshes
  108985. */
  108986. export class TorusKnotBuilder {
  108987. /**
  108988. * Creates a torus knot mesh
  108989. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  108990. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  108991. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  108992. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  108993. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108994. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108995. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108996. * @param name defines the name of the mesh
  108997. * @param options defines the options used to create the mesh
  108998. * @param scene defines the hosting scene
  108999. * @returns the torus knot mesh
  109000. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  109001. */
  109002. static CreateTorusKnot(name: string, options: {
  109003. radius?: number;
  109004. tube?: number;
  109005. radialSegments?: number;
  109006. tubularSegments?: number;
  109007. p?: number;
  109008. q?: number;
  109009. updatable?: boolean;
  109010. sideOrientation?: number;
  109011. frontUVs?: Vector4;
  109012. backUVs?: Vector4;
  109013. }, scene: any): Mesh;
  109014. }
  109015. }
  109016. declare module BABYLON {
  109017. /**
  109018. * Polygon
  109019. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  109020. */
  109021. export class Polygon {
  109022. /**
  109023. * Creates a rectangle
  109024. * @param xmin bottom X coord
  109025. * @param ymin bottom Y coord
  109026. * @param xmax top X coord
  109027. * @param ymax top Y coord
  109028. * @returns points that make the resulting rectation
  109029. */
  109030. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  109031. /**
  109032. * Creates a circle
  109033. * @param radius radius of circle
  109034. * @param cx scale in x
  109035. * @param cy scale in y
  109036. * @param numberOfSides number of sides that make up the circle
  109037. * @returns points that make the resulting circle
  109038. */
  109039. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  109040. /**
  109041. * Creates a polygon from input string
  109042. * @param input Input polygon data
  109043. * @returns the parsed points
  109044. */
  109045. static Parse(input: string): Vector2[];
  109046. /**
  109047. * Starts building a polygon from x and y coordinates
  109048. * @param x x coordinate
  109049. * @param y y coordinate
  109050. * @returns the started path2
  109051. */
  109052. static StartingAt(x: number, y: number): Path2;
  109053. }
  109054. /**
  109055. * Builds a polygon
  109056. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  109057. */
  109058. export class PolygonMeshBuilder {
  109059. private _points;
  109060. private _outlinepoints;
  109061. private _holes;
  109062. private _name;
  109063. private _scene;
  109064. private _epoints;
  109065. private _eholes;
  109066. private _addToepoint;
  109067. /**
  109068. * Babylon reference to the earcut plugin.
  109069. */
  109070. bjsEarcut: any;
  109071. /**
  109072. * Creates a PolygonMeshBuilder
  109073. * @param name name of the builder
  109074. * @param contours Path of the polygon
  109075. * @param scene scene to add to when creating the mesh
  109076. * @param earcutInjection can be used to inject your own earcut reference
  109077. */
  109078. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  109079. /**
  109080. * Adds a whole within the polygon
  109081. * @param hole Array of points defining the hole
  109082. * @returns this
  109083. */
  109084. addHole(hole: Vector2[]): PolygonMeshBuilder;
  109085. /**
  109086. * Creates the polygon
  109087. * @param updatable If the mesh should be updatable
  109088. * @param depth The depth of the mesh created
  109089. * @returns the created mesh
  109090. */
  109091. build(updatable?: boolean, depth?: number): Mesh;
  109092. /**
  109093. * Creates the polygon
  109094. * @param depth The depth of the mesh created
  109095. * @returns the created VertexData
  109096. */
  109097. buildVertexData(depth?: number): VertexData;
  109098. /**
  109099. * Adds a side to the polygon
  109100. * @param positions points that make the polygon
  109101. * @param normals normals of the polygon
  109102. * @param uvs uvs of the polygon
  109103. * @param indices indices of the polygon
  109104. * @param bounds bounds of the polygon
  109105. * @param points points of the polygon
  109106. * @param depth depth of the polygon
  109107. * @param flip flip of the polygon
  109108. */
  109109. private addSide;
  109110. }
  109111. }
  109112. declare module BABYLON {
  109113. /**
  109114. * Class containing static functions to help procedurally build meshes
  109115. */
  109116. export class PolygonBuilder {
  109117. /**
  109118. * Creates a polygon mesh
  109119. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  109120. * * 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
  109121. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109122. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109123. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  109124. * * Remember you can only change the shape positions, not their number when updating a polygon
  109125. * @param name defines the name of the mesh
  109126. * @param options defines the options used to create the mesh
  109127. * @param scene defines the hosting scene
  109128. * @param earcutInjection can be used to inject your own earcut reference
  109129. * @returns the polygon mesh
  109130. */
  109131. static CreatePolygon(name: string, options: {
  109132. shape: Vector3[];
  109133. holes?: Vector3[][];
  109134. depth?: number;
  109135. faceUV?: Vector4[];
  109136. faceColors?: Color4[];
  109137. updatable?: boolean;
  109138. sideOrientation?: number;
  109139. frontUVs?: Vector4;
  109140. backUVs?: Vector4;
  109141. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  109142. /**
  109143. * Creates an extruded polygon mesh, with depth in the Y direction.
  109144. * * 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)
  109145. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  109146. * @param name defines the name of the mesh
  109147. * @param options defines the options used to create the mesh
  109148. * @param scene defines the hosting scene
  109149. * @param earcutInjection can be used to inject your own earcut reference
  109150. * @returns the polygon mesh
  109151. */
  109152. static ExtrudePolygon(name: string, options: {
  109153. shape: Vector3[];
  109154. holes?: Vector3[][];
  109155. depth?: number;
  109156. faceUV?: Vector4[];
  109157. faceColors?: Color4[];
  109158. updatable?: boolean;
  109159. sideOrientation?: number;
  109160. frontUVs?: Vector4;
  109161. backUVs?: Vector4;
  109162. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  109163. }
  109164. }
  109165. declare module BABYLON {
  109166. /**
  109167. * Class containing static functions to help procedurally build meshes
  109168. */
  109169. export class LatheBuilder {
  109170. /**
  109171. * Creates lathe mesh.
  109172. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  109173. * * 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
  109174. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  109175. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  109176. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  109177. * * 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
  109178. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  109179. * * 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
  109180. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109181. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109182. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109183. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109184. * @param name defines the name of the mesh
  109185. * @param options defines the options used to create the mesh
  109186. * @param scene defines the hosting scene
  109187. * @returns the lathe mesh
  109188. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  109189. */
  109190. static CreateLathe(name: string, options: {
  109191. shape: Vector3[];
  109192. radius?: number;
  109193. tessellation?: number;
  109194. clip?: number;
  109195. arc?: number;
  109196. closed?: boolean;
  109197. updatable?: boolean;
  109198. sideOrientation?: number;
  109199. frontUVs?: Vector4;
  109200. backUVs?: Vector4;
  109201. cap?: number;
  109202. invertUV?: boolean;
  109203. }, scene?: Nullable<Scene>): Mesh;
  109204. }
  109205. }
  109206. declare module BABYLON {
  109207. /**
  109208. * Class containing static functions to help procedurally build meshes
  109209. */
  109210. export class TubeBuilder {
  109211. /**
  109212. * Creates a tube mesh.
  109213. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  109214. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  109215. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  109216. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  109217. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  109218. * * 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)
  109219. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  109220. * * 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
  109221. * * 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
  109222. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109223. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109224. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109225. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109226. * @param name defines the name of the mesh
  109227. * @param options defines the options used to create the mesh
  109228. * @param scene defines the hosting scene
  109229. * @returns the tube mesh
  109230. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109231. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  109232. */
  109233. static CreateTube(name: string, options: {
  109234. path: Vector3[];
  109235. radius?: number;
  109236. tessellation?: number;
  109237. radiusFunction?: {
  109238. (i: number, distance: number): number;
  109239. };
  109240. cap?: number;
  109241. arc?: number;
  109242. updatable?: boolean;
  109243. sideOrientation?: number;
  109244. frontUVs?: Vector4;
  109245. backUVs?: Vector4;
  109246. instance?: Mesh;
  109247. invertUV?: boolean;
  109248. }, scene?: Nullable<Scene>): Mesh;
  109249. }
  109250. }
  109251. declare module BABYLON {
  109252. /**
  109253. * Class containing static functions to help procedurally build meshes
  109254. */
  109255. export class IcoSphereBuilder {
  109256. /**
  109257. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  109258. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  109259. * * 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`)
  109260. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  109261. * * 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
  109262. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109263. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109264. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109265. * @param name defines the name of the mesh
  109266. * @param options defines the options used to create the mesh
  109267. * @param scene defines the hosting scene
  109268. * @returns the icosahedron mesh
  109269. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  109270. */
  109271. static CreateIcoSphere(name: string, options: {
  109272. radius?: number;
  109273. radiusX?: number;
  109274. radiusY?: number;
  109275. radiusZ?: number;
  109276. flat?: boolean;
  109277. subdivisions?: number;
  109278. sideOrientation?: number;
  109279. frontUVs?: Vector4;
  109280. backUVs?: Vector4;
  109281. updatable?: boolean;
  109282. }, scene?: Nullable<Scene>): Mesh;
  109283. }
  109284. }
  109285. declare module BABYLON {
  109286. /**
  109287. * Class containing static functions to help procedurally build meshes
  109288. */
  109289. export class DecalBuilder {
  109290. /**
  109291. * Creates a decal mesh.
  109292. * 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
  109293. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  109294. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  109295. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  109296. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  109297. * @param name defines the name of the mesh
  109298. * @param sourceMesh defines the mesh where the decal must be applied
  109299. * @param options defines the options used to create the mesh
  109300. * @param scene defines the hosting scene
  109301. * @returns the decal mesh
  109302. * @see https://doc.babylonjs.com/how_to/decals
  109303. */
  109304. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  109305. position?: Vector3;
  109306. normal?: Vector3;
  109307. size?: Vector3;
  109308. angle?: number;
  109309. }): Mesh;
  109310. }
  109311. }
  109312. declare module BABYLON {
  109313. /**
  109314. * Class containing static functions to help procedurally build meshes
  109315. */
  109316. export class MeshBuilder {
  109317. /**
  109318. * Creates a box mesh
  109319. * * The parameter `size` sets the size (float) of each box side (default 1)
  109320. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  109321. * * 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)
  109322. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  109323. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109324. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109325. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109326. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  109327. * @param name defines the name of the mesh
  109328. * @param options defines the options used to create the mesh
  109329. * @param scene defines the hosting scene
  109330. * @returns the box mesh
  109331. */
  109332. static CreateBox(name: string, options: {
  109333. size?: number;
  109334. width?: number;
  109335. height?: number;
  109336. depth?: number;
  109337. faceUV?: Vector4[];
  109338. faceColors?: Color4[];
  109339. sideOrientation?: number;
  109340. frontUVs?: Vector4;
  109341. backUVs?: Vector4;
  109342. updatable?: boolean;
  109343. }, scene?: Nullable<Scene>): Mesh;
  109344. /**
  109345. * Creates a sphere mesh
  109346. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  109347. * * 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`)
  109348. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  109349. * * 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
  109350. * * 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)
  109351. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109352. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109353. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109354. * @param name defines the name of the mesh
  109355. * @param options defines the options used to create the mesh
  109356. * @param scene defines the hosting scene
  109357. * @returns the sphere mesh
  109358. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  109359. */
  109360. static CreateSphere(name: string, options: {
  109361. segments?: number;
  109362. diameter?: number;
  109363. diameterX?: number;
  109364. diameterY?: number;
  109365. diameterZ?: number;
  109366. arc?: number;
  109367. slice?: number;
  109368. sideOrientation?: number;
  109369. frontUVs?: Vector4;
  109370. backUVs?: Vector4;
  109371. updatable?: boolean;
  109372. }, scene?: Nullable<Scene>): Mesh;
  109373. /**
  109374. * Creates a plane polygonal mesh. By default, this is a disc
  109375. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  109376. * * 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
  109377. * * 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
  109378. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109379. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109380. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109381. * @param name defines the name of the mesh
  109382. * @param options defines the options used to create the mesh
  109383. * @param scene defines the hosting scene
  109384. * @returns the plane polygonal mesh
  109385. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  109386. */
  109387. static CreateDisc(name: string, options: {
  109388. radius?: number;
  109389. tessellation?: number;
  109390. arc?: number;
  109391. updatable?: boolean;
  109392. sideOrientation?: number;
  109393. frontUVs?: Vector4;
  109394. backUVs?: Vector4;
  109395. }, scene?: Nullable<Scene>): Mesh;
  109396. /**
  109397. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  109398. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  109399. * * 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`)
  109400. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  109401. * * 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
  109402. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109403. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109404. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109405. * @param name defines the name of the mesh
  109406. * @param options defines the options used to create the mesh
  109407. * @param scene defines the hosting scene
  109408. * @returns the icosahedron mesh
  109409. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  109410. */
  109411. static CreateIcoSphere(name: string, options: {
  109412. radius?: number;
  109413. radiusX?: number;
  109414. radiusY?: number;
  109415. radiusZ?: number;
  109416. flat?: boolean;
  109417. subdivisions?: number;
  109418. sideOrientation?: number;
  109419. frontUVs?: Vector4;
  109420. backUVs?: Vector4;
  109421. updatable?: boolean;
  109422. }, scene?: Nullable<Scene>): Mesh;
  109423. /**
  109424. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  109425. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  109426. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  109427. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  109428. * * 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
  109429. * * 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
  109430. * * 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
  109431. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109432. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109433. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109434. * * 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
  109435. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  109436. * * 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
  109437. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  109438. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109439. * @param name defines the name of the mesh
  109440. * @param options defines the options used to create the mesh
  109441. * @param scene defines the hosting scene
  109442. * @returns the ribbon mesh
  109443. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  109444. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109445. */
  109446. static CreateRibbon(name: string, options: {
  109447. pathArray: Vector3[][];
  109448. closeArray?: boolean;
  109449. closePath?: boolean;
  109450. offset?: number;
  109451. updatable?: boolean;
  109452. sideOrientation?: number;
  109453. frontUVs?: Vector4;
  109454. backUVs?: Vector4;
  109455. instance?: Mesh;
  109456. invertUV?: boolean;
  109457. uvs?: Vector2[];
  109458. colors?: Color4[];
  109459. }, scene?: Nullable<Scene>): Mesh;
  109460. /**
  109461. * Creates a cylinder or a cone mesh
  109462. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  109463. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  109464. * * 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.
  109465. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  109466. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  109467. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  109468. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  109469. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  109470. * * 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).
  109471. * * 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
  109472. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  109473. * * 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
  109474. * * 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.
  109475. * * If `enclose` is false, a ring surface is one element.
  109476. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  109477. * * 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
  109478. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109479. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109480. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109481. * @param name defines the name of the mesh
  109482. * @param options defines the options used to create the mesh
  109483. * @param scene defines the hosting scene
  109484. * @returns the cylinder mesh
  109485. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  109486. */
  109487. static CreateCylinder(name: string, options: {
  109488. height?: number;
  109489. diameterTop?: number;
  109490. diameterBottom?: number;
  109491. diameter?: number;
  109492. tessellation?: number;
  109493. subdivisions?: number;
  109494. arc?: number;
  109495. faceColors?: Color4[];
  109496. faceUV?: Vector4[];
  109497. updatable?: boolean;
  109498. hasRings?: boolean;
  109499. enclose?: boolean;
  109500. sideOrientation?: number;
  109501. frontUVs?: Vector4;
  109502. backUVs?: Vector4;
  109503. }, scene?: Nullable<Scene>): Mesh;
  109504. /**
  109505. * Creates a torus mesh
  109506. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  109507. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  109508. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  109509. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109510. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109511. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109512. * @param name defines the name of the mesh
  109513. * @param options defines the options used to create the mesh
  109514. * @param scene defines the hosting scene
  109515. * @returns the torus mesh
  109516. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  109517. */
  109518. static CreateTorus(name: string, options: {
  109519. diameter?: number;
  109520. thickness?: number;
  109521. tessellation?: number;
  109522. updatable?: boolean;
  109523. sideOrientation?: number;
  109524. frontUVs?: Vector4;
  109525. backUVs?: Vector4;
  109526. }, scene?: Nullable<Scene>): Mesh;
  109527. /**
  109528. * Creates a torus knot mesh
  109529. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  109530. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  109531. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  109532. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  109533. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109534. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109535. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109536. * @param name defines the name of the mesh
  109537. * @param options defines the options used to create the mesh
  109538. * @param scene defines the hosting scene
  109539. * @returns the torus knot mesh
  109540. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  109541. */
  109542. static CreateTorusKnot(name: string, options: {
  109543. radius?: number;
  109544. tube?: number;
  109545. radialSegments?: number;
  109546. tubularSegments?: number;
  109547. p?: number;
  109548. q?: number;
  109549. updatable?: boolean;
  109550. sideOrientation?: number;
  109551. frontUVs?: Vector4;
  109552. backUVs?: Vector4;
  109553. }, scene?: Nullable<Scene>): Mesh;
  109554. /**
  109555. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  109556. * * 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
  109557. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  109558. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  109559. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  109560. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  109561. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  109562. * * 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
  109563. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  109564. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109565. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  109566. * @param name defines the name of the new line system
  109567. * @param options defines the options used to create the line system
  109568. * @param scene defines the hosting scene
  109569. * @returns a new line system mesh
  109570. */
  109571. static CreateLineSystem(name: string, options: {
  109572. lines: Vector3[][];
  109573. updatable?: boolean;
  109574. instance?: Nullable<LinesMesh>;
  109575. colors?: Nullable<Color4[][]>;
  109576. useVertexAlpha?: boolean;
  109577. }, scene: Nullable<Scene>): LinesMesh;
  109578. /**
  109579. * Creates a line mesh
  109580. * 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
  109581. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  109582. * * The parameter `points` is an array successive Vector3
  109583. * * 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
  109584. * * The optional parameter `colors` is an array of successive Color4, one per line point
  109585. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  109586. * * When updating an instance, remember that only point positions can change, not the number of points
  109587. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109588. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  109589. * @param name defines the name of the new line system
  109590. * @param options defines the options used to create the line system
  109591. * @param scene defines the hosting scene
  109592. * @returns a new line mesh
  109593. */
  109594. static CreateLines(name: string, options: {
  109595. points: Vector3[];
  109596. updatable?: boolean;
  109597. instance?: Nullable<LinesMesh>;
  109598. colors?: Color4[];
  109599. useVertexAlpha?: boolean;
  109600. }, scene?: Nullable<Scene>): LinesMesh;
  109601. /**
  109602. * Creates a dashed line mesh
  109603. * * 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
  109604. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  109605. * * The parameter `points` is an array successive Vector3
  109606. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  109607. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  109608. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  109609. * * 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
  109610. * * When updating an instance, remember that only point positions can change, not the number of points
  109611. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109612. * @param name defines the name of the mesh
  109613. * @param options defines the options used to create the mesh
  109614. * @param scene defines the hosting scene
  109615. * @returns the dashed line mesh
  109616. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  109617. */
  109618. static CreateDashedLines(name: string, options: {
  109619. points: Vector3[];
  109620. dashSize?: number;
  109621. gapSize?: number;
  109622. dashNb?: number;
  109623. updatable?: boolean;
  109624. instance?: LinesMesh;
  109625. }, scene?: Nullable<Scene>): LinesMesh;
  109626. /**
  109627. * 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.
  109628. * * 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.
  109629. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  109630. * * 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.
  109631. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  109632. * * 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
  109633. * * 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
  109634. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  109635. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109636. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109637. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  109638. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109639. * @param name defines the name of the mesh
  109640. * @param options defines the options used to create the mesh
  109641. * @param scene defines the hosting scene
  109642. * @returns the extruded shape mesh
  109643. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109644. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  109645. */
  109646. static ExtrudeShape(name: string, options: {
  109647. shape: Vector3[];
  109648. path: Vector3[];
  109649. scale?: number;
  109650. rotation?: number;
  109651. cap?: number;
  109652. updatable?: boolean;
  109653. sideOrientation?: number;
  109654. frontUVs?: Vector4;
  109655. backUVs?: Vector4;
  109656. instance?: Mesh;
  109657. invertUV?: boolean;
  109658. }, scene?: Nullable<Scene>): Mesh;
  109659. /**
  109660. * Creates an custom extruded shape mesh.
  109661. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  109662. * * 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.
  109663. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  109664. * * 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
  109665. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  109666. * * 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
  109667. * * It must returns a float value that will be the scale value applied to the shape on each path point
  109668. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  109669. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  109670. * * 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
  109671. * * 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
  109672. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  109673. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109674. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109675. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109676. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109677. * @param name defines the name of the mesh
  109678. * @param options defines the options used to create the mesh
  109679. * @param scene defines the hosting scene
  109680. * @returns the custom extruded shape mesh
  109681. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  109682. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109683. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  109684. */
  109685. static ExtrudeShapeCustom(name: string, options: {
  109686. shape: Vector3[];
  109687. path: Vector3[];
  109688. scaleFunction?: any;
  109689. rotationFunction?: any;
  109690. ribbonCloseArray?: boolean;
  109691. ribbonClosePath?: boolean;
  109692. cap?: number;
  109693. updatable?: boolean;
  109694. sideOrientation?: number;
  109695. frontUVs?: Vector4;
  109696. backUVs?: Vector4;
  109697. instance?: Mesh;
  109698. invertUV?: boolean;
  109699. }, scene?: Nullable<Scene>): Mesh;
  109700. /**
  109701. * Creates lathe mesh.
  109702. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  109703. * * 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
  109704. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  109705. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  109706. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  109707. * * 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
  109708. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  109709. * * 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
  109710. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109711. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109712. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109713. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109714. * @param name defines the name of the mesh
  109715. * @param options defines the options used to create the mesh
  109716. * @param scene defines the hosting scene
  109717. * @returns the lathe mesh
  109718. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  109719. */
  109720. static CreateLathe(name: string, options: {
  109721. shape: Vector3[];
  109722. radius?: number;
  109723. tessellation?: number;
  109724. clip?: number;
  109725. arc?: number;
  109726. closed?: boolean;
  109727. updatable?: boolean;
  109728. sideOrientation?: number;
  109729. frontUVs?: Vector4;
  109730. backUVs?: Vector4;
  109731. cap?: number;
  109732. invertUV?: boolean;
  109733. }, scene?: Nullable<Scene>): Mesh;
  109734. /**
  109735. * Creates a plane mesh
  109736. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  109737. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  109738. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  109739. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109740. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109741. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109742. * @param name defines the name of the mesh
  109743. * @param options defines the options used to create the mesh
  109744. * @param scene defines the hosting scene
  109745. * @returns the plane mesh
  109746. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  109747. */
  109748. static CreatePlane(name: string, options: {
  109749. size?: number;
  109750. width?: number;
  109751. height?: number;
  109752. sideOrientation?: number;
  109753. frontUVs?: Vector4;
  109754. backUVs?: Vector4;
  109755. updatable?: boolean;
  109756. sourcePlane?: Plane;
  109757. }, scene?: Nullable<Scene>): Mesh;
  109758. /**
  109759. * Creates a ground mesh
  109760. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  109761. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  109762. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109763. * @param name defines the name of the mesh
  109764. * @param options defines the options used to create the mesh
  109765. * @param scene defines the hosting scene
  109766. * @returns the ground mesh
  109767. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  109768. */
  109769. static CreateGround(name: string, options: {
  109770. width?: number;
  109771. height?: number;
  109772. subdivisions?: number;
  109773. subdivisionsX?: number;
  109774. subdivisionsY?: number;
  109775. updatable?: boolean;
  109776. }, scene?: Nullable<Scene>): Mesh;
  109777. /**
  109778. * Creates a tiled ground mesh
  109779. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  109780. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  109781. * * 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
  109782. * * 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
  109783. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109784. * @param name defines the name of the mesh
  109785. * @param options defines the options used to create the mesh
  109786. * @param scene defines the hosting scene
  109787. * @returns the tiled ground mesh
  109788. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  109789. */
  109790. static CreateTiledGround(name: string, options: {
  109791. xmin: number;
  109792. zmin: number;
  109793. xmax: number;
  109794. zmax: number;
  109795. subdivisions?: {
  109796. w: number;
  109797. h: number;
  109798. };
  109799. precision?: {
  109800. w: number;
  109801. h: number;
  109802. };
  109803. updatable?: boolean;
  109804. }, scene?: Nullable<Scene>): Mesh;
  109805. /**
  109806. * Creates a ground mesh from a height map
  109807. * * The parameter `url` sets the URL of the height map image resource.
  109808. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  109809. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  109810. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  109811. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  109812. * * 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.
  109813. * * 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).
  109814. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  109815. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109816. * @param name defines the name of the mesh
  109817. * @param url defines the url to the height map
  109818. * @param options defines the options used to create the mesh
  109819. * @param scene defines the hosting scene
  109820. * @returns the ground mesh
  109821. * @see https://doc.babylonjs.com/babylon101/height_map
  109822. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  109823. */
  109824. static CreateGroundFromHeightMap(name: string, url: string, options: {
  109825. width?: number;
  109826. height?: number;
  109827. subdivisions?: number;
  109828. minHeight?: number;
  109829. maxHeight?: number;
  109830. colorFilter?: Color3;
  109831. alphaFilter?: number;
  109832. updatable?: boolean;
  109833. onReady?: (mesh: GroundMesh) => void;
  109834. }, scene?: Nullable<Scene>): GroundMesh;
  109835. /**
  109836. * Creates a polygon mesh
  109837. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  109838. * * 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
  109839. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109840. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109841. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  109842. * * Remember you can only change the shape positions, not their number when updating a polygon
  109843. * @param name defines the name of the mesh
  109844. * @param options defines the options used to create the mesh
  109845. * @param scene defines the hosting scene
  109846. * @param earcutInjection can be used to inject your own earcut reference
  109847. * @returns the polygon mesh
  109848. */
  109849. static CreatePolygon(name: string, options: {
  109850. shape: Vector3[];
  109851. holes?: Vector3[][];
  109852. depth?: number;
  109853. faceUV?: Vector4[];
  109854. faceColors?: Color4[];
  109855. updatable?: boolean;
  109856. sideOrientation?: number;
  109857. frontUVs?: Vector4;
  109858. backUVs?: Vector4;
  109859. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  109860. /**
  109861. * Creates an extruded polygon mesh, with depth in the Y direction.
  109862. * * 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)
  109863. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  109864. * @param name defines the name of the mesh
  109865. * @param options defines the options used to create the mesh
  109866. * @param scene defines the hosting scene
  109867. * @param earcutInjection can be used to inject your own earcut reference
  109868. * @returns the polygon mesh
  109869. */
  109870. static ExtrudePolygon(name: string, options: {
  109871. shape: Vector3[];
  109872. holes?: Vector3[][];
  109873. depth?: number;
  109874. faceUV?: Vector4[];
  109875. faceColors?: Color4[];
  109876. updatable?: boolean;
  109877. sideOrientation?: number;
  109878. frontUVs?: Vector4;
  109879. backUVs?: Vector4;
  109880. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  109881. /**
  109882. * Creates a tube mesh.
  109883. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  109884. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  109885. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  109886. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  109887. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  109888. * * 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)
  109889. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  109890. * * 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
  109891. * * 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
  109892. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109893. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109894. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109895. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109896. * @param name defines the name of the mesh
  109897. * @param options defines the options used to create the mesh
  109898. * @param scene defines the hosting scene
  109899. * @returns the tube mesh
  109900. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109901. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  109902. */
  109903. static CreateTube(name: string, options: {
  109904. path: Vector3[];
  109905. radius?: number;
  109906. tessellation?: number;
  109907. radiusFunction?: {
  109908. (i: number, distance: number): number;
  109909. };
  109910. cap?: number;
  109911. arc?: number;
  109912. updatable?: boolean;
  109913. sideOrientation?: number;
  109914. frontUVs?: Vector4;
  109915. backUVs?: Vector4;
  109916. instance?: Mesh;
  109917. invertUV?: boolean;
  109918. }, scene?: Nullable<Scene>): Mesh;
  109919. /**
  109920. * Creates a polyhedron mesh
  109921. * * 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
  109922. * * The parameter `size` (positive float, default 1) sets the polygon size
  109923. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  109924. * * 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`
  109925. * * 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
  109926. * * 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)`)
  109927. * * 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
  109928. * * 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
  109929. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109930. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109931. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109932. * @param name defines the name of the mesh
  109933. * @param options defines the options used to create the mesh
  109934. * @param scene defines the hosting scene
  109935. * @returns the polyhedron mesh
  109936. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  109937. */
  109938. static CreatePolyhedron(name: string, options: {
  109939. type?: number;
  109940. size?: number;
  109941. sizeX?: number;
  109942. sizeY?: number;
  109943. sizeZ?: number;
  109944. custom?: any;
  109945. faceUV?: Vector4[];
  109946. faceColors?: Color4[];
  109947. flat?: boolean;
  109948. updatable?: boolean;
  109949. sideOrientation?: number;
  109950. frontUVs?: Vector4;
  109951. backUVs?: Vector4;
  109952. }, scene?: Nullable<Scene>): Mesh;
  109953. /**
  109954. * Creates a decal mesh.
  109955. * 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
  109956. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  109957. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  109958. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  109959. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  109960. * @param name defines the name of the mesh
  109961. * @param sourceMesh defines the mesh where the decal must be applied
  109962. * @param options defines the options used to create the mesh
  109963. * @param scene defines the hosting scene
  109964. * @returns the decal mesh
  109965. * @see https://doc.babylonjs.com/how_to/decals
  109966. */
  109967. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  109968. position?: Vector3;
  109969. normal?: Vector3;
  109970. size?: Vector3;
  109971. angle?: number;
  109972. }): Mesh;
  109973. }
  109974. }
  109975. declare module BABYLON {
  109976. /**
  109977. * A simplifier interface for future simplification implementations
  109978. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  109979. */
  109980. export interface ISimplifier {
  109981. /**
  109982. * Simplification of a given mesh according to the given settings.
  109983. * Since this requires computation, it is assumed that the function runs async.
  109984. * @param settings The settings of the simplification, including quality and distance
  109985. * @param successCallback A callback that will be called after the mesh was simplified.
  109986. * @param errorCallback in case of an error, this callback will be called. optional.
  109987. */
  109988. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  109989. }
  109990. /**
  109991. * Expected simplification settings.
  109992. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  109993. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  109994. */
  109995. export interface ISimplificationSettings {
  109996. /**
  109997. * Gets or sets the expected quality
  109998. */
  109999. quality: number;
  110000. /**
  110001. * Gets or sets the distance when this optimized version should be used
  110002. */
  110003. distance: number;
  110004. /**
  110005. * Gets an already optimized mesh
  110006. */
  110007. optimizeMesh?: boolean;
  110008. }
  110009. /**
  110010. * Class used to specify simplification options
  110011. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110012. */
  110013. export class SimplificationSettings implements ISimplificationSettings {
  110014. /** expected quality */
  110015. quality: number;
  110016. /** distance when this optimized version should be used */
  110017. distance: number;
  110018. /** already optimized mesh */
  110019. optimizeMesh?: boolean | undefined;
  110020. /**
  110021. * Creates a SimplificationSettings
  110022. * @param quality expected quality
  110023. * @param distance distance when this optimized version should be used
  110024. * @param optimizeMesh already optimized mesh
  110025. */
  110026. constructor(
  110027. /** expected quality */
  110028. quality: number,
  110029. /** distance when this optimized version should be used */
  110030. distance: number,
  110031. /** already optimized mesh */
  110032. optimizeMesh?: boolean | undefined);
  110033. }
  110034. /**
  110035. * Interface used to define a simplification task
  110036. */
  110037. export interface ISimplificationTask {
  110038. /**
  110039. * Array of settings
  110040. */
  110041. settings: Array<ISimplificationSettings>;
  110042. /**
  110043. * Simplification type
  110044. */
  110045. simplificationType: SimplificationType;
  110046. /**
  110047. * Mesh to simplify
  110048. */
  110049. mesh: Mesh;
  110050. /**
  110051. * Callback called on success
  110052. */
  110053. successCallback?: () => void;
  110054. /**
  110055. * Defines if parallel processing can be used
  110056. */
  110057. parallelProcessing: boolean;
  110058. }
  110059. /**
  110060. * Queue used to order the simplification tasks
  110061. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110062. */
  110063. export class SimplificationQueue {
  110064. private _simplificationArray;
  110065. /**
  110066. * Gets a boolean indicating that the process is still running
  110067. */
  110068. running: boolean;
  110069. /**
  110070. * Creates a new queue
  110071. */
  110072. constructor();
  110073. /**
  110074. * Adds a new simplification task
  110075. * @param task defines a task to add
  110076. */
  110077. addTask(task: ISimplificationTask): void;
  110078. /**
  110079. * Execute next task
  110080. */
  110081. executeNext(): void;
  110082. /**
  110083. * Execute a simplification task
  110084. * @param task defines the task to run
  110085. */
  110086. runSimplification(task: ISimplificationTask): void;
  110087. private getSimplifier;
  110088. }
  110089. /**
  110090. * The implemented types of simplification
  110091. * At the moment only Quadratic Error Decimation is implemented
  110092. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110093. */
  110094. export enum SimplificationType {
  110095. /** Quadratic error decimation */
  110096. QUADRATIC = 0
  110097. }
  110098. }
  110099. declare module BABYLON {
  110100. interface Scene {
  110101. /** @hidden (Backing field) */
  110102. _simplificationQueue: SimplificationQueue;
  110103. /**
  110104. * Gets or sets the simplification queue attached to the scene
  110105. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110106. */
  110107. simplificationQueue: SimplificationQueue;
  110108. }
  110109. interface Mesh {
  110110. /**
  110111. * Simplify the mesh according to the given array of settings.
  110112. * Function will return immediately and will simplify async
  110113. * @param settings a collection of simplification settings
  110114. * @param parallelProcessing should all levels calculate parallel or one after the other
  110115. * @param simplificationType the type of simplification to run
  110116. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  110117. * @returns the current mesh
  110118. */
  110119. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  110120. }
  110121. /**
  110122. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  110123. * created in a scene
  110124. */
  110125. export class SimplicationQueueSceneComponent implements ISceneComponent {
  110126. /**
  110127. * The component name helpfull to identify the component in the list of scene components.
  110128. */
  110129. readonly name: string;
  110130. /**
  110131. * The scene the component belongs to.
  110132. */
  110133. scene: Scene;
  110134. /**
  110135. * Creates a new instance of the component for the given scene
  110136. * @param scene Defines the scene to register the component in
  110137. */
  110138. constructor(scene: Scene);
  110139. /**
  110140. * Registers the component in a given scene
  110141. */
  110142. register(): void;
  110143. /**
  110144. * Rebuilds the elements related to this component in case of
  110145. * context lost for instance.
  110146. */
  110147. rebuild(): void;
  110148. /**
  110149. * Disposes the component and the associated ressources
  110150. */
  110151. dispose(): void;
  110152. private _beforeCameraUpdate;
  110153. }
  110154. }
  110155. declare module BABYLON {
  110156. /**
  110157. * Class used to enable access to IndexedDB
  110158. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  110159. */
  110160. export class Database implements IOfflineProvider {
  110161. private _callbackManifestChecked;
  110162. private _currentSceneUrl;
  110163. private _db;
  110164. private _enableSceneOffline;
  110165. private _enableTexturesOffline;
  110166. private _manifestVersionFound;
  110167. private _mustUpdateRessources;
  110168. private _hasReachedQuota;
  110169. private _isSupported;
  110170. private _idbFactory;
  110171. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  110172. private static IsUASupportingBlobStorage;
  110173. /**
  110174. * Gets a boolean indicating if Database storate is enabled (off by default)
  110175. */
  110176. static IDBStorageEnabled: boolean;
  110177. /**
  110178. * Gets a boolean indicating if scene must be saved in the database
  110179. */
  110180. readonly enableSceneOffline: boolean;
  110181. /**
  110182. * Gets a boolean indicating if textures must be saved in the database
  110183. */
  110184. readonly enableTexturesOffline: boolean;
  110185. /**
  110186. * Creates a new Database
  110187. * @param urlToScene defines the url to load the scene
  110188. * @param callbackManifestChecked defines the callback to use when manifest is checked
  110189. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  110190. */
  110191. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  110192. private static _ParseURL;
  110193. private static _ReturnFullUrlLocation;
  110194. private _checkManifestFile;
  110195. /**
  110196. * Open the database and make it available
  110197. * @param successCallback defines the callback to call on success
  110198. * @param errorCallback defines the callback to call on error
  110199. */
  110200. open(successCallback: () => void, errorCallback: () => void): void;
  110201. /**
  110202. * Loads an image from the database
  110203. * @param url defines the url to load from
  110204. * @param image defines the target DOM image
  110205. */
  110206. loadImage(url: string, image: HTMLImageElement): void;
  110207. private _loadImageFromDBAsync;
  110208. private _saveImageIntoDBAsync;
  110209. private _checkVersionFromDB;
  110210. private _loadVersionFromDBAsync;
  110211. private _saveVersionIntoDBAsync;
  110212. /**
  110213. * Loads a file from database
  110214. * @param url defines the URL to load from
  110215. * @param sceneLoaded defines a callback to call on success
  110216. * @param progressCallBack defines a callback to call when progress changed
  110217. * @param errorCallback defines a callback to call on error
  110218. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  110219. */
  110220. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  110221. private _loadFileAsync;
  110222. private _saveFileAsync;
  110223. /**
  110224. * Validates if xhr data is correct
  110225. * @param xhr defines the request to validate
  110226. * @param dataType defines the expected data type
  110227. * @returns true if data is correct
  110228. */
  110229. private static _ValidateXHRData;
  110230. }
  110231. }
  110232. declare module BABYLON {
  110233. /** @hidden */
  110234. export var gpuUpdateParticlesPixelShader: {
  110235. name: string;
  110236. shader: string;
  110237. };
  110238. }
  110239. declare module BABYLON {
  110240. /** @hidden */
  110241. export var gpuUpdateParticlesVertexShader: {
  110242. name: string;
  110243. shader: string;
  110244. };
  110245. }
  110246. declare module BABYLON {
  110247. /** @hidden */
  110248. export var clipPlaneFragmentDeclaration2: {
  110249. name: string;
  110250. shader: string;
  110251. };
  110252. }
  110253. declare module BABYLON {
  110254. /** @hidden */
  110255. export var gpuRenderParticlesPixelShader: {
  110256. name: string;
  110257. shader: string;
  110258. };
  110259. }
  110260. declare module BABYLON {
  110261. /** @hidden */
  110262. export var clipPlaneVertexDeclaration2: {
  110263. name: string;
  110264. shader: string;
  110265. };
  110266. }
  110267. declare module BABYLON {
  110268. /** @hidden */
  110269. export var gpuRenderParticlesVertexShader: {
  110270. name: string;
  110271. shader: string;
  110272. };
  110273. }
  110274. declare module BABYLON {
  110275. /**
  110276. * This represents a GPU particle system in Babylon
  110277. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  110278. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  110279. */
  110280. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  110281. /**
  110282. * The layer mask we are rendering the particles through.
  110283. */
  110284. layerMask: number;
  110285. private _capacity;
  110286. private _activeCount;
  110287. private _currentActiveCount;
  110288. private _accumulatedCount;
  110289. private _renderEffect;
  110290. private _updateEffect;
  110291. private _buffer0;
  110292. private _buffer1;
  110293. private _spriteBuffer;
  110294. private _updateVAO;
  110295. private _renderVAO;
  110296. private _targetIndex;
  110297. private _sourceBuffer;
  110298. private _targetBuffer;
  110299. private _engine;
  110300. private _currentRenderId;
  110301. private _started;
  110302. private _stopped;
  110303. private _timeDelta;
  110304. private _randomTexture;
  110305. private _randomTexture2;
  110306. private _attributesStrideSize;
  110307. private _updateEffectOptions;
  110308. private _randomTextureSize;
  110309. private _actualFrame;
  110310. private readonly _rawTextureWidth;
  110311. /**
  110312. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  110313. */
  110314. static readonly IsSupported: boolean;
  110315. /**
  110316. * An event triggered when the system is disposed.
  110317. */
  110318. onDisposeObservable: Observable<GPUParticleSystem>;
  110319. /**
  110320. * Gets the maximum number of particles active at the same time.
  110321. * @returns The max number of active particles.
  110322. */
  110323. getCapacity(): number;
  110324. /**
  110325. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  110326. * to override the particles.
  110327. */
  110328. forceDepthWrite: boolean;
  110329. /**
  110330. * Gets or set the number of active particles
  110331. */
  110332. activeParticleCount: number;
  110333. private _preWarmDone;
  110334. /**
  110335. * Is this system ready to be used/rendered
  110336. * @return true if the system is ready
  110337. */
  110338. isReady(): boolean;
  110339. /**
  110340. * Gets if the system has been started. (Note: this will still be true after stop is called)
  110341. * @returns True if it has been started, otherwise false.
  110342. */
  110343. isStarted(): boolean;
  110344. /**
  110345. * Starts the particle system and begins to emit
  110346. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  110347. */
  110348. start(delay?: number): void;
  110349. /**
  110350. * Stops the particle system.
  110351. */
  110352. stop(): void;
  110353. /**
  110354. * Remove all active particles
  110355. */
  110356. reset(): void;
  110357. /**
  110358. * Returns the string "GPUParticleSystem"
  110359. * @returns a string containing the class name
  110360. */
  110361. getClassName(): string;
  110362. private _colorGradientsTexture;
  110363. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  110364. /**
  110365. * Adds a new color gradient
  110366. * @param gradient defines the gradient to use (between 0 and 1)
  110367. * @param color1 defines the color to affect to the specified gradient
  110368. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  110369. * @returns the current particle system
  110370. */
  110371. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  110372. /**
  110373. * Remove a specific color gradient
  110374. * @param gradient defines the gradient to remove
  110375. * @returns the current particle system
  110376. */
  110377. removeColorGradient(gradient: number): GPUParticleSystem;
  110378. private _angularSpeedGradientsTexture;
  110379. private _sizeGradientsTexture;
  110380. private _velocityGradientsTexture;
  110381. private _limitVelocityGradientsTexture;
  110382. private _dragGradientsTexture;
  110383. private _addFactorGradient;
  110384. /**
  110385. * Adds a new size gradient
  110386. * @param gradient defines the gradient to use (between 0 and 1)
  110387. * @param factor defines the size factor to affect to the specified gradient
  110388. * @returns the current particle system
  110389. */
  110390. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  110391. /**
  110392. * Remove a specific size gradient
  110393. * @param gradient defines the gradient to remove
  110394. * @returns the current particle system
  110395. */
  110396. removeSizeGradient(gradient: number): GPUParticleSystem;
  110397. /**
  110398. * Adds a new angular speed gradient
  110399. * @param gradient defines the gradient to use (between 0 and 1)
  110400. * @param factor defines the angular speed to affect to the specified gradient
  110401. * @returns the current particle system
  110402. */
  110403. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  110404. /**
  110405. * Remove a specific angular speed gradient
  110406. * @param gradient defines the gradient to remove
  110407. * @returns the current particle system
  110408. */
  110409. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  110410. /**
  110411. * Adds a new velocity gradient
  110412. * @param gradient defines the gradient to use (between 0 and 1)
  110413. * @param factor defines the velocity to affect to the specified gradient
  110414. * @returns the current particle system
  110415. */
  110416. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  110417. /**
  110418. * Remove a specific velocity gradient
  110419. * @param gradient defines the gradient to remove
  110420. * @returns the current particle system
  110421. */
  110422. removeVelocityGradient(gradient: number): GPUParticleSystem;
  110423. /**
  110424. * Adds a new limit velocity gradient
  110425. * @param gradient defines the gradient to use (between 0 and 1)
  110426. * @param factor defines the limit velocity value to affect to the specified gradient
  110427. * @returns the current particle system
  110428. */
  110429. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  110430. /**
  110431. * Remove a specific limit velocity gradient
  110432. * @param gradient defines the gradient to remove
  110433. * @returns the current particle system
  110434. */
  110435. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  110436. /**
  110437. * Adds a new drag gradient
  110438. * @param gradient defines the gradient to use (between 0 and 1)
  110439. * @param factor defines the drag value to affect to the specified gradient
  110440. * @returns the current particle system
  110441. */
  110442. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  110443. /**
  110444. * Remove a specific drag gradient
  110445. * @param gradient defines the gradient to remove
  110446. * @returns the current particle system
  110447. */
  110448. removeDragGradient(gradient: number): GPUParticleSystem;
  110449. /**
  110450. * Not supported by GPUParticleSystem
  110451. * @param gradient defines the gradient to use (between 0 and 1)
  110452. * @param factor defines the emit rate value to affect to the specified gradient
  110453. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110454. * @returns the current particle system
  110455. */
  110456. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  110457. /**
  110458. * Not supported by GPUParticleSystem
  110459. * @param gradient defines the gradient to remove
  110460. * @returns the current particle system
  110461. */
  110462. removeEmitRateGradient(gradient: number): IParticleSystem;
  110463. /**
  110464. * Not supported by GPUParticleSystem
  110465. * @param gradient defines the gradient to use (between 0 and 1)
  110466. * @param factor defines the start size value to affect to the specified gradient
  110467. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110468. * @returns the current particle system
  110469. */
  110470. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  110471. /**
  110472. * Not supported by GPUParticleSystem
  110473. * @param gradient defines the gradient to remove
  110474. * @returns the current particle system
  110475. */
  110476. removeStartSizeGradient(gradient: number): IParticleSystem;
  110477. /**
  110478. * Not supported by GPUParticleSystem
  110479. * @param gradient defines the gradient to use (between 0 and 1)
  110480. * @param min defines the color remap minimal range
  110481. * @param max defines the color remap maximal range
  110482. * @returns the current particle system
  110483. */
  110484. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  110485. /**
  110486. * Not supported by GPUParticleSystem
  110487. * @param gradient defines the gradient to remove
  110488. * @returns the current particle system
  110489. */
  110490. removeColorRemapGradient(): IParticleSystem;
  110491. /**
  110492. * Not supported by GPUParticleSystem
  110493. * @param gradient defines the gradient to use (between 0 and 1)
  110494. * @param min defines the alpha remap minimal range
  110495. * @param max defines the alpha remap maximal range
  110496. * @returns the current particle system
  110497. */
  110498. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  110499. /**
  110500. * Not supported by GPUParticleSystem
  110501. * @param gradient defines the gradient to remove
  110502. * @returns the current particle system
  110503. */
  110504. removeAlphaRemapGradient(): IParticleSystem;
  110505. /**
  110506. * Not supported by GPUParticleSystem
  110507. * @param gradient defines the gradient to use (between 0 and 1)
  110508. * @param color defines the color to affect to the specified gradient
  110509. * @returns the current particle system
  110510. */
  110511. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  110512. /**
  110513. * Not supported by GPUParticleSystem
  110514. * @param gradient defines the gradient to remove
  110515. * @returns the current particle system
  110516. */
  110517. removeRampGradient(): IParticleSystem;
  110518. /**
  110519. * Not supported by GPUParticleSystem
  110520. * @returns the list of ramp gradients
  110521. */
  110522. getRampGradients(): Nullable<Array<Color3Gradient>>;
  110523. /**
  110524. * Not supported by GPUParticleSystem
  110525. * Gets or sets a boolean indicating that ramp gradients must be used
  110526. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  110527. */
  110528. useRampGradients: boolean;
  110529. /**
  110530. * Not supported by GPUParticleSystem
  110531. * @param gradient defines the gradient to use (between 0 and 1)
  110532. * @param factor defines the life time factor to affect to the specified gradient
  110533. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110534. * @returns the current particle system
  110535. */
  110536. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  110537. /**
  110538. * Not supported by GPUParticleSystem
  110539. * @param gradient defines the gradient to remove
  110540. * @returns the current particle system
  110541. */
  110542. removeLifeTimeGradient(gradient: number): IParticleSystem;
  110543. /**
  110544. * Instantiates a GPU particle system.
  110545. * 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.
  110546. * @param name The name of the particle system
  110547. * @param options The options used to create the system
  110548. * @param scene The scene the particle system belongs to
  110549. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  110550. */
  110551. constructor(name: string, options: Partial<{
  110552. capacity: number;
  110553. randomTextureSize: number;
  110554. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  110555. protected _reset(): void;
  110556. private _createUpdateVAO;
  110557. private _createRenderVAO;
  110558. private _initialize;
  110559. /** @hidden */
  110560. _recreateUpdateEffect(): void;
  110561. /** @hidden */
  110562. _recreateRenderEffect(): void;
  110563. /**
  110564. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  110565. * @param preWarm defines if we are in the pre-warmimg phase
  110566. */
  110567. animate(preWarm?: boolean): void;
  110568. private _createFactorGradientTexture;
  110569. private _createSizeGradientTexture;
  110570. private _createAngularSpeedGradientTexture;
  110571. private _createVelocityGradientTexture;
  110572. private _createLimitVelocityGradientTexture;
  110573. private _createDragGradientTexture;
  110574. private _createColorGradientTexture;
  110575. /**
  110576. * Renders the particle system in its current state
  110577. * @param preWarm defines if the system should only update the particles but not render them
  110578. * @returns the current number of particles
  110579. */
  110580. render(preWarm?: boolean): number;
  110581. /**
  110582. * Rebuilds the particle system
  110583. */
  110584. rebuild(): void;
  110585. private _releaseBuffers;
  110586. private _releaseVAOs;
  110587. /**
  110588. * Disposes the particle system and free the associated resources
  110589. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  110590. */
  110591. dispose(disposeTexture?: boolean): void;
  110592. /**
  110593. * Clones the particle system.
  110594. * @param name The name of the cloned object
  110595. * @param newEmitter The new emitter to use
  110596. * @returns the cloned particle system
  110597. */
  110598. clone(name: string, newEmitter: any): GPUParticleSystem;
  110599. /**
  110600. * Serializes the particle system to a JSON object.
  110601. * @returns the JSON object
  110602. */
  110603. serialize(): any;
  110604. /**
  110605. * Parses a JSON object to create a GPU particle system.
  110606. * @param parsedParticleSystem The JSON object to parse
  110607. * @param scene The scene to create the particle system in
  110608. * @param rootUrl The root url to use to load external dependencies like texture
  110609. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  110610. * @returns the parsed GPU particle system
  110611. */
  110612. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  110613. }
  110614. }
  110615. declare module BABYLON {
  110616. /**
  110617. * Represents a set of particle systems working together to create a specific effect
  110618. */
  110619. export class ParticleSystemSet implements IDisposable {
  110620. private _emitterCreationOptions;
  110621. private _emitterNode;
  110622. /**
  110623. * Gets the particle system list
  110624. */
  110625. systems: IParticleSystem[];
  110626. /**
  110627. * Gets the emitter node used with this set
  110628. */
  110629. readonly emitterNode: Nullable<TransformNode>;
  110630. /**
  110631. * Creates a new emitter mesh as a sphere
  110632. * @param options defines the options used to create the sphere
  110633. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  110634. * @param scene defines the hosting scene
  110635. */
  110636. setEmitterAsSphere(options: {
  110637. diameter: number;
  110638. segments: number;
  110639. color: Color3;
  110640. }, renderingGroupId: number, scene: Scene): void;
  110641. /**
  110642. * Starts all particle systems of the set
  110643. * @param emitter defines an optional mesh to use as emitter for the particle systems
  110644. */
  110645. start(emitter?: AbstractMesh): void;
  110646. /**
  110647. * Release all associated resources
  110648. */
  110649. dispose(): void;
  110650. /**
  110651. * Serialize the set into a JSON compatible object
  110652. * @returns a JSON compatible representation of the set
  110653. */
  110654. serialize(): any;
  110655. /**
  110656. * Parse a new ParticleSystemSet from a serialized source
  110657. * @param data defines a JSON compatible representation of the set
  110658. * @param scene defines the hosting scene
  110659. * @param gpu defines if we want GPU particles or CPU particles
  110660. * @returns a new ParticleSystemSet
  110661. */
  110662. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  110663. }
  110664. }
  110665. declare module BABYLON {
  110666. /**
  110667. * This class is made for on one-liner static method to help creating particle system set.
  110668. */
  110669. export class ParticleHelper {
  110670. /**
  110671. * Gets or sets base Assets URL
  110672. */
  110673. static BaseAssetsUrl: string;
  110674. /**
  110675. * Create a default particle system that you can tweak
  110676. * @param emitter defines the emitter to use
  110677. * @param capacity defines the system capacity (default is 500 particles)
  110678. * @param scene defines the hosting scene
  110679. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  110680. * @returns the new Particle system
  110681. */
  110682. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  110683. /**
  110684. * This is the main static method (one-liner) of this helper to create different particle systems
  110685. * @param type This string represents the type to the particle system to create
  110686. * @param scene The scene where the particle system should live
  110687. * @param gpu If the system will use gpu
  110688. * @returns the ParticleSystemSet created
  110689. */
  110690. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  110691. /**
  110692. * Static function used to export a particle system to a ParticleSystemSet variable.
  110693. * Please note that the emitter shape is not exported
  110694. * @param systems defines the particle systems to export
  110695. * @returns the created particle system set
  110696. */
  110697. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  110698. }
  110699. }
  110700. declare module BABYLON {
  110701. interface Engine {
  110702. /**
  110703. * Create an effect to use with particle systems.
  110704. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  110705. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  110706. * @param uniformsNames defines a list of attribute names
  110707. * @param samplers defines an array of string used to represent textures
  110708. * @param defines defines the string containing the defines to use to compile the shaders
  110709. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  110710. * @param onCompiled defines a function to call when the effect creation is successful
  110711. * @param onError defines a function to call when the effect creation has failed
  110712. * @returns the new Effect
  110713. */
  110714. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  110715. }
  110716. interface Mesh {
  110717. /**
  110718. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  110719. * @returns an array of IParticleSystem
  110720. */
  110721. getEmittedParticleSystems(): IParticleSystem[];
  110722. /**
  110723. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  110724. * @returns an array of IParticleSystem
  110725. */
  110726. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  110727. }
  110728. /**
  110729. * @hidden
  110730. */
  110731. export var _IDoNeedToBeInTheBuild: number;
  110732. }
  110733. declare module BABYLON {
  110734. interface Scene {
  110735. /** @hidden (Backing field) */
  110736. _physicsEngine: Nullable<IPhysicsEngine>;
  110737. /**
  110738. * Gets the current physics engine
  110739. * @returns a IPhysicsEngine or null if none attached
  110740. */
  110741. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  110742. /**
  110743. * Enables physics to the current scene
  110744. * @param gravity defines the scene's gravity for the physics engine
  110745. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  110746. * @return a boolean indicating if the physics engine was initialized
  110747. */
  110748. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  110749. /**
  110750. * Disables and disposes the physics engine associated with the scene
  110751. */
  110752. disablePhysicsEngine(): void;
  110753. /**
  110754. * Gets a boolean indicating if there is an active physics engine
  110755. * @returns a boolean indicating if there is an active physics engine
  110756. */
  110757. isPhysicsEnabled(): boolean;
  110758. /**
  110759. * Deletes a physics compound impostor
  110760. * @param compound defines the compound to delete
  110761. */
  110762. deleteCompoundImpostor(compound: any): void;
  110763. /**
  110764. * An event triggered when physic simulation is about to be run
  110765. */
  110766. onBeforePhysicsObservable: Observable<Scene>;
  110767. /**
  110768. * An event triggered when physic simulation has been done
  110769. */
  110770. onAfterPhysicsObservable: Observable<Scene>;
  110771. }
  110772. interface AbstractMesh {
  110773. /** @hidden */
  110774. _physicsImpostor: Nullable<PhysicsImpostor>;
  110775. /**
  110776. * Gets or sets impostor used for physic simulation
  110777. * @see http://doc.babylonjs.com/features/physics_engine
  110778. */
  110779. physicsImpostor: Nullable<PhysicsImpostor>;
  110780. /**
  110781. * Gets the current physics impostor
  110782. * @see http://doc.babylonjs.com/features/physics_engine
  110783. * @returns a physics impostor or null
  110784. */
  110785. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  110786. /** Apply a physic impulse to the mesh
  110787. * @param force defines the force to apply
  110788. * @param contactPoint defines where to apply the force
  110789. * @returns the current mesh
  110790. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  110791. */
  110792. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  110793. /**
  110794. * Creates a physic joint between two meshes
  110795. * @param otherMesh defines the other mesh to use
  110796. * @param pivot1 defines the pivot to use on this mesh
  110797. * @param pivot2 defines the pivot to use on the other mesh
  110798. * @param options defines additional options (can be plugin dependent)
  110799. * @returns the current mesh
  110800. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  110801. */
  110802. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  110803. /** @hidden */
  110804. _disposePhysicsObserver: Nullable<Observer<Node>>;
  110805. }
  110806. /**
  110807. * Defines the physics engine scene component responsible to manage a physics engine
  110808. */
  110809. export class PhysicsEngineSceneComponent implements ISceneComponent {
  110810. /**
  110811. * The component name helpful to identify the component in the list of scene components.
  110812. */
  110813. readonly name: string;
  110814. /**
  110815. * The scene the component belongs to.
  110816. */
  110817. scene: Scene;
  110818. /**
  110819. * Creates a new instance of the component for the given scene
  110820. * @param scene Defines the scene to register the component in
  110821. */
  110822. constructor(scene: Scene);
  110823. /**
  110824. * Registers the component in a given scene
  110825. */
  110826. register(): void;
  110827. /**
  110828. * Rebuilds the elements related to this component in case of
  110829. * context lost for instance.
  110830. */
  110831. rebuild(): void;
  110832. /**
  110833. * Disposes the component and the associated ressources
  110834. */
  110835. dispose(): void;
  110836. }
  110837. }
  110838. declare module BABYLON {
  110839. /**
  110840. * A helper for physics simulations
  110841. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  110842. */
  110843. export class PhysicsHelper {
  110844. private _scene;
  110845. private _physicsEngine;
  110846. /**
  110847. * Initializes the Physics helper
  110848. * @param scene Babylon.js scene
  110849. */
  110850. constructor(scene: Scene);
  110851. /**
  110852. * Applies a radial explosion impulse
  110853. * @param origin the origin of the explosion
  110854. * @param radiusOrEventOptions the radius or the options of radial explosion
  110855. * @param strength the explosion strength
  110856. * @param falloff possible options: Constant & Linear. Defaults to Constant
  110857. * @returns A physics radial explosion event, or null
  110858. */
  110859. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  110860. /**
  110861. * Applies a radial explosion force
  110862. * @param origin the origin of the explosion
  110863. * @param radiusOrEventOptions the radius or the options of radial explosion
  110864. * @param strength the explosion strength
  110865. * @param falloff possible options: Constant & Linear. Defaults to Constant
  110866. * @returns A physics radial explosion event, or null
  110867. */
  110868. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  110869. /**
  110870. * Creates a gravitational field
  110871. * @param origin the origin of the explosion
  110872. * @param radiusOrEventOptions the radius or the options of radial explosion
  110873. * @param strength the explosion strength
  110874. * @param falloff possible options: Constant & Linear. Defaults to Constant
  110875. * @returns A physics gravitational field event, or null
  110876. */
  110877. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  110878. /**
  110879. * Creates a physics updraft event
  110880. * @param origin the origin of the updraft
  110881. * @param radiusOrEventOptions the radius or the options of the updraft
  110882. * @param strength the strength of the updraft
  110883. * @param height the height of the updraft
  110884. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  110885. * @returns A physics updraft event, or null
  110886. */
  110887. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  110888. /**
  110889. * Creates a physics vortex event
  110890. * @param origin the of the vortex
  110891. * @param radiusOrEventOptions the radius or the options of the vortex
  110892. * @param strength the strength of the vortex
  110893. * @param height the height of the vortex
  110894. * @returns a Physics vortex event, or null
  110895. * A physics vortex event or null
  110896. */
  110897. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  110898. }
  110899. /**
  110900. * Represents a physics radial explosion event
  110901. */
  110902. class PhysicsRadialExplosionEvent {
  110903. private _scene;
  110904. private _options;
  110905. private _sphere;
  110906. private _dataFetched;
  110907. /**
  110908. * Initializes a radial explosioin event
  110909. * @param _scene BabylonJS scene
  110910. * @param _options The options for the vortex event
  110911. */
  110912. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  110913. /**
  110914. * Returns the data related to the radial explosion event (sphere).
  110915. * @returns The radial explosion event data
  110916. */
  110917. getData(): PhysicsRadialExplosionEventData;
  110918. /**
  110919. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  110920. * @param impostor A physics imposter
  110921. * @param origin the origin of the explosion
  110922. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  110923. */
  110924. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  110925. /**
  110926. * Triggers affecterd impostors callbacks
  110927. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  110928. */
  110929. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  110930. /**
  110931. * Disposes the sphere.
  110932. * @param force Specifies if the sphere should be disposed by force
  110933. */
  110934. dispose(force?: boolean): void;
  110935. /*** Helpers ***/
  110936. private _prepareSphere;
  110937. private _intersectsWithSphere;
  110938. }
  110939. /**
  110940. * Represents a gravitational field event
  110941. */
  110942. class PhysicsGravitationalFieldEvent {
  110943. private _physicsHelper;
  110944. private _scene;
  110945. private _origin;
  110946. private _options;
  110947. private _tickCallback;
  110948. private _sphere;
  110949. private _dataFetched;
  110950. /**
  110951. * Initializes the physics gravitational field event
  110952. * @param _physicsHelper A physics helper
  110953. * @param _scene BabylonJS scene
  110954. * @param _origin The origin position of the gravitational field event
  110955. * @param _options The options for the vortex event
  110956. */
  110957. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  110958. /**
  110959. * Returns the data related to the gravitational field event (sphere).
  110960. * @returns A gravitational field event
  110961. */
  110962. getData(): PhysicsGravitationalFieldEventData;
  110963. /**
  110964. * Enables the gravitational field.
  110965. */
  110966. enable(): void;
  110967. /**
  110968. * Disables the gravitational field.
  110969. */
  110970. disable(): void;
  110971. /**
  110972. * Disposes the sphere.
  110973. * @param force The force to dispose from the gravitational field event
  110974. */
  110975. dispose(force?: boolean): void;
  110976. private _tick;
  110977. }
  110978. /**
  110979. * Represents a physics updraft event
  110980. */
  110981. class PhysicsUpdraftEvent {
  110982. private _scene;
  110983. private _origin;
  110984. private _options;
  110985. private _physicsEngine;
  110986. private _originTop;
  110987. private _originDirection;
  110988. private _tickCallback;
  110989. private _cylinder;
  110990. private _cylinderPosition;
  110991. private _dataFetched;
  110992. /**
  110993. * Initializes the physics updraft event
  110994. * @param _scene BabylonJS scene
  110995. * @param _origin The origin position of the updraft
  110996. * @param _options The options for the updraft event
  110997. */
  110998. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  110999. /**
  111000. * Returns the data related to the updraft event (cylinder).
  111001. * @returns A physics updraft event
  111002. */
  111003. getData(): PhysicsUpdraftEventData;
  111004. /**
  111005. * Enables the updraft.
  111006. */
  111007. enable(): void;
  111008. /**
  111009. * Disables the updraft.
  111010. */
  111011. disable(): void;
  111012. /**
  111013. * Disposes the cylinder.
  111014. * @param force Specifies if the updraft should be disposed by force
  111015. */
  111016. dispose(force?: boolean): void;
  111017. private getImpostorHitData;
  111018. private _tick;
  111019. /*** Helpers ***/
  111020. private _prepareCylinder;
  111021. private _intersectsWithCylinder;
  111022. }
  111023. /**
  111024. * Represents a physics vortex event
  111025. */
  111026. class PhysicsVortexEvent {
  111027. private _scene;
  111028. private _origin;
  111029. private _options;
  111030. private _physicsEngine;
  111031. private _originTop;
  111032. private _tickCallback;
  111033. private _cylinder;
  111034. private _cylinderPosition;
  111035. private _dataFetched;
  111036. /**
  111037. * Initializes the physics vortex event
  111038. * @param _scene The BabylonJS scene
  111039. * @param _origin The origin position of the vortex
  111040. * @param _options The options for the vortex event
  111041. */
  111042. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  111043. /**
  111044. * Returns the data related to the vortex event (cylinder).
  111045. * @returns The physics vortex event data
  111046. */
  111047. getData(): PhysicsVortexEventData;
  111048. /**
  111049. * Enables the vortex.
  111050. */
  111051. enable(): void;
  111052. /**
  111053. * Disables the cortex.
  111054. */
  111055. disable(): void;
  111056. /**
  111057. * Disposes the sphere.
  111058. * @param force
  111059. */
  111060. dispose(force?: boolean): void;
  111061. private getImpostorHitData;
  111062. private _tick;
  111063. /*** Helpers ***/
  111064. private _prepareCylinder;
  111065. private _intersectsWithCylinder;
  111066. }
  111067. /**
  111068. * Options fot the radial explosion event
  111069. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111070. */
  111071. export class PhysicsRadialExplosionEventOptions {
  111072. /**
  111073. * The radius of the sphere for the radial explosion.
  111074. */
  111075. radius: number;
  111076. /**
  111077. * The strenth of the explosion.
  111078. */
  111079. strength: number;
  111080. /**
  111081. * The strenght of the force in correspondence to the distance of the affected object
  111082. */
  111083. falloff: PhysicsRadialImpulseFalloff;
  111084. /**
  111085. * Sphere options for the radial explosion.
  111086. */
  111087. sphere: {
  111088. segments: number;
  111089. diameter: number;
  111090. };
  111091. /**
  111092. * Sphere options for the radial explosion.
  111093. */
  111094. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  111095. }
  111096. /**
  111097. * Options fot the updraft event
  111098. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111099. */
  111100. export class PhysicsUpdraftEventOptions {
  111101. /**
  111102. * The radius of the cylinder for the vortex
  111103. */
  111104. radius: number;
  111105. /**
  111106. * The strenth of the updraft.
  111107. */
  111108. strength: number;
  111109. /**
  111110. * The height of the cylinder for the updraft.
  111111. */
  111112. height: number;
  111113. /**
  111114. * The mode for the the updraft.
  111115. */
  111116. updraftMode: PhysicsUpdraftMode;
  111117. }
  111118. /**
  111119. * Options fot the vortex event
  111120. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111121. */
  111122. export class PhysicsVortexEventOptions {
  111123. /**
  111124. * The radius of the cylinder for the vortex
  111125. */
  111126. radius: number;
  111127. /**
  111128. * The strenth of the vortex.
  111129. */
  111130. strength: number;
  111131. /**
  111132. * The height of the cylinder for the vortex.
  111133. */
  111134. height: number;
  111135. /**
  111136. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  111137. */
  111138. centripetalForceThreshold: number;
  111139. /**
  111140. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  111141. */
  111142. centripetalForceMultiplier: number;
  111143. /**
  111144. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  111145. */
  111146. centrifugalForceMultiplier: number;
  111147. /**
  111148. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  111149. */
  111150. updraftForceMultiplier: number;
  111151. }
  111152. /**
  111153. * The strenght of the force in correspondence to the distance of the affected object
  111154. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111155. */
  111156. export enum PhysicsRadialImpulseFalloff {
  111157. /** Defines that impulse is constant in strength across it's whole radius */
  111158. Constant = 0,
  111159. /** Defines that impulse gets weaker if it's further from the origin */
  111160. Linear = 1
  111161. }
  111162. /**
  111163. * The strength of the force in correspondence to the distance of the affected object
  111164. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111165. */
  111166. export enum PhysicsUpdraftMode {
  111167. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  111168. Center = 0,
  111169. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  111170. Perpendicular = 1
  111171. }
  111172. /**
  111173. * Interface for a physics hit data
  111174. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111175. */
  111176. export interface PhysicsHitData {
  111177. /**
  111178. * The force applied at the contact point
  111179. */
  111180. force: Vector3;
  111181. /**
  111182. * The contact point
  111183. */
  111184. contactPoint: Vector3;
  111185. /**
  111186. * The distance from the origin to the contact point
  111187. */
  111188. distanceFromOrigin: number;
  111189. }
  111190. /**
  111191. * Interface for radial explosion event data
  111192. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111193. */
  111194. export interface PhysicsRadialExplosionEventData {
  111195. /**
  111196. * A sphere used for the radial explosion event
  111197. */
  111198. sphere: Mesh;
  111199. }
  111200. /**
  111201. * Interface for gravitational field event data
  111202. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111203. */
  111204. export interface PhysicsGravitationalFieldEventData {
  111205. /**
  111206. * A sphere mesh used for the gravitational field event
  111207. */
  111208. sphere: Mesh;
  111209. }
  111210. /**
  111211. * Interface for updraft event data
  111212. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111213. */
  111214. export interface PhysicsUpdraftEventData {
  111215. /**
  111216. * A cylinder used for the updraft event
  111217. */
  111218. cylinder: Mesh;
  111219. }
  111220. /**
  111221. * Interface for vortex event data
  111222. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111223. */
  111224. export interface PhysicsVortexEventData {
  111225. /**
  111226. * A cylinder used for the vortex event
  111227. */
  111228. cylinder: Mesh;
  111229. }
  111230. /**
  111231. * Interface for an affected physics impostor
  111232. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111233. */
  111234. export interface PhysicsAffectedImpostorWithData {
  111235. /**
  111236. * The impostor affected by the effect
  111237. */
  111238. impostor: PhysicsImpostor;
  111239. /**
  111240. * The data about the hit/horce from the explosion
  111241. */
  111242. hitData: PhysicsHitData;
  111243. }
  111244. }
  111245. declare module BABYLON {
  111246. /** @hidden */
  111247. export var blackAndWhitePixelShader: {
  111248. name: string;
  111249. shader: string;
  111250. };
  111251. }
  111252. declare module BABYLON {
  111253. /**
  111254. * Post process used to render in black and white
  111255. */
  111256. export class BlackAndWhitePostProcess extends PostProcess {
  111257. /**
  111258. * Linear about to convert he result to black and white (default: 1)
  111259. */
  111260. degree: number;
  111261. /**
  111262. * Creates a black and white post process
  111263. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  111264. * @param name The name of the effect.
  111265. * @param options The required width/height ratio to downsize to before computing the render pass.
  111266. * @param camera The camera to apply the render pass to.
  111267. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111268. * @param engine The engine which the post process will be applied. (default: current engine)
  111269. * @param reusable If the post process can be reused on the same frame. (default: false)
  111270. */
  111271. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  111272. }
  111273. }
  111274. declare module BABYLON {
  111275. /**
  111276. * This represents a set of one or more post processes in Babylon.
  111277. * A post process can be used to apply a shader to a texture after it is rendered.
  111278. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  111279. */
  111280. export class PostProcessRenderEffect {
  111281. private _postProcesses;
  111282. private _getPostProcesses;
  111283. private _singleInstance;
  111284. private _cameras;
  111285. private _indicesForCamera;
  111286. /**
  111287. * Name of the effect
  111288. * @hidden
  111289. */
  111290. _name: string;
  111291. /**
  111292. * Instantiates a post process render effect.
  111293. * A post process can be used to apply a shader to a texture after it is rendered.
  111294. * @param engine The engine the effect is tied to
  111295. * @param name The name of the effect
  111296. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  111297. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  111298. */
  111299. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  111300. /**
  111301. * Checks if all the post processes in the effect are supported.
  111302. */
  111303. readonly isSupported: boolean;
  111304. /**
  111305. * Updates the current state of the effect
  111306. * @hidden
  111307. */
  111308. _update(): void;
  111309. /**
  111310. * Attaches the effect on cameras
  111311. * @param cameras The camera to attach to.
  111312. * @hidden
  111313. */
  111314. _attachCameras(cameras: Camera): void;
  111315. /**
  111316. * Attaches the effect on cameras
  111317. * @param cameras The camera to attach to.
  111318. * @hidden
  111319. */
  111320. _attachCameras(cameras: Camera[]): void;
  111321. /**
  111322. * Detatches the effect on cameras
  111323. * @param cameras The camera to detatch from.
  111324. * @hidden
  111325. */
  111326. _detachCameras(cameras: Camera): void;
  111327. /**
  111328. * Detatches the effect on cameras
  111329. * @param cameras The camera to detatch from.
  111330. * @hidden
  111331. */
  111332. _detachCameras(cameras: Camera[]): void;
  111333. /**
  111334. * Enables the effect on given cameras
  111335. * @param cameras The camera to enable.
  111336. * @hidden
  111337. */
  111338. _enable(cameras: Camera): void;
  111339. /**
  111340. * Enables the effect on given cameras
  111341. * @param cameras The camera to enable.
  111342. * @hidden
  111343. */
  111344. _enable(cameras: Nullable<Camera[]>): void;
  111345. /**
  111346. * Disables the effect on the given cameras
  111347. * @param cameras The camera to disable.
  111348. * @hidden
  111349. */
  111350. _disable(cameras: Camera): void;
  111351. /**
  111352. * Disables the effect on the given cameras
  111353. * @param cameras The camera to disable.
  111354. * @hidden
  111355. */
  111356. _disable(cameras: Nullable<Camera[]>): void;
  111357. /**
  111358. * Gets a list of the post processes contained in the effect.
  111359. * @param camera The camera to get the post processes on.
  111360. * @returns The list of the post processes in the effect.
  111361. */
  111362. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  111363. }
  111364. }
  111365. declare module BABYLON {
  111366. /** @hidden */
  111367. export var extractHighlightsPixelShader: {
  111368. name: string;
  111369. shader: string;
  111370. };
  111371. }
  111372. declare module BABYLON {
  111373. /**
  111374. * 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.
  111375. */
  111376. export class ExtractHighlightsPostProcess extends PostProcess {
  111377. /**
  111378. * The luminance threshold, pixels below this value will be set to black.
  111379. */
  111380. threshold: number;
  111381. /** @hidden */
  111382. _exposure: number;
  111383. /**
  111384. * Post process which has the input texture to be used when performing highlight extraction
  111385. * @hidden
  111386. */
  111387. _inputPostProcess: Nullable<PostProcess>;
  111388. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111389. }
  111390. }
  111391. declare module BABYLON {
  111392. /** @hidden */
  111393. export var bloomMergePixelShader: {
  111394. name: string;
  111395. shader: string;
  111396. };
  111397. }
  111398. declare module BABYLON {
  111399. /**
  111400. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  111401. */
  111402. export class BloomMergePostProcess extends PostProcess {
  111403. /** Weight of the bloom to be added to the original input. */
  111404. weight: number;
  111405. /**
  111406. * Creates a new instance of @see BloomMergePostProcess
  111407. * @param name The name of the effect.
  111408. * @param originalFromInput Post process which's input will be used for the merge.
  111409. * @param blurred Blurred highlights post process which's output will be used.
  111410. * @param weight Weight of the bloom to be added to the original input.
  111411. * @param options The required width/height ratio to downsize to before computing the render pass.
  111412. * @param camera The camera to apply the render pass to.
  111413. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111414. * @param engine The engine which the post process will be applied. (default: current engine)
  111415. * @param reusable If the post process can be reused on the same frame. (default: false)
  111416. * @param textureType Type of textures used when performing the post process. (default: 0)
  111417. * @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)
  111418. */
  111419. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  111420. /** Weight of the bloom to be added to the original input. */
  111421. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111422. }
  111423. }
  111424. declare module BABYLON {
  111425. /**
  111426. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  111427. */
  111428. export class BloomEffect extends PostProcessRenderEffect {
  111429. private bloomScale;
  111430. /**
  111431. * @hidden Internal
  111432. */
  111433. _effects: Array<PostProcess>;
  111434. /**
  111435. * @hidden Internal
  111436. */
  111437. _downscale: ExtractHighlightsPostProcess;
  111438. private _blurX;
  111439. private _blurY;
  111440. private _merge;
  111441. /**
  111442. * The luminance threshold to find bright areas of the image to bloom.
  111443. */
  111444. threshold: number;
  111445. /**
  111446. * The strength of the bloom.
  111447. */
  111448. weight: number;
  111449. /**
  111450. * Specifies the size of the bloom blur kernel, relative to the final output size
  111451. */
  111452. kernel: number;
  111453. /**
  111454. * Creates a new instance of @see BloomEffect
  111455. * @param scene The scene the effect belongs to.
  111456. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  111457. * @param bloomKernel The size of the kernel to be used when applying the blur.
  111458. * @param bloomWeight The the strength of bloom.
  111459. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  111460. * @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)
  111461. */
  111462. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  111463. /**
  111464. * Disposes each of the internal effects for a given camera.
  111465. * @param camera The camera to dispose the effect on.
  111466. */
  111467. disposeEffects(camera: Camera): void;
  111468. /**
  111469. * @hidden Internal
  111470. */
  111471. _updateEffects(): void;
  111472. /**
  111473. * Internal
  111474. * @returns if all the contained post processes are ready.
  111475. * @hidden
  111476. */
  111477. _isReady(): boolean;
  111478. }
  111479. }
  111480. declare module BABYLON {
  111481. /** @hidden */
  111482. export var chromaticAberrationPixelShader: {
  111483. name: string;
  111484. shader: string;
  111485. };
  111486. }
  111487. declare module BABYLON {
  111488. /**
  111489. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  111490. */
  111491. export class ChromaticAberrationPostProcess extends PostProcess {
  111492. /**
  111493. * The amount of seperation of rgb channels (default: 30)
  111494. */
  111495. aberrationAmount: number;
  111496. /**
  111497. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  111498. */
  111499. radialIntensity: number;
  111500. /**
  111501. * 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))
  111502. */
  111503. direction: Vector2;
  111504. /**
  111505. * 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))
  111506. */
  111507. centerPosition: Vector2;
  111508. /**
  111509. * Creates a new instance ChromaticAberrationPostProcess
  111510. * @param name The name of the effect.
  111511. * @param screenWidth The width of the screen to apply the effect on.
  111512. * @param screenHeight The height of the screen to apply the effect on.
  111513. * @param options The required width/height ratio to downsize to before computing the render pass.
  111514. * @param camera The camera to apply the render pass to.
  111515. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111516. * @param engine The engine which the post process will be applied. (default: current engine)
  111517. * @param reusable If the post process can be reused on the same frame. (default: false)
  111518. * @param textureType Type of textures used when performing the post process. (default: 0)
  111519. * @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)
  111520. */
  111521. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111522. }
  111523. }
  111524. declare module BABYLON {
  111525. /** @hidden */
  111526. export var circleOfConfusionPixelShader: {
  111527. name: string;
  111528. shader: string;
  111529. };
  111530. }
  111531. declare module BABYLON {
  111532. /**
  111533. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  111534. */
  111535. export class CircleOfConfusionPostProcess extends PostProcess {
  111536. /**
  111537. * 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.
  111538. */
  111539. lensSize: number;
  111540. /**
  111541. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  111542. */
  111543. fStop: number;
  111544. /**
  111545. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  111546. */
  111547. focusDistance: number;
  111548. /**
  111549. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  111550. */
  111551. focalLength: number;
  111552. private _depthTexture;
  111553. /**
  111554. * Creates a new instance CircleOfConfusionPostProcess
  111555. * @param name The name of the effect.
  111556. * @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.
  111557. * @param options The required width/height ratio to downsize to before computing the render pass.
  111558. * @param camera The camera to apply the render pass to.
  111559. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111560. * @param engine The engine which the post process will be applied. (default: current engine)
  111561. * @param reusable If the post process can be reused on the same frame. (default: false)
  111562. * @param textureType Type of textures used when performing the post process. (default: 0)
  111563. * @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)
  111564. */
  111565. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111566. /**
  111567. * 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.
  111568. */
  111569. depthTexture: RenderTargetTexture;
  111570. }
  111571. }
  111572. declare module BABYLON {
  111573. /** @hidden */
  111574. export var colorCorrectionPixelShader: {
  111575. name: string;
  111576. shader: string;
  111577. };
  111578. }
  111579. declare module BABYLON {
  111580. /**
  111581. *
  111582. * This post-process allows the modification of rendered colors by using
  111583. * a 'look-up table' (LUT). This effect is also called Color Grading.
  111584. *
  111585. * The object needs to be provided an url to a texture containing the color
  111586. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  111587. * Use an image editing software to tweak the LUT to match your needs.
  111588. *
  111589. * For an example of a color LUT, see here:
  111590. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  111591. * For explanations on color grading, see here:
  111592. * @see http://udn.epicgames.com/Three/ColorGrading.html
  111593. *
  111594. */
  111595. export class ColorCorrectionPostProcess extends PostProcess {
  111596. private _colorTableTexture;
  111597. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  111598. }
  111599. }
  111600. declare module BABYLON {
  111601. /** @hidden */
  111602. export var convolutionPixelShader: {
  111603. name: string;
  111604. shader: string;
  111605. };
  111606. }
  111607. declare module BABYLON {
  111608. /**
  111609. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  111610. * input texture to perform effects such as edge detection or sharpening
  111611. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  111612. */
  111613. export class ConvolutionPostProcess extends PostProcess {
  111614. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  111615. kernel: number[];
  111616. /**
  111617. * Creates a new instance ConvolutionPostProcess
  111618. * @param name The name of the effect.
  111619. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  111620. * @param options The required width/height ratio to downsize to before computing the render pass.
  111621. * @param camera The camera to apply the render pass to.
  111622. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111623. * @param engine The engine which the post process will be applied. (default: current engine)
  111624. * @param reusable If the post process can be reused on the same frame. (default: false)
  111625. * @param textureType Type of textures used when performing the post process. (default: 0)
  111626. */
  111627. constructor(name: string,
  111628. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  111629. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  111630. /**
  111631. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111632. */
  111633. static EdgeDetect0Kernel: number[];
  111634. /**
  111635. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111636. */
  111637. static EdgeDetect1Kernel: number[];
  111638. /**
  111639. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111640. */
  111641. static EdgeDetect2Kernel: number[];
  111642. /**
  111643. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111644. */
  111645. static SharpenKernel: number[];
  111646. /**
  111647. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111648. */
  111649. static EmbossKernel: number[];
  111650. /**
  111651. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111652. */
  111653. static GaussianKernel: number[];
  111654. }
  111655. }
  111656. declare module BABYLON {
  111657. /**
  111658. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  111659. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  111660. * based on samples that have a large difference in distance than the center pixel.
  111661. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  111662. */
  111663. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  111664. direction: Vector2;
  111665. /**
  111666. * Creates a new instance CircleOfConfusionPostProcess
  111667. * @param name The name of the effect.
  111668. * @param scene The scene the effect belongs to.
  111669. * @param direction The direction the blur should be applied.
  111670. * @param kernel The size of the kernel used to blur.
  111671. * @param options The required width/height ratio to downsize to before computing the render pass.
  111672. * @param camera The camera to apply the render pass to.
  111673. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  111674. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  111675. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111676. * @param engine The engine which the post process will be applied. (default: current engine)
  111677. * @param reusable If the post process can be reused on the same frame. (default: false)
  111678. * @param textureType Type of textures used when performing the post process. (default: 0)
  111679. * @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)
  111680. */
  111681. 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);
  111682. }
  111683. }
  111684. declare module BABYLON {
  111685. /** @hidden */
  111686. export var depthOfFieldMergePixelShader: {
  111687. name: string;
  111688. shader: string;
  111689. };
  111690. }
  111691. declare module BABYLON {
  111692. /**
  111693. * Options to be set when merging outputs from the default pipeline.
  111694. */
  111695. export class DepthOfFieldMergePostProcessOptions {
  111696. /**
  111697. * The original image to merge on top of
  111698. */
  111699. originalFromInput: PostProcess;
  111700. /**
  111701. * Parameters to perform the merge of the depth of field effect
  111702. */
  111703. depthOfField?: {
  111704. circleOfConfusion: PostProcess;
  111705. blurSteps: Array<PostProcess>;
  111706. };
  111707. /**
  111708. * Parameters to perform the merge of bloom effect
  111709. */
  111710. bloom?: {
  111711. blurred: PostProcess;
  111712. weight: number;
  111713. };
  111714. }
  111715. /**
  111716. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  111717. */
  111718. export class DepthOfFieldMergePostProcess extends PostProcess {
  111719. private blurSteps;
  111720. /**
  111721. * Creates a new instance of DepthOfFieldMergePostProcess
  111722. * @param name The name of the effect.
  111723. * @param originalFromInput Post process which's input will be used for the merge.
  111724. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  111725. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  111726. * @param options The required width/height ratio to downsize to before computing the render pass.
  111727. * @param camera The camera to apply the render pass to.
  111728. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111729. * @param engine The engine which the post process will be applied. (default: current engine)
  111730. * @param reusable If the post process can be reused on the same frame. (default: false)
  111731. * @param textureType Type of textures used when performing the post process. (default: 0)
  111732. * @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)
  111733. */
  111734. 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);
  111735. /**
  111736. * Updates the effect with the current post process compile time values and recompiles the shader.
  111737. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  111738. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  111739. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  111740. * @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
  111741. * @param onCompiled Called when the shader has been compiled.
  111742. * @param onError Called if there is an error when compiling a shader.
  111743. */
  111744. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  111745. }
  111746. }
  111747. declare module BABYLON {
  111748. /**
  111749. * Specifies the level of max blur that should be applied when using the depth of field effect
  111750. */
  111751. export enum DepthOfFieldEffectBlurLevel {
  111752. /**
  111753. * Subtle blur
  111754. */
  111755. Low = 0,
  111756. /**
  111757. * Medium blur
  111758. */
  111759. Medium = 1,
  111760. /**
  111761. * Large blur
  111762. */
  111763. High = 2
  111764. }
  111765. /**
  111766. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  111767. */
  111768. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  111769. private _circleOfConfusion;
  111770. /**
  111771. * @hidden Internal, blurs from high to low
  111772. */
  111773. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  111774. private _depthOfFieldBlurY;
  111775. private _dofMerge;
  111776. /**
  111777. * @hidden Internal post processes in depth of field effect
  111778. */
  111779. _effects: Array<PostProcess>;
  111780. /**
  111781. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  111782. */
  111783. focalLength: number;
  111784. /**
  111785. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  111786. */
  111787. fStop: number;
  111788. /**
  111789. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  111790. */
  111791. focusDistance: number;
  111792. /**
  111793. * 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.
  111794. */
  111795. lensSize: number;
  111796. /**
  111797. * Creates a new instance DepthOfFieldEffect
  111798. * @param scene The scene the effect belongs to.
  111799. * @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.
  111800. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  111801. * @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)
  111802. */
  111803. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  111804. /**
  111805. * 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.
  111806. */
  111807. depthTexture: RenderTargetTexture;
  111808. /**
  111809. * Disposes each of the internal effects for a given camera.
  111810. * @param camera The camera to dispose the effect on.
  111811. */
  111812. disposeEffects(camera: Camera): void;
  111813. /**
  111814. * @hidden Internal
  111815. */
  111816. _updateEffects(): void;
  111817. /**
  111818. * Internal
  111819. * @returns if all the contained post processes are ready.
  111820. * @hidden
  111821. */
  111822. _isReady(): boolean;
  111823. }
  111824. }
  111825. declare module BABYLON {
  111826. /** @hidden */
  111827. export var displayPassPixelShader: {
  111828. name: string;
  111829. shader: string;
  111830. };
  111831. }
  111832. declare module BABYLON {
  111833. /**
  111834. * DisplayPassPostProcess which produces an output the same as it's input
  111835. */
  111836. export class DisplayPassPostProcess extends PostProcess {
  111837. /**
  111838. * Creates the DisplayPassPostProcess
  111839. * @param name The name of the effect.
  111840. * @param options The required width/height ratio to downsize to before computing the render pass.
  111841. * @param camera The camera to apply the render pass to.
  111842. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111843. * @param engine The engine which the post process will be applied. (default: current engine)
  111844. * @param reusable If the post process can be reused on the same frame. (default: false)
  111845. */
  111846. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  111847. }
  111848. }
  111849. declare module BABYLON {
  111850. /** @hidden */
  111851. export var filterPixelShader: {
  111852. name: string;
  111853. shader: string;
  111854. };
  111855. }
  111856. declare module BABYLON {
  111857. /**
  111858. * Applies a kernel filter to the image
  111859. */
  111860. export class FilterPostProcess extends PostProcess {
  111861. /** The matrix to be applied to the image */
  111862. kernelMatrix: Matrix;
  111863. /**
  111864. *
  111865. * @param name The name of the effect.
  111866. * @param kernelMatrix The matrix to be applied to the image
  111867. * @param options The required width/height ratio to downsize to before computing the render pass.
  111868. * @param camera The camera to apply the render pass to.
  111869. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111870. * @param engine The engine which the post process will be applied. (default: current engine)
  111871. * @param reusable If the post process can be reused on the same frame. (default: false)
  111872. */
  111873. constructor(name: string,
  111874. /** The matrix to be applied to the image */
  111875. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  111876. }
  111877. }
  111878. declare module BABYLON {
  111879. /** @hidden */
  111880. export var fxaaPixelShader: {
  111881. name: string;
  111882. shader: string;
  111883. };
  111884. }
  111885. declare module BABYLON {
  111886. /** @hidden */
  111887. export var fxaaVertexShader: {
  111888. name: string;
  111889. shader: string;
  111890. };
  111891. }
  111892. declare module BABYLON {
  111893. /**
  111894. * Fxaa post process
  111895. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  111896. */
  111897. export class FxaaPostProcess extends PostProcess {
  111898. /** @hidden */
  111899. texelWidth: number;
  111900. /** @hidden */
  111901. texelHeight: number;
  111902. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  111903. private _getDefines;
  111904. }
  111905. }
  111906. declare module BABYLON {
  111907. /** @hidden */
  111908. export var grainPixelShader: {
  111909. name: string;
  111910. shader: string;
  111911. };
  111912. }
  111913. declare module BABYLON {
  111914. /**
  111915. * The GrainPostProcess adds noise to the image at mid luminance levels
  111916. */
  111917. export class GrainPostProcess extends PostProcess {
  111918. /**
  111919. * The intensity of the grain added (default: 30)
  111920. */
  111921. intensity: number;
  111922. /**
  111923. * If the grain should be randomized on every frame
  111924. */
  111925. animated: boolean;
  111926. /**
  111927. * Creates a new instance of @see GrainPostProcess
  111928. * @param name The name of the effect.
  111929. * @param options The required width/height ratio to downsize to before computing the render pass.
  111930. * @param camera The camera to apply the render pass to.
  111931. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111932. * @param engine The engine which the post process will be applied. (default: current engine)
  111933. * @param reusable If the post process can be reused on the same frame. (default: false)
  111934. * @param textureType Type of textures used when performing the post process. (default: 0)
  111935. * @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)
  111936. */
  111937. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111938. }
  111939. }
  111940. declare module BABYLON {
  111941. /** @hidden */
  111942. export var highlightsPixelShader: {
  111943. name: string;
  111944. shader: string;
  111945. };
  111946. }
  111947. declare module BABYLON {
  111948. /**
  111949. * Extracts highlights from the image
  111950. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  111951. */
  111952. export class HighlightsPostProcess extends PostProcess {
  111953. /**
  111954. * Extracts highlights from the image
  111955. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  111956. * @param name The name of the effect.
  111957. * @param options The required width/height ratio to downsize to before computing the render pass.
  111958. * @param camera The camera to apply the render pass to.
  111959. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111960. * @param engine The engine which the post process will be applied. (default: current engine)
  111961. * @param reusable If the post process can be reused on the same frame. (default: false)
  111962. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  111963. */
  111964. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  111965. }
  111966. }
  111967. declare module BABYLON {
  111968. /** @hidden */
  111969. export var mrtFragmentDeclaration: {
  111970. name: string;
  111971. shader: string;
  111972. };
  111973. }
  111974. declare module BABYLON {
  111975. /** @hidden */
  111976. export var geometryPixelShader: {
  111977. name: string;
  111978. shader: string;
  111979. };
  111980. }
  111981. declare module BABYLON {
  111982. /** @hidden */
  111983. export var geometryVertexShader: {
  111984. name: string;
  111985. shader: string;
  111986. };
  111987. }
  111988. declare module BABYLON {
  111989. /**
  111990. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  111991. */
  111992. export class GeometryBufferRenderer {
  111993. /**
  111994. * Constant used to retrieve the position texture index in the G-Buffer textures array
  111995. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  111996. */
  111997. static readonly POSITION_TEXTURE_TYPE: number;
  111998. /**
  111999. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  112000. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  112001. */
  112002. static readonly VELOCITY_TEXTURE_TYPE: number;
  112003. /**
  112004. * Dictionary used to store the previous transformation matrices of each rendered mesh
  112005. * in order to compute objects velocities when enableVelocity is set to "true"
  112006. * @hidden
  112007. */
  112008. _previousTransformationMatrices: {
  112009. [index: number]: Matrix;
  112010. };
  112011. private _scene;
  112012. private _multiRenderTarget;
  112013. private _ratio;
  112014. private _enablePosition;
  112015. private _enableVelocity;
  112016. private _positionIndex;
  112017. private _velocityIndex;
  112018. protected _effect: Effect;
  112019. protected _cachedDefines: string;
  112020. /**
  112021. * Set the render list (meshes to be rendered) used in the G buffer.
  112022. */
  112023. renderList: Mesh[];
  112024. /**
  112025. * Gets wether or not G buffer are supported by the running hardware.
  112026. * This requires draw buffer supports
  112027. */
  112028. readonly isSupported: boolean;
  112029. /**
  112030. * Returns the index of the given texture type in the G-Buffer textures array
  112031. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  112032. * @returns the index of the given texture type in the G-Buffer textures array
  112033. */
  112034. getTextureIndex(textureType: number): number;
  112035. /**
  112036. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  112037. */
  112038. /**
  112039. * Sets whether or not objects positions are enabled for the G buffer.
  112040. */
  112041. enablePosition: boolean;
  112042. /**
  112043. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  112044. */
  112045. /**
  112046. * Sets wether or not objects velocities are enabled for the G buffer.
  112047. */
  112048. enableVelocity: boolean;
  112049. /**
  112050. * Gets the scene associated with the buffer.
  112051. */
  112052. readonly scene: Scene;
  112053. /**
  112054. * Gets the ratio used by the buffer during its creation.
  112055. * How big is the buffer related to the main canvas.
  112056. */
  112057. readonly ratio: number;
  112058. /** @hidden */
  112059. static _SceneComponentInitialization: (scene: Scene) => void;
  112060. /**
  112061. * Creates a new G Buffer for the scene
  112062. * @param scene The scene the buffer belongs to
  112063. * @param ratio How big is the buffer related to the main canvas.
  112064. */
  112065. constructor(scene: Scene, ratio?: number);
  112066. /**
  112067. * Checks wether everything is ready to render a submesh to the G buffer.
  112068. * @param subMesh the submesh to check readiness for
  112069. * @param useInstances is the mesh drawn using instance or not
  112070. * @returns true if ready otherwise false
  112071. */
  112072. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  112073. /**
  112074. * Gets the current underlying G Buffer.
  112075. * @returns the buffer
  112076. */
  112077. getGBuffer(): MultiRenderTarget;
  112078. /**
  112079. * Gets the number of samples used to render the buffer (anti aliasing).
  112080. */
  112081. /**
  112082. * Sets the number of samples used to render the buffer (anti aliasing).
  112083. */
  112084. samples: number;
  112085. /**
  112086. * Disposes the renderer and frees up associated resources.
  112087. */
  112088. dispose(): void;
  112089. protected _createRenderTargets(): void;
  112090. }
  112091. }
  112092. declare module BABYLON {
  112093. interface Scene {
  112094. /** @hidden (Backing field) */
  112095. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  112096. /**
  112097. * Gets or Sets the current geometry buffer associated to the scene.
  112098. */
  112099. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  112100. /**
  112101. * Enables a GeometryBufferRender and associates it with the scene
  112102. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  112103. * @returns the GeometryBufferRenderer
  112104. */
  112105. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  112106. /**
  112107. * Disables the GeometryBufferRender associated with the scene
  112108. */
  112109. disableGeometryBufferRenderer(): void;
  112110. }
  112111. /**
  112112. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  112113. * in several rendering techniques.
  112114. */
  112115. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  112116. /**
  112117. * The component name helpful to identify the component in the list of scene components.
  112118. */
  112119. readonly name: string;
  112120. /**
  112121. * The scene the component belongs to.
  112122. */
  112123. scene: Scene;
  112124. /**
  112125. * Creates a new instance of the component for the given scene
  112126. * @param scene Defines the scene to register the component in
  112127. */
  112128. constructor(scene: Scene);
  112129. /**
  112130. * Registers the component in a given scene
  112131. */
  112132. register(): void;
  112133. /**
  112134. * Rebuilds the elements related to this component in case of
  112135. * context lost for instance.
  112136. */
  112137. rebuild(): void;
  112138. /**
  112139. * Disposes the component and the associated ressources
  112140. */
  112141. dispose(): void;
  112142. private _gatherRenderTargets;
  112143. }
  112144. }
  112145. declare module BABYLON {
  112146. /** @hidden */
  112147. export var motionBlurPixelShader: {
  112148. name: string;
  112149. shader: string;
  112150. };
  112151. }
  112152. declare module BABYLON {
  112153. /**
  112154. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  112155. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  112156. * As an example, all you have to do is to create the post-process:
  112157. * var mb = new BABYLON.MotionBlurPostProcess(
  112158. * 'mb', // The name of the effect.
  112159. * scene, // The scene containing the objects to blur according to their velocity.
  112160. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  112161. * camera // The camera to apply the render pass to.
  112162. * );
  112163. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  112164. */
  112165. export class MotionBlurPostProcess extends PostProcess {
  112166. /**
  112167. * Defines how much the image is blurred by the movement. Default value is equal to 1
  112168. */
  112169. motionStrength: number;
  112170. /**
  112171. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  112172. */
  112173. /**
  112174. * Sets the number of iterations to be used for motion blur quality
  112175. */
  112176. motionBlurSamples: number;
  112177. private _motionBlurSamples;
  112178. private _geometryBufferRenderer;
  112179. /**
  112180. * Creates a new instance MotionBlurPostProcess
  112181. * @param name The name of the effect.
  112182. * @param scene The scene containing the objects to blur according to their velocity.
  112183. * @param options The required width/height ratio to downsize to before computing the render pass.
  112184. * @param camera The camera to apply the render pass to.
  112185. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112186. * @param engine The engine which the post process will be applied. (default: current engine)
  112187. * @param reusable If the post process can be reused on the same frame. (default: false)
  112188. * @param textureType Type of textures used when performing the post process. (default: 0)
  112189. * @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)
  112190. */
  112191. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112192. /**
  112193. * Disposes the post process.
  112194. * @param camera The camera to dispose the post process on.
  112195. */
  112196. dispose(camera?: Camera): void;
  112197. }
  112198. }
  112199. declare module BABYLON {
  112200. /** @hidden */
  112201. export var refractionPixelShader: {
  112202. name: string;
  112203. shader: string;
  112204. };
  112205. }
  112206. declare module BABYLON {
  112207. /**
  112208. * Post process which applies a refractin texture
  112209. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  112210. */
  112211. export class RefractionPostProcess extends PostProcess {
  112212. /** the base color of the refraction (used to taint the rendering) */
  112213. color: Color3;
  112214. /** simulated refraction depth */
  112215. depth: number;
  112216. /** the coefficient of the base color (0 to remove base color tainting) */
  112217. colorLevel: number;
  112218. private _refTexture;
  112219. private _ownRefractionTexture;
  112220. /**
  112221. * Gets or sets the refraction texture
  112222. * Please note that you are responsible for disposing the texture if you set it manually
  112223. */
  112224. refractionTexture: Texture;
  112225. /**
  112226. * Initializes the RefractionPostProcess
  112227. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  112228. * @param name The name of the effect.
  112229. * @param refractionTextureUrl Url of the refraction texture to use
  112230. * @param color the base color of the refraction (used to taint the rendering)
  112231. * @param depth simulated refraction depth
  112232. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  112233. * @param camera The camera to apply the render pass to.
  112234. * @param options The required width/height ratio to downsize to before computing the render pass.
  112235. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112236. * @param engine The engine which the post process will be applied. (default: current engine)
  112237. * @param reusable If the post process can be reused on the same frame. (default: false)
  112238. */
  112239. constructor(name: string, refractionTextureUrl: string,
  112240. /** the base color of the refraction (used to taint the rendering) */
  112241. color: Color3,
  112242. /** simulated refraction depth */
  112243. depth: number,
  112244. /** the coefficient of the base color (0 to remove base color tainting) */
  112245. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112246. /**
  112247. * Disposes of the post process
  112248. * @param camera Camera to dispose post process on
  112249. */
  112250. dispose(camera: Camera): void;
  112251. }
  112252. }
  112253. declare module BABYLON {
  112254. /** @hidden */
  112255. export var sharpenPixelShader: {
  112256. name: string;
  112257. shader: string;
  112258. };
  112259. }
  112260. declare module BABYLON {
  112261. /**
  112262. * The SharpenPostProcess applies a sharpen kernel to every pixel
  112263. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  112264. */
  112265. export class SharpenPostProcess extends PostProcess {
  112266. /**
  112267. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  112268. */
  112269. colorAmount: number;
  112270. /**
  112271. * How much sharpness should be applied (default: 0.3)
  112272. */
  112273. edgeAmount: number;
  112274. /**
  112275. * Creates a new instance ConvolutionPostProcess
  112276. * @param name The name of the effect.
  112277. * @param options The required width/height ratio to downsize to before computing the render pass.
  112278. * @param camera The camera to apply the render pass to.
  112279. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112280. * @param engine The engine which the post process will be applied. (default: current engine)
  112281. * @param reusable If the post process can be reused on the same frame. (default: false)
  112282. * @param textureType Type of textures used when performing the post process. (default: 0)
  112283. * @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)
  112284. */
  112285. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112286. }
  112287. }
  112288. declare module BABYLON {
  112289. /**
  112290. * PostProcessRenderPipeline
  112291. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  112292. */
  112293. export class PostProcessRenderPipeline {
  112294. private engine;
  112295. private _renderEffects;
  112296. private _renderEffectsForIsolatedPass;
  112297. /**
  112298. * List of inspectable custom properties (used by the Inspector)
  112299. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  112300. */
  112301. inspectableCustomProperties: IInspectable[];
  112302. /**
  112303. * @hidden
  112304. */
  112305. protected _cameras: Camera[];
  112306. /** @hidden */
  112307. _name: string;
  112308. /**
  112309. * Gets pipeline name
  112310. */
  112311. readonly name: string;
  112312. /**
  112313. * Initializes a PostProcessRenderPipeline
  112314. * @param engine engine to add the pipeline to
  112315. * @param name name of the pipeline
  112316. */
  112317. constructor(engine: Engine, name: string);
  112318. /**
  112319. * Gets the class name
  112320. * @returns "PostProcessRenderPipeline"
  112321. */
  112322. getClassName(): string;
  112323. /**
  112324. * If all the render effects in the pipeline are supported
  112325. */
  112326. readonly isSupported: boolean;
  112327. /**
  112328. * Adds an effect to the pipeline
  112329. * @param renderEffect the effect to add
  112330. */
  112331. addEffect(renderEffect: PostProcessRenderEffect): void;
  112332. /** @hidden */
  112333. _rebuild(): void;
  112334. /** @hidden */
  112335. _enableEffect(renderEffectName: string, cameras: Camera): void;
  112336. /** @hidden */
  112337. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  112338. /** @hidden */
  112339. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  112340. /** @hidden */
  112341. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  112342. /** @hidden */
  112343. _attachCameras(cameras: Camera, unique: boolean): void;
  112344. /** @hidden */
  112345. _attachCameras(cameras: Camera[], unique: boolean): void;
  112346. /** @hidden */
  112347. _detachCameras(cameras: Camera): void;
  112348. /** @hidden */
  112349. _detachCameras(cameras: Nullable<Camera[]>): void;
  112350. /** @hidden */
  112351. _update(): void;
  112352. /** @hidden */
  112353. _reset(): void;
  112354. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  112355. /**
  112356. * Disposes of the pipeline
  112357. */
  112358. dispose(): void;
  112359. }
  112360. }
  112361. declare module BABYLON {
  112362. /**
  112363. * PostProcessRenderPipelineManager class
  112364. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  112365. */
  112366. export class PostProcessRenderPipelineManager {
  112367. private _renderPipelines;
  112368. /**
  112369. * Initializes a PostProcessRenderPipelineManager
  112370. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  112371. */
  112372. constructor();
  112373. /**
  112374. * Gets the list of supported render pipelines
  112375. */
  112376. readonly supportedPipelines: PostProcessRenderPipeline[];
  112377. /**
  112378. * Adds a pipeline to the manager
  112379. * @param renderPipeline The pipeline to add
  112380. */
  112381. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  112382. /**
  112383. * Attaches a camera to the pipeline
  112384. * @param renderPipelineName The name of the pipeline to attach to
  112385. * @param cameras the camera to attach
  112386. * @param unique if the camera can be attached multiple times to the pipeline
  112387. */
  112388. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  112389. /**
  112390. * Detaches a camera from the pipeline
  112391. * @param renderPipelineName The name of the pipeline to detach from
  112392. * @param cameras the camera to detach
  112393. */
  112394. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  112395. /**
  112396. * Enables an effect by name on a pipeline
  112397. * @param renderPipelineName the name of the pipeline to enable the effect in
  112398. * @param renderEffectName the name of the effect to enable
  112399. * @param cameras the cameras that the effect should be enabled on
  112400. */
  112401. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  112402. /**
  112403. * Disables an effect by name on a pipeline
  112404. * @param renderPipelineName the name of the pipeline to disable the effect in
  112405. * @param renderEffectName the name of the effect to disable
  112406. * @param cameras the cameras that the effect should be disabled on
  112407. */
  112408. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  112409. /**
  112410. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  112411. */
  112412. update(): void;
  112413. /** @hidden */
  112414. _rebuild(): void;
  112415. /**
  112416. * Disposes of the manager and pipelines
  112417. */
  112418. dispose(): void;
  112419. }
  112420. }
  112421. declare module BABYLON {
  112422. interface Scene {
  112423. /** @hidden (Backing field) */
  112424. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  112425. /**
  112426. * Gets the postprocess render pipeline manager
  112427. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  112428. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  112429. */
  112430. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  112431. }
  112432. /**
  112433. * Defines the Render Pipeline scene component responsible to rendering pipelines
  112434. */
  112435. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  112436. /**
  112437. * The component name helpfull to identify the component in the list of scene components.
  112438. */
  112439. readonly name: string;
  112440. /**
  112441. * The scene the component belongs to.
  112442. */
  112443. scene: Scene;
  112444. /**
  112445. * Creates a new instance of the component for the given scene
  112446. * @param scene Defines the scene to register the component in
  112447. */
  112448. constructor(scene: Scene);
  112449. /**
  112450. * Registers the component in a given scene
  112451. */
  112452. register(): void;
  112453. /**
  112454. * Rebuilds the elements related to this component in case of
  112455. * context lost for instance.
  112456. */
  112457. rebuild(): void;
  112458. /**
  112459. * Disposes the component and the associated ressources
  112460. */
  112461. dispose(): void;
  112462. private _gatherRenderTargets;
  112463. }
  112464. }
  112465. declare module BABYLON {
  112466. /**
  112467. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  112468. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  112469. */
  112470. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  112471. private _scene;
  112472. private _camerasToBeAttached;
  112473. /**
  112474. * ID of the sharpen post process,
  112475. */
  112476. private readonly SharpenPostProcessId;
  112477. /**
  112478. * @ignore
  112479. * ID of the image processing post process;
  112480. */
  112481. readonly ImageProcessingPostProcessId: string;
  112482. /**
  112483. * @ignore
  112484. * ID of the Fast Approximate Anti-Aliasing post process;
  112485. */
  112486. readonly FxaaPostProcessId: string;
  112487. /**
  112488. * ID of the chromatic aberration post process,
  112489. */
  112490. private readonly ChromaticAberrationPostProcessId;
  112491. /**
  112492. * ID of the grain post process
  112493. */
  112494. private readonly GrainPostProcessId;
  112495. /**
  112496. * Sharpen post process which will apply a sharpen convolution to enhance edges
  112497. */
  112498. sharpen: SharpenPostProcess;
  112499. private _sharpenEffect;
  112500. private bloom;
  112501. /**
  112502. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  112503. */
  112504. depthOfField: DepthOfFieldEffect;
  112505. /**
  112506. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  112507. */
  112508. fxaa: FxaaPostProcess;
  112509. /**
  112510. * Image post processing pass used to perform operations such as tone mapping or color grading.
  112511. */
  112512. imageProcessing: ImageProcessingPostProcess;
  112513. /**
  112514. * Chromatic aberration post process which will shift rgb colors in the image
  112515. */
  112516. chromaticAberration: ChromaticAberrationPostProcess;
  112517. private _chromaticAberrationEffect;
  112518. /**
  112519. * Grain post process which add noise to the image
  112520. */
  112521. grain: GrainPostProcess;
  112522. private _grainEffect;
  112523. /**
  112524. * Glow post process which adds a glow to emissive areas of the image
  112525. */
  112526. private _glowLayer;
  112527. /**
  112528. * Animations which can be used to tweak settings over a period of time
  112529. */
  112530. animations: Animation[];
  112531. private _imageProcessingConfigurationObserver;
  112532. private _sharpenEnabled;
  112533. private _bloomEnabled;
  112534. private _depthOfFieldEnabled;
  112535. private _depthOfFieldBlurLevel;
  112536. private _fxaaEnabled;
  112537. private _imageProcessingEnabled;
  112538. private _defaultPipelineTextureType;
  112539. private _bloomScale;
  112540. private _chromaticAberrationEnabled;
  112541. private _grainEnabled;
  112542. private _buildAllowed;
  112543. /**
  112544. * Gets active scene
  112545. */
  112546. readonly scene: Scene;
  112547. /**
  112548. * Enable or disable the sharpen process from the pipeline
  112549. */
  112550. sharpenEnabled: boolean;
  112551. private _resizeObserver;
  112552. private _hardwareScaleLevel;
  112553. private _bloomKernel;
  112554. /**
  112555. * Specifies the size of the bloom blur kernel, relative to the final output size
  112556. */
  112557. bloomKernel: number;
  112558. /**
  112559. * Specifies the weight of the bloom in the final rendering
  112560. */
  112561. private _bloomWeight;
  112562. /**
  112563. * Specifies the luma threshold for the area that will be blurred by the bloom
  112564. */
  112565. private _bloomThreshold;
  112566. private _hdr;
  112567. /**
  112568. * The strength of the bloom.
  112569. */
  112570. bloomWeight: number;
  112571. /**
  112572. * The strength of the bloom.
  112573. */
  112574. bloomThreshold: number;
  112575. /**
  112576. * The scale of the bloom, lower value will provide better performance.
  112577. */
  112578. bloomScale: number;
  112579. /**
  112580. * Enable or disable the bloom from the pipeline
  112581. */
  112582. bloomEnabled: boolean;
  112583. private _rebuildBloom;
  112584. /**
  112585. * If the depth of field is enabled.
  112586. */
  112587. depthOfFieldEnabled: boolean;
  112588. /**
  112589. * Blur level of the depth of field effect. (Higher blur will effect performance)
  112590. */
  112591. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  112592. /**
  112593. * If the anti aliasing is enabled.
  112594. */
  112595. fxaaEnabled: boolean;
  112596. private _samples;
  112597. /**
  112598. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  112599. */
  112600. samples: number;
  112601. /**
  112602. * If image processing is enabled.
  112603. */
  112604. imageProcessingEnabled: boolean;
  112605. /**
  112606. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  112607. */
  112608. glowLayerEnabled: boolean;
  112609. /**
  112610. * Enable or disable the chromaticAberration process from the pipeline
  112611. */
  112612. chromaticAberrationEnabled: boolean;
  112613. /**
  112614. * Enable or disable the grain process from the pipeline
  112615. */
  112616. grainEnabled: boolean;
  112617. /**
  112618. * @constructor
  112619. * @param name - The rendering pipeline name (default: "")
  112620. * @param hdr - If high dynamic range textures should be used (default: true)
  112621. * @param scene - The scene linked to this pipeline (default: the last created scene)
  112622. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  112623. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  112624. */
  112625. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  112626. /**
  112627. * Get the class name
  112628. * @returns "DefaultRenderingPipeline"
  112629. */
  112630. getClassName(): string;
  112631. /**
  112632. * Force the compilation of the entire pipeline.
  112633. */
  112634. prepare(): void;
  112635. private _hasCleared;
  112636. private _prevPostProcess;
  112637. private _prevPrevPostProcess;
  112638. private _setAutoClearAndTextureSharing;
  112639. private _depthOfFieldSceneObserver;
  112640. private _buildPipeline;
  112641. private _disposePostProcesses;
  112642. /**
  112643. * Adds a camera to the pipeline
  112644. * @param camera the camera to be added
  112645. */
  112646. addCamera(camera: Camera): void;
  112647. /**
  112648. * Removes a camera from the pipeline
  112649. * @param camera the camera to remove
  112650. */
  112651. removeCamera(camera: Camera): void;
  112652. /**
  112653. * Dispose of the pipeline and stop all post processes
  112654. */
  112655. dispose(): void;
  112656. /**
  112657. * Serialize the rendering pipeline (Used when exporting)
  112658. * @returns the serialized object
  112659. */
  112660. serialize(): any;
  112661. /**
  112662. * Parse the serialized pipeline
  112663. * @param source Source pipeline.
  112664. * @param scene The scene to load the pipeline to.
  112665. * @param rootUrl The URL of the serialized pipeline.
  112666. * @returns An instantiated pipeline from the serialized object.
  112667. */
  112668. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  112669. }
  112670. }
  112671. declare module BABYLON {
  112672. /** @hidden */
  112673. export var lensHighlightsPixelShader: {
  112674. name: string;
  112675. shader: string;
  112676. };
  112677. }
  112678. declare module BABYLON {
  112679. /** @hidden */
  112680. export var depthOfFieldPixelShader: {
  112681. name: string;
  112682. shader: string;
  112683. };
  112684. }
  112685. declare module BABYLON {
  112686. /**
  112687. * BABYLON.JS Chromatic Aberration GLSL Shader
  112688. * Author: Olivier Guyot
  112689. * Separates very slightly R, G and B colors on the edges of the screen
  112690. * Inspired by Francois Tarlier & Martins Upitis
  112691. */
  112692. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  112693. /**
  112694. * @ignore
  112695. * The chromatic aberration PostProcess id in the pipeline
  112696. */
  112697. LensChromaticAberrationEffect: string;
  112698. /**
  112699. * @ignore
  112700. * The highlights enhancing PostProcess id in the pipeline
  112701. */
  112702. HighlightsEnhancingEffect: string;
  112703. /**
  112704. * @ignore
  112705. * The depth-of-field PostProcess id in the pipeline
  112706. */
  112707. LensDepthOfFieldEffect: string;
  112708. private _scene;
  112709. private _depthTexture;
  112710. private _grainTexture;
  112711. private _chromaticAberrationPostProcess;
  112712. private _highlightsPostProcess;
  112713. private _depthOfFieldPostProcess;
  112714. private _edgeBlur;
  112715. private _grainAmount;
  112716. private _chromaticAberration;
  112717. private _distortion;
  112718. private _highlightsGain;
  112719. private _highlightsThreshold;
  112720. private _dofDistance;
  112721. private _dofAperture;
  112722. private _dofDarken;
  112723. private _dofPentagon;
  112724. private _blurNoise;
  112725. /**
  112726. * @constructor
  112727. *
  112728. * Effect parameters are as follow:
  112729. * {
  112730. * chromatic_aberration: number; // from 0 to x (1 for realism)
  112731. * edge_blur: number; // from 0 to x (1 for realism)
  112732. * distortion: number; // from 0 to x (1 for realism)
  112733. * grain_amount: number; // from 0 to 1
  112734. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  112735. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  112736. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  112737. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  112738. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  112739. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  112740. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  112741. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  112742. * }
  112743. * Note: if an effect parameter is unset, effect is disabled
  112744. *
  112745. * @param name The rendering pipeline name
  112746. * @param parameters - An object containing all parameters (see above)
  112747. * @param scene The scene linked to this pipeline
  112748. * @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)
  112749. * @param cameras The array of cameras that the rendering pipeline will be attached to
  112750. */
  112751. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  112752. /**
  112753. * Get the class name
  112754. * @returns "LensRenderingPipeline"
  112755. */
  112756. getClassName(): string;
  112757. /**
  112758. * Gets associated scene
  112759. */
  112760. readonly scene: Scene;
  112761. /**
  112762. * Gets or sets the edge blur
  112763. */
  112764. edgeBlur: number;
  112765. /**
  112766. * Gets or sets the grain amount
  112767. */
  112768. grainAmount: number;
  112769. /**
  112770. * Gets or sets the chromatic aberration amount
  112771. */
  112772. chromaticAberration: number;
  112773. /**
  112774. * Gets or sets the depth of field aperture
  112775. */
  112776. dofAperture: number;
  112777. /**
  112778. * Gets or sets the edge distortion
  112779. */
  112780. edgeDistortion: number;
  112781. /**
  112782. * Gets or sets the depth of field distortion
  112783. */
  112784. dofDistortion: number;
  112785. /**
  112786. * Gets or sets the darken out of focus amount
  112787. */
  112788. darkenOutOfFocus: number;
  112789. /**
  112790. * Gets or sets a boolean indicating if blur noise is enabled
  112791. */
  112792. blurNoise: boolean;
  112793. /**
  112794. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  112795. */
  112796. pentagonBokeh: boolean;
  112797. /**
  112798. * Gets or sets the highlight grain amount
  112799. */
  112800. highlightsGain: number;
  112801. /**
  112802. * Gets or sets the highlight threshold
  112803. */
  112804. highlightsThreshold: number;
  112805. /**
  112806. * Sets the amount of blur at the edges
  112807. * @param amount blur amount
  112808. */
  112809. setEdgeBlur(amount: number): void;
  112810. /**
  112811. * Sets edge blur to 0
  112812. */
  112813. disableEdgeBlur(): void;
  112814. /**
  112815. * Sets the amout of grain
  112816. * @param amount Amount of grain
  112817. */
  112818. setGrainAmount(amount: number): void;
  112819. /**
  112820. * Set grain amount to 0
  112821. */
  112822. disableGrain(): void;
  112823. /**
  112824. * Sets the chromatic aberration amount
  112825. * @param amount amount of chromatic aberration
  112826. */
  112827. setChromaticAberration(amount: number): void;
  112828. /**
  112829. * Sets chromatic aberration amount to 0
  112830. */
  112831. disableChromaticAberration(): void;
  112832. /**
  112833. * Sets the EdgeDistortion amount
  112834. * @param amount amount of EdgeDistortion
  112835. */
  112836. setEdgeDistortion(amount: number): void;
  112837. /**
  112838. * Sets edge distortion to 0
  112839. */
  112840. disableEdgeDistortion(): void;
  112841. /**
  112842. * Sets the FocusDistance amount
  112843. * @param amount amount of FocusDistance
  112844. */
  112845. setFocusDistance(amount: number): void;
  112846. /**
  112847. * Disables depth of field
  112848. */
  112849. disableDepthOfField(): void;
  112850. /**
  112851. * Sets the Aperture amount
  112852. * @param amount amount of Aperture
  112853. */
  112854. setAperture(amount: number): void;
  112855. /**
  112856. * Sets the DarkenOutOfFocus amount
  112857. * @param amount amount of DarkenOutOfFocus
  112858. */
  112859. setDarkenOutOfFocus(amount: number): void;
  112860. private _pentagonBokehIsEnabled;
  112861. /**
  112862. * Creates a pentagon bokeh effect
  112863. */
  112864. enablePentagonBokeh(): void;
  112865. /**
  112866. * Disables the pentagon bokeh effect
  112867. */
  112868. disablePentagonBokeh(): void;
  112869. /**
  112870. * Enables noise blur
  112871. */
  112872. enableNoiseBlur(): void;
  112873. /**
  112874. * Disables noise blur
  112875. */
  112876. disableNoiseBlur(): void;
  112877. /**
  112878. * Sets the HighlightsGain amount
  112879. * @param amount amount of HighlightsGain
  112880. */
  112881. setHighlightsGain(amount: number): void;
  112882. /**
  112883. * Sets the HighlightsThreshold amount
  112884. * @param amount amount of HighlightsThreshold
  112885. */
  112886. setHighlightsThreshold(amount: number): void;
  112887. /**
  112888. * Disables highlights
  112889. */
  112890. disableHighlights(): void;
  112891. /**
  112892. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  112893. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  112894. */
  112895. dispose(disableDepthRender?: boolean): void;
  112896. private _createChromaticAberrationPostProcess;
  112897. private _createHighlightsPostProcess;
  112898. private _createDepthOfFieldPostProcess;
  112899. private _createGrainTexture;
  112900. }
  112901. }
  112902. declare module BABYLON {
  112903. /** @hidden */
  112904. export var ssao2PixelShader: {
  112905. name: string;
  112906. shader: string;
  112907. };
  112908. }
  112909. declare module BABYLON {
  112910. /** @hidden */
  112911. export var ssaoCombinePixelShader: {
  112912. name: string;
  112913. shader: string;
  112914. };
  112915. }
  112916. declare module BABYLON {
  112917. /**
  112918. * Render pipeline to produce ssao effect
  112919. */
  112920. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  112921. /**
  112922. * @ignore
  112923. * The PassPostProcess id in the pipeline that contains the original scene color
  112924. */
  112925. SSAOOriginalSceneColorEffect: string;
  112926. /**
  112927. * @ignore
  112928. * The SSAO PostProcess id in the pipeline
  112929. */
  112930. SSAORenderEffect: string;
  112931. /**
  112932. * @ignore
  112933. * The horizontal blur PostProcess id in the pipeline
  112934. */
  112935. SSAOBlurHRenderEffect: string;
  112936. /**
  112937. * @ignore
  112938. * The vertical blur PostProcess id in the pipeline
  112939. */
  112940. SSAOBlurVRenderEffect: string;
  112941. /**
  112942. * @ignore
  112943. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  112944. */
  112945. SSAOCombineRenderEffect: string;
  112946. /**
  112947. * The output strength of the SSAO post-process. Default value is 1.0.
  112948. */
  112949. totalStrength: number;
  112950. /**
  112951. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  112952. */
  112953. maxZ: number;
  112954. /**
  112955. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  112956. */
  112957. minZAspect: number;
  112958. private _samples;
  112959. /**
  112960. * Number of samples used for the SSAO calculations. Default value is 8
  112961. */
  112962. samples: number;
  112963. private _textureSamples;
  112964. /**
  112965. * Number of samples to use for antialiasing
  112966. */
  112967. textureSamples: number;
  112968. /**
  112969. * Ratio object used for SSAO ratio and blur ratio
  112970. */
  112971. private _ratio;
  112972. /**
  112973. * Dynamically generated sphere sampler.
  112974. */
  112975. private _sampleSphere;
  112976. /**
  112977. * Blur filter offsets
  112978. */
  112979. private _samplerOffsets;
  112980. private _expensiveBlur;
  112981. /**
  112982. * If bilateral blur should be used
  112983. */
  112984. expensiveBlur: boolean;
  112985. /**
  112986. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  112987. */
  112988. radius: number;
  112989. /**
  112990. * The base color of the SSAO post-process
  112991. * The final result is "base + ssao" between [0, 1]
  112992. */
  112993. base: number;
  112994. /**
  112995. * Support test.
  112996. */
  112997. static readonly IsSupported: boolean;
  112998. private _scene;
  112999. private _depthTexture;
  113000. private _normalTexture;
  113001. private _randomTexture;
  113002. private _originalColorPostProcess;
  113003. private _ssaoPostProcess;
  113004. private _blurHPostProcess;
  113005. private _blurVPostProcess;
  113006. private _ssaoCombinePostProcess;
  113007. private _firstUpdate;
  113008. /**
  113009. * Gets active scene
  113010. */
  113011. readonly scene: Scene;
  113012. /**
  113013. * @constructor
  113014. * @param name The rendering pipeline name
  113015. * @param scene The scene linked to this pipeline
  113016. * @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 }
  113017. * @param cameras The array of cameras that the rendering pipeline will be attached to
  113018. */
  113019. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  113020. /**
  113021. * Get the class name
  113022. * @returns "SSAO2RenderingPipeline"
  113023. */
  113024. getClassName(): string;
  113025. /**
  113026. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  113027. */
  113028. dispose(disableGeometryBufferRenderer?: boolean): void;
  113029. private _createBlurPostProcess;
  113030. /** @hidden */
  113031. _rebuild(): void;
  113032. private _bits;
  113033. private _radicalInverse_VdC;
  113034. private _hammersley;
  113035. private _hemisphereSample_uniform;
  113036. private _generateHemisphere;
  113037. private _createSSAOPostProcess;
  113038. private _createSSAOCombinePostProcess;
  113039. private _createRandomTexture;
  113040. /**
  113041. * Serialize the rendering pipeline (Used when exporting)
  113042. * @returns the serialized object
  113043. */
  113044. serialize(): any;
  113045. /**
  113046. * Parse the serialized pipeline
  113047. * @param source Source pipeline.
  113048. * @param scene The scene to load the pipeline to.
  113049. * @param rootUrl The URL of the serialized pipeline.
  113050. * @returns An instantiated pipeline from the serialized object.
  113051. */
  113052. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  113053. }
  113054. }
  113055. declare module BABYLON {
  113056. /** @hidden */
  113057. export var ssaoPixelShader: {
  113058. name: string;
  113059. shader: string;
  113060. };
  113061. }
  113062. declare module BABYLON {
  113063. /**
  113064. * Render pipeline to produce ssao effect
  113065. */
  113066. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  113067. /**
  113068. * @ignore
  113069. * The PassPostProcess id in the pipeline that contains the original scene color
  113070. */
  113071. SSAOOriginalSceneColorEffect: string;
  113072. /**
  113073. * @ignore
  113074. * The SSAO PostProcess id in the pipeline
  113075. */
  113076. SSAORenderEffect: string;
  113077. /**
  113078. * @ignore
  113079. * The horizontal blur PostProcess id in the pipeline
  113080. */
  113081. SSAOBlurHRenderEffect: string;
  113082. /**
  113083. * @ignore
  113084. * The vertical blur PostProcess id in the pipeline
  113085. */
  113086. SSAOBlurVRenderEffect: string;
  113087. /**
  113088. * @ignore
  113089. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  113090. */
  113091. SSAOCombineRenderEffect: string;
  113092. /**
  113093. * The output strength of the SSAO post-process. Default value is 1.0.
  113094. */
  113095. totalStrength: number;
  113096. /**
  113097. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  113098. */
  113099. radius: number;
  113100. /**
  113101. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  113102. * Must not be equal to fallOff and superior to fallOff.
  113103. * Default value is 0.0075
  113104. */
  113105. area: number;
  113106. /**
  113107. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  113108. * Must not be equal to area and inferior to area.
  113109. * Default value is 0.000001
  113110. */
  113111. fallOff: number;
  113112. /**
  113113. * The base color of the SSAO post-process
  113114. * The final result is "base + ssao" between [0, 1]
  113115. */
  113116. base: number;
  113117. private _scene;
  113118. private _depthTexture;
  113119. private _randomTexture;
  113120. private _originalColorPostProcess;
  113121. private _ssaoPostProcess;
  113122. private _blurHPostProcess;
  113123. private _blurVPostProcess;
  113124. private _ssaoCombinePostProcess;
  113125. private _firstUpdate;
  113126. /**
  113127. * Gets active scene
  113128. */
  113129. readonly scene: Scene;
  113130. /**
  113131. * @constructor
  113132. * @param name - The rendering pipeline name
  113133. * @param scene - The scene linked to this pipeline
  113134. * @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 }
  113135. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  113136. */
  113137. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  113138. /**
  113139. * Get the class name
  113140. * @returns "SSAORenderingPipeline"
  113141. */
  113142. getClassName(): string;
  113143. /**
  113144. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  113145. */
  113146. dispose(disableDepthRender?: boolean): void;
  113147. private _createBlurPostProcess;
  113148. /** @hidden */
  113149. _rebuild(): void;
  113150. private _createSSAOPostProcess;
  113151. private _createSSAOCombinePostProcess;
  113152. private _createRandomTexture;
  113153. }
  113154. }
  113155. declare module BABYLON {
  113156. /** @hidden */
  113157. export var standardPixelShader: {
  113158. name: string;
  113159. shader: string;
  113160. };
  113161. }
  113162. declare module BABYLON {
  113163. /**
  113164. * Standard rendering pipeline
  113165. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  113166. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  113167. */
  113168. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  113169. /**
  113170. * Public members
  113171. */
  113172. /**
  113173. * Post-process which contains the original scene color before the pipeline applies all the effects
  113174. */
  113175. originalPostProcess: Nullable<PostProcess>;
  113176. /**
  113177. * Post-process used to down scale an image x4
  113178. */
  113179. downSampleX4PostProcess: Nullable<PostProcess>;
  113180. /**
  113181. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  113182. */
  113183. brightPassPostProcess: Nullable<PostProcess>;
  113184. /**
  113185. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  113186. */
  113187. blurHPostProcesses: PostProcess[];
  113188. /**
  113189. * Post-process array storing all the vertical blur post-processes used by the pipeline
  113190. */
  113191. blurVPostProcesses: PostProcess[];
  113192. /**
  113193. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  113194. */
  113195. textureAdderPostProcess: Nullable<PostProcess>;
  113196. /**
  113197. * Post-process used to create volumetric lighting effect
  113198. */
  113199. volumetricLightPostProcess: Nullable<PostProcess>;
  113200. /**
  113201. * Post-process used to smooth the previous volumetric light post-process on the X axis
  113202. */
  113203. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  113204. /**
  113205. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  113206. */
  113207. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  113208. /**
  113209. * Post-process used to merge the volumetric light effect and the real scene color
  113210. */
  113211. volumetricLightMergePostProces: Nullable<PostProcess>;
  113212. /**
  113213. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  113214. */
  113215. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  113216. /**
  113217. * Base post-process used to calculate the average luminance of the final image for HDR
  113218. */
  113219. luminancePostProcess: Nullable<PostProcess>;
  113220. /**
  113221. * Post-processes used to create down sample post-processes in order to get
  113222. * the average luminance of the final image for HDR
  113223. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  113224. */
  113225. luminanceDownSamplePostProcesses: PostProcess[];
  113226. /**
  113227. * Post-process used to create a HDR effect (light adaptation)
  113228. */
  113229. hdrPostProcess: Nullable<PostProcess>;
  113230. /**
  113231. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  113232. */
  113233. textureAdderFinalPostProcess: Nullable<PostProcess>;
  113234. /**
  113235. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  113236. */
  113237. lensFlareFinalPostProcess: Nullable<PostProcess>;
  113238. /**
  113239. * Post-process used to merge the final HDR post-process and the real scene color
  113240. */
  113241. hdrFinalPostProcess: Nullable<PostProcess>;
  113242. /**
  113243. * Post-process used to create a lens flare effect
  113244. */
  113245. lensFlarePostProcess: Nullable<PostProcess>;
  113246. /**
  113247. * Post-process that merges the result of the lens flare post-process and the real scene color
  113248. */
  113249. lensFlareComposePostProcess: Nullable<PostProcess>;
  113250. /**
  113251. * Post-process used to create a motion blur effect
  113252. */
  113253. motionBlurPostProcess: Nullable<PostProcess>;
  113254. /**
  113255. * Post-process used to create a depth of field effect
  113256. */
  113257. depthOfFieldPostProcess: Nullable<PostProcess>;
  113258. /**
  113259. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  113260. */
  113261. fxaaPostProcess: Nullable<FxaaPostProcess>;
  113262. /**
  113263. * Represents the brightness threshold in order to configure the illuminated surfaces
  113264. */
  113265. brightThreshold: number;
  113266. /**
  113267. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  113268. */
  113269. blurWidth: number;
  113270. /**
  113271. * Sets if the blur for highlighted surfaces must be only horizontal
  113272. */
  113273. horizontalBlur: boolean;
  113274. /**
  113275. * Gets the overall exposure used by the pipeline
  113276. */
  113277. /**
  113278. * Sets the overall exposure used by the pipeline
  113279. */
  113280. exposure: number;
  113281. /**
  113282. * Texture used typically to simulate "dirty" on camera lens
  113283. */
  113284. lensTexture: Nullable<Texture>;
  113285. /**
  113286. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  113287. */
  113288. volumetricLightCoefficient: number;
  113289. /**
  113290. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  113291. */
  113292. volumetricLightPower: number;
  113293. /**
  113294. * Used the set the blur intensity to smooth the volumetric lights
  113295. */
  113296. volumetricLightBlurScale: number;
  113297. /**
  113298. * Light (spot or directional) used to generate the volumetric lights rays
  113299. * The source light must have a shadow generate so the pipeline can get its
  113300. * depth map
  113301. */
  113302. sourceLight: Nullable<SpotLight | DirectionalLight>;
  113303. /**
  113304. * For eye adaptation, represents the minimum luminance the eye can see
  113305. */
  113306. hdrMinimumLuminance: number;
  113307. /**
  113308. * For eye adaptation, represents the decrease luminance speed
  113309. */
  113310. hdrDecreaseRate: number;
  113311. /**
  113312. * For eye adaptation, represents the increase luminance speed
  113313. */
  113314. hdrIncreaseRate: number;
  113315. /**
  113316. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  113317. */
  113318. /**
  113319. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  113320. */
  113321. hdrAutoExposure: boolean;
  113322. /**
  113323. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  113324. */
  113325. lensColorTexture: Nullable<Texture>;
  113326. /**
  113327. * The overall strengh for the lens flare effect
  113328. */
  113329. lensFlareStrength: number;
  113330. /**
  113331. * Dispersion coefficient for lens flare ghosts
  113332. */
  113333. lensFlareGhostDispersal: number;
  113334. /**
  113335. * Main lens flare halo width
  113336. */
  113337. lensFlareHaloWidth: number;
  113338. /**
  113339. * Based on the lens distortion effect, defines how much the lens flare result
  113340. * is distorted
  113341. */
  113342. lensFlareDistortionStrength: number;
  113343. /**
  113344. * Lens star texture must be used to simulate rays on the flares and is available
  113345. * in the documentation
  113346. */
  113347. lensStarTexture: Nullable<Texture>;
  113348. /**
  113349. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  113350. * flare effect by taking account of the dirt texture
  113351. */
  113352. lensFlareDirtTexture: Nullable<Texture>;
  113353. /**
  113354. * Represents the focal length for the depth of field effect
  113355. */
  113356. depthOfFieldDistance: number;
  113357. /**
  113358. * Represents the blur intensity for the blurred part of the depth of field effect
  113359. */
  113360. depthOfFieldBlurWidth: number;
  113361. /**
  113362. * For motion blur, defines how much the image is blurred by the movement
  113363. */
  113364. motionStrength: number;
  113365. /**
  113366. * List of animations for the pipeline (IAnimatable implementation)
  113367. */
  113368. animations: Animation[];
  113369. /**
  113370. * Private members
  113371. */
  113372. private _scene;
  113373. private _currentDepthOfFieldSource;
  113374. private _basePostProcess;
  113375. private _fixedExposure;
  113376. private _currentExposure;
  113377. private _hdrAutoExposure;
  113378. private _hdrCurrentLuminance;
  113379. private _floatTextureType;
  113380. private _ratio;
  113381. private _bloomEnabled;
  113382. private _depthOfFieldEnabled;
  113383. private _vlsEnabled;
  113384. private _lensFlareEnabled;
  113385. private _hdrEnabled;
  113386. private _motionBlurEnabled;
  113387. private _fxaaEnabled;
  113388. private _motionBlurSamples;
  113389. private _volumetricLightStepsCount;
  113390. private _samples;
  113391. /**
  113392. * @ignore
  113393. * Specifies if the bloom pipeline is enabled
  113394. */
  113395. BloomEnabled: boolean;
  113396. /**
  113397. * @ignore
  113398. * Specifies if the depth of field pipeline is enabed
  113399. */
  113400. DepthOfFieldEnabled: boolean;
  113401. /**
  113402. * @ignore
  113403. * Specifies if the lens flare pipeline is enabed
  113404. */
  113405. LensFlareEnabled: boolean;
  113406. /**
  113407. * @ignore
  113408. * Specifies if the HDR pipeline is enabled
  113409. */
  113410. HDREnabled: boolean;
  113411. /**
  113412. * @ignore
  113413. * Specifies if the volumetric lights scattering effect is enabled
  113414. */
  113415. VLSEnabled: boolean;
  113416. /**
  113417. * @ignore
  113418. * Specifies if the motion blur effect is enabled
  113419. */
  113420. MotionBlurEnabled: boolean;
  113421. /**
  113422. * Specifies if anti-aliasing is enabled
  113423. */
  113424. fxaaEnabled: boolean;
  113425. /**
  113426. * Specifies the number of steps used to calculate the volumetric lights
  113427. * Typically in interval [50, 200]
  113428. */
  113429. volumetricLightStepsCount: number;
  113430. /**
  113431. * Specifies the number of samples used for the motion blur effect
  113432. * Typically in interval [16, 64]
  113433. */
  113434. motionBlurSamples: number;
  113435. /**
  113436. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  113437. */
  113438. samples: number;
  113439. /**
  113440. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  113441. * @constructor
  113442. * @param name The rendering pipeline name
  113443. * @param scene The scene linked to this pipeline
  113444. * @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)
  113445. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  113446. * @param cameras The array of cameras that the rendering pipeline will be attached to
  113447. */
  113448. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  113449. private _buildPipeline;
  113450. private _createDownSampleX4PostProcess;
  113451. private _createBrightPassPostProcess;
  113452. private _createBlurPostProcesses;
  113453. private _createTextureAdderPostProcess;
  113454. private _createVolumetricLightPostProcess;
  113455. private _createLuminancePostProcesses;
  113456. private _createHdrPostProcess;
  113457. private _createLensFlarePostProcess;
  113458. private _createDepthOfFieldPostProcess;
  113459. private _createMotionBlurPostProcess;
  113460. private _getDepthTexture;
  113461. private _disposePostProcesses;
  113462. /**
  113463. * Dispose of the pipeline and stop all post processes
  113464. */
  113465. dispose(): void;
  113466. /**
  113467. * Serialize the rendering pipeline (Used when exporting)
  113468. * @returns the serialized object
  113469. */
  113470. serialize(): any;
  113471. /**
  113472. * Parse the serialized pipeline
  113473. * @param source Source pipeline.
  113474. * @param scene The scene to load the pipeline to.
  113475. * @param rootUrl The URL of the serialized pipeline.
  113476. * @returns An instantiated pipeline from the serialized object.
  113477. */
  113478. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  113479. /**
  113480. * Luminance steps
  113481. */
  113482. static LuminanceSteps: number;
  113483. }
  113484. }
  113485. declare module BABYLON {
  113486. /** @hidden */
  113487. export var tonemapPixelShader: {
  113488. name: string;
  113489. shader: string;
  113490. };
  113491. }
  113492. declare module BABYLON {
  113493. /** Defines operator used for tonemapping */
  113494. export enum TonemappingOperator {
  113495. /** Hable */
  113496. Hable = 0,
  113497. /** Reinhard */
  113498. Reinhard = 1,
  113499. /** HejiDawson */
  113500. HejiDawson = 2,
  113501. /** Photographic */
  113502. Photographic = 3
  113503. }
  113504. /**
  113505. * Defines a post process to apply tone mapping
  113506. */
  113507. export class TonemapPostProcess extends PostProcess {
  113508. private _operator;
  113509. /** Defines the required exposure adjustement */
  113510. exposureAdjustment: number;
  113511. /**
  113512. * Creates a new TonemapPostProcess
  113513. * @param name defines the name of the postprocess
  113514. * @param _operator defines the operator to use
  113515. * @param exposureAdjustment defines the required exposure adjustement
  113516. * @param camera defines the camera to use (can be null)
  113517. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  113518. * @param engine defines the hosting engine (can be ignore if camera is set)
  113519. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  113520. */
  113521. constructor(name: string, _operator: TonemappingOperator,
  113522. /** Defines the required exposure adjustement */
  113523. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  113524. }
  113525. }
  113526. declare module BABYLON {
  113527. /** @hidden */
  113528. export var depthVertexShader: {
  113529. name: string;
  113530. shader: string;
  113531. };
  113532. }
  113533. declare module BABYLON {
  113534. /** @hidden */
  113535. export var volumetricLightScatteringPixelShader: {
  113536. name: string;
  113537. shader: string;
  113538. };
  113539. }
  113540. declare module BABYLON {
  113541. /** @hidden */
  113542. export var volumetricLightScatteringPassPixelShader: {
  113543. name: string;
  113544. shader: string;
  113545. };
  113546. }
  113547. declare module BABYLON {
  113548. /**
  113549. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  113550. */
  113551. export class VolumetricLightScatteringPostProcess extends PostProcess {
  113552. private _volumetricLightScatteringPass;
  113553. private _volumetricLightScatteringRTT;
  113554. private _viewPort;
  113555. private _screenCoordinates;
  113556. private _cachedDefines;
  113557. /**
  113558. * If not undefined, the mesh position is computed from the attached node position
  113559. */
  113560. attachedNode: {
  113561. position: Vector3;
  113562. };
  113563. /**
  113564. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  113565. */
  113566. customMeshPosition: Vector3;
  113567. /**
  113568. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  113569. */
  113570. useCustomMeshPosition: boolean;
  113571. /**
  113572. * If the post-process should inverse the light scattering direction
  113573. */
  113574. invert: boolean;
  113575. /**
  113576. * The internal mesh used by the post-process
  113577. */
  113578. mesh: Mesh;
  113579. /**
  113580. * @hidden
  113581. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  113582. */
  113583. useDiffuseColor: boolean;
  113584. /**
  113585. * Array containing the excluded meshes not rendered in the internal pass
  113586. */
  113587. excludedMeshes: AbstractMesh[];
  113588. /**
  113589. * Controls the overall intensity of the post-process
  113590. */
  113591. exposure: number;
  113592. /**
  113593. * Dissipates each sample's contribution in range [0, 1]
  113594. */
  113595. decay: number;
  113596. /**
  113597. * Controls the overall intensity of each sample
  113598. */
  113599. weight: number;
  113600. /**
  113601. * Controls the density of each sample
  113602. */
  113603. density: number;
  113604. /**
  113605. * @constructor
  113606. * @param name The post-process name
  113607. * @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)
  113608. * @param camera The camera that the post-process will be attached to
  113609. * @param mesh The mesh used to create the light scattering
  113610. * @param samples The post-process quality, default 100
  113611. * @param samplingModeThe post-process filtering mode
  113612. * @param engine The babylon engine
  113613. * @param reusable If the post-process is reusable
  113614. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  113615. */
  113616. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  113617. /**
  113618. * Returns the string "VolumetricLightScatteringPostProcess"
  113619. * @returns "VolumetricLightScatteringPostProcess"
  113620. */
  113621. getClassName(): string;
  113622. private _isReady;
  113623. /**
  113624. * Sets the new light position for light scattering effect
  113625. * @param position The new custom light position
  113626. */
  113627. setCustomMeshPosition(position: Vector3): void;
  113628. /**
  113629. * Returns the light position for light scattering effect
  113630. * @return Vector3 The custom light position
  113631. */
  113632. getCustomMeshPosition(): Vector3;
  113633. /**
  113634. * Disposes the internal assets and detaches the post-process from the camera
  113635. */
  113636. dispose(camera: Camera): void;
  113637. /**
  113638. * Returns the render target texture used by the post-process
  113639. * @return the render target texture used by the post-process
  113640. */
  113641. getPass(): RenderTargetTexture;
  113642. private _meshExcluded;
  113643. private _createPass;
  113644. private _updateMeshScreenCoordinates;
  113645. /**
  113646. * Creates a default mesh for the Volumeric Light Scattering post-process
  113647. * @param name The mesh name
  113648. * @param scene The scene where to create the mesh
  113649. * @return the default mesh
  113650. */
  113651. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  113652. }
  113653. }
  113654. declare module BABYLON {
  113655. interface Scene {
  113656. /** @hidden (Backing field) */
  113657. _boundingBoxRenderer: BoundingBoxRenderer;
  113658. /** @hidden (Backing field) */
  113659. _forceShowBoundingBoxes: boolean;
  113660. /**
  113661. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  113662. */
  113663. forceShowBoundingBoxes: boolean;
  113664. /**
  113665. * Gets the bounding box renderer associated with the scene
  113666. * @returns a BoundingBoxRenderer
  113667. */
  113668. getBoundingBoxRenderer(): BoundingBoxRenderer;
  113669. }
  113670. interface AbstractMesh {
  113671. /** @hidden (Backing field) */
  113672. _showBoundingBox: boolean;
  113673. /**
  113674. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  113675. */
  113676. showBoundingBox: boolean;
  113677. }
  113678. /**
  113679. * Component responsible of rendering the bounding box of the meshes in a scene.
  113680. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  113681. */
  113682. export class BoundingBoxRenderer implements ISceneComponent {
  113683. /**
  113684. * The component name helpfull to identify the component in the list of scene components.
  113685. */
  113686. readonly name: string;
  113687. /**
  113688. * The scene the component belongs to.
  113689. */
  113690. scene: Scene;
  113691. /**
  113692. * Color of the bounding box lines placed in front of an object
  113693. */
  113694. frontColor: Color3;
  113695. /**
  113696. * Color of the bounding box lines placed behind an object
  113697. */
  113698. backColor: Color3;
  113699. /**
  113700. * Defines if the renderer should show the back lines or not
  113701. */
  113702. showBackLines: boolean;
  113703. /**
  113704. * @hidden
  113705. */
  113706. renderList: SmartArray<BoundingBox>;
  113707. private _colorShader;
  113708. private _vertexBuffers;
  113709. private _indexBuffer;
  113710. /**
  113711. * Instantiates a new bounding box renderer in a scene.
  113712. * @param scene the scene the renderer renders in
  113713. */
  113714. constructor(scene: Scene);
  113715. /**
  113716. * Registers the component in a given scene
  113717. */
  113718. register(): void;
  113719. private _evaluateSubMesh;
  113720. private _activeMesh;
  113721. private _prepareRessources;
  113722. private _createIndexBuffer;
  113723. /**
  113724. * Rebuilds the elements related to this component in case of
  113725. * context lost for instance.
  113726. */
  113727. rebuild(): void;
  113728. /**
  113729. * @hidden
  113730. */
  113731. reset(): void;
  113732. /**
  113733. * Render the bounding boxes of a specific rendering group
  113734. * @param renderingGroupId defines the rendering group to render
  113735. */
  113736. render(renderingGroupId: number): void;
  113737. /**
  113738. * In case of occlusion queries, we can render the occlusion bounding box through this method
  113739. * @param mesh Define the mesh to render the occlusion bounding box for
  113740. */
  113741. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  113742. /**
  113743. * Dispose and release the resources attached to this renderer.
  113744. */
  113745. dispose(): void;
  113746. }
  113747. }
  113748. declare module BABYLON {
  113749. /** @hidden */
  113750. export var depthPixelShader: {
  113751. name: string;
  113752. shader: string;
  113753. };
  113754. }
  113755. declare module BABYLON {
  113756. /**
  113757. * This represents a depth renderer in Babylon.
  113758. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  113759. */
  113760. export class DepthRenderer {
  113761. private _scene;
  113762. private _depthMap;
  113763. private _effect;
  113764. private _cachedDefines;
  113765. private _camera;
  113766. /**
  113767. * Specifiess that the depth renderer will only be used within
  113768. * the camera it is created for.
  113769. * This can help forcing its rendering during the camera processing.
  113770. */
  113771. useOnlyInActiveCamera: boolean;
  113772. /** @hidden */
  113773. static _SceneComponentInitialization: (scene: Scene) => void;
  113774. /**
  113775. * Instantiates a depth renderer
  113776. * @param scene The scene the renderer belongs to
  113777. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  113778. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  113779. */
  113780. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  113781. /**
  113782. * Creates the depth rendering effect and checks if the effect is ready.
  113783. * @param subMesh The submesh to be used to render the depth map of
  113784. * @param useInstances If multiple world instances should be used
  113785. * @returns if the depth renderer is ready to render the depth map
  113786. */
  113787. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  113788. /**
  113789. * Gets the texture which the depth map will be written to.
  113790. * @returns The depth map texture
  113791. */
  113792. getDepthMap(): RenderTargetTexture;
  113793. /**
  113794. * Disposes of the depth renderer.
  113795. */
  113796. dispose(): void;
  113797. }
  113798. }
  113799. declare module BABYLON {
  113800. interface Scene {
  113801. /** @hidden (Backing field) */
  113802. _depthRenderer: {
  113803. [id: string]: DepthRenderer;
  113804. };
  113805. /**
  113806. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  113807. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  113808. * @returns the created depth renderer
  113809. */
  113810. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  113811. /**
  113812. * Disables a depth renderer for a given camera
  113813. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  113814. */
  113815. disableDepthRenderer(camera?: Nullable<Camera>): void;
  113816. }
  113817. /**
  113818. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  113819. * in several rendering techniques.
  113820. */
  113821. export class DepthRendererSceneComponent implements ISceneComponent {
  113822. /**
  113823. * The component name helpfull to identify the component in the list of scene components.
  113824. */
  113825. readonly name: string;
  113826. /**
  113827. * The scene the component belongs to.
  113828. */
  113829. scene: Scene;
  113830. /**
  113831. * Creates a new instance of the component for the given scene
  113832. * @param scene Defines the scene to register the component in
  113833. */
  113834. constructor(scene: Scene);
  113835. /**
  113836. * Registers the component in a given scene
  113837. */
  113838. register(): void;
  113839. /**
  113840. * Rebuilds the elements related to this component in case of
  113841. * context lost for instance.
  113842. */
  113843. rebuild(): void;
  113844. /**
  113845. * Disposes the component and the associated ressources
  113846. */
  113847. dispose(): void;
  113848. private _gatherRenderTargets;
  113849. private _gatherActiveCameraRenderTargets;
  113850. }
  113851. }
  113852. declare module BABYLON {
  113853. /** @hidden */
  113854. export var outlinePixelShader: {
  113855. name: string;
  113856. shader: string;
  113857. };
  113858. }
  113859. declare module BABYLON {
  113860. /** @hidden */
  113861. export var outlineVertexShader: {
  113862. name: string;
  113863. shader: string;
  113864. };
  113865. }
  113866. declare module BABYLON {
  113867. interface Scene {
  113868. /** @hidden */
  113869. _outlineRenderer: OutlineRenderer;
  113870. /**
  113871. * Gets the outline renderer associated with the scene
  113872. * @returns a OutlineRenderer
  113873. */
  113874. getOutlineRenderer(): OutlineRenderer;
  113875. }
  113876. interface AbstractMesh {
  113877. /** @hidden (Backing field) */
  113878. _renderOutline: boolean;
  113879. /**
  113880. * Gets or sets a boolean indicating if the outline must be rendered as well
  113881. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  113882. */
  113883. renderOutline: boolean;
  113884. /** @hidden (Backing field) */
  113885. _renderOverlay: boolean;
  113886. /**
  113887. * Gets or sets a boolean indicating if the overlay must be rendered as well
  113888. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  113889. */
  113890. renderOverlay: boolean;
  113891. }
  113892. /**
  113893. * This class is responsible to draw bothe outline/overlay of meshes.
  113894. * It should not be used directly but through the available method on mesh.
  113895. */
  113896. export class OutlineRenderer implements ISceneComponent {
  113897. /**
  113898. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  113899. */
  113900. private static _StencilReference;
  113901. /**
  113902. * The name of the component. Each component must have a unique name.
  113903. */
  113904. name: string;
  113905. /**
  113906. * The scene the component belongs to.
  113907. */
  113908. scene: Scene;
  113909. /**
  113910. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  113911. */
  113912. zOffset: number;
  113913. private _engine;
  113914. private _effect;
  113915. private _cachedDefines;
  113916. private _savedDepthWrite;
  113917. /**
  113918. * Instantiates a new outline renderer. (There could be only one per scene).
  113919. * @param scene Defines the scene it belongs to
  113920. */
  113921. constructor(scene: Scene);
  113922. /**
  113923. * Register the component to one instance of a scene.
  113924. */
  113925. register(): void;
  113926. /**
  113927. * Rebuilds the elements related to this component in case of
  113928. * context lost for instance.
  113929. */
  113930. rebuild(): void;
  113931. /**
  113932. * Disposes the component and the associated ressources.
  113933. */
  113934. dispose(): void;
  113935. /**
  113936. * Renders the outline in the canvas.
  113937. * @param subMesh Defines the sumesh to render
  113938. * @param batch Defines the batch of meshes in case of instances
  113939. * @param useOverlay Defines if the rendering is for the overlay or the outline
  113940. */
  113941. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  113942. /**
  113943. * Returns whether or not the outline renderer is ready for a given submesh.
  113944. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  113945. * @param subMesh Defines the submesh to check readyness for
  113946. * @param useInstances Defines wheter wee are trying to render instances or not
  113947. * @returns true if ready otherwise false
  113948. */
  113949. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  113950. private _beforeRenderingMesh;
  113951. private _afterRenderingMesh;
  113952. }
  113953. }
  113954. declare module BABYLON {
  113955. /**
  113956. * Defines the list of states available for a task inside a AssetsManager
  113957. */
  113958. export enum AssetTaskState {
  113959. /**
  113960. * Initialization
  113961. */
  113962. INIT = 0,
  113963. /**
  113964. * Running
  113965. */
  113966. RUNNING = 1,
  113967. /**
  113968. * Done
  113969. */
  113970. DONE = 2,
  113971. /**
  113972. * Error
  113973. */
  113974. ERROR = 3
  113975. }
  113976. /**
  113977. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  113978. */
  113979. export abstract class AbstractAssetTask {
  113980. /**
  113981. * Task name
  113982. */ name: string;
  113983. /**
  113984. * Callback called when the task is successful
  113985. */
  113986. onSuccess: (task: any) => void;
  113987. /**
  113988. * Callback called when the task is not successful
  113989. */
  113990. onError: (task: any, message?: string, exception?: any) => void;
  113991. /**
  113992. * Creates a new AssetsManager
  113993. * @param name defines the name of the task
  113994. */
  113995. constructor(
  113996. /**
  113997. * Task name
  113998. */ name: string);
  113999. private _isCompleted;
  114000. private _taskState;
  114001. private _errorObject;
  114002. /**
  114003. * Get if the task is completed
  114004. */
  114005. readonly isCompleted: boolean;
  114006. /**
  114007. * Gets the current state of the task
  114008. */
  114009. readonly taskState: AssetTaskState;
  114010. /**
  114011. * Gets the current error object (if task is in error)
  114012. */
  114013. readonly errorObject: {
  114014. message?: string;
  114015. exception?: any;
  114016. };
  114017. /**
  114018. * Internal only
  114019. * @hidden
  114020. */
  114021. _setErrorObject(message?: string, exception?: any): void;
  114022. /**
  114023. * Execute the current task
  114024. * @param scene defines the scene where you want your assets to be loaded
  114025. * @param onSuccess is a callback called when the task is successfully executed
  114026. * @param onError is a callback called if an error occurs
  114027. */
  114028. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114029. /**
  114030. * Execute the current task
  114031. * @param scene defines the scene where you want your assets to be loaded
  114032. * @param onSuccess is a callback called when the task is successfully executed
  114033. * @param onError is a callback called if an error occurs
  114034. */
  114035. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114036. /**
  114037. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  114038. * This can be used with failed tasks that have the reason for failure fixed.
  114039. */
  114040. reset(): void;
  114041. private onErrorCallback;
  114042. private onDoneCallback;
  114043. }
  114044. /**
  114045. * Define the interface used by progress events raised during assets loading
  114046. */
  114047. export interface IAssetsProgressEvent {
  114048. /**
  114049. * Defines the number of remaining tasks to process
  114050. */
  114051. remainingCount: number;
  114052. /**
  114053. * Defines the total number of tasks
  114054. */
  114055. totalCount: number;
  114056. /**
  114057. * Defines the task that was just processed
  114058. */
  114059. task: AbstractAssetTask;
  114060. }
  114061. /**
  114062. * Class used to share progress information about assets loading
  114063. */
  114064. export class AssetsProgressEvent implements IAssetsProgressEvent {
  114065. /**
  114066. * Defines the number of remaining tasks to process
  114067. */
  114068. remainingCount: number;
  114069. /**
  114070. * Defines the total number of tasks
  114071. */
  114072. totalCount: number;
  114073. /**
  114074. * Defines the task that was just processed
  114075. */
  114076. task: AbstractAssetTask;
  114077. /**
  114078. * Creates a AssetsProgressEvent
  114079. * @param remainingCount defines the number of remaining tasks to process
  114080. * @param totalCount defines the total number of tasks
  114081. * @param task defines the task that was just processed
  114082. */
  114083. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  114084. }
  114085. /**
  114086. * Define a task used by AssetsManager to load meshes
  114087. */
  114088. export class MeshAssetTask extends AbstractAssetTask {
  114089. /**
  114090. * Defines the name of the task
  114091. */
  114092. name: string;
  114093. /**
  114094. * Defines the list of mesh's names you want to load
  114095. */
  114096. meshesNames: any;
  114097. /**
  114098. * Defines the root url to use as a base to load your meshes and associated resources
  114099. */
  114100. rootUrl: string;
  114101. /**
  114102. * Defines the filename of the scene to load from
  114103. */
  114104. sceneFilename: string;
  114105. /**
  114106. * Gets the list of loaded meshes
  114107. */
  114108. loadedMeshes: Array<AbstractMesh>;
  114109. /**
  114110. * Gets the list of loaded particle systems
  114111. */
  114112. loadedParticleSystems: Array<IParticleSystem>;
  114113. /**
  114114. * Gets the list of loaded skeletons
  114115. */
  114116. loadedSkeletons: Array<Skeleton>;
  114117. /**
  114118. * Gets the list of loaded animation groups
  114119. */
  114120. loadedAnimationGroups: Array<AnimationGroup>;
  114121. /**
  114122. * Callback called when the task is successful
  114123. */
  114124. onSuccess: (task: MeshAssetTask) => void;
  114125. /**
  114126. * Callback called when the task is successful
  114127. */
  114128. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  114129. /**
  114130. * Creates a new MeshAssetTask
  114131. * @param name defines the name of the task
  114132. * @param meshesNames defines the list of mesh's names you want to load
  114133. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  114134. * @param sceneFilename defines the filename of the scene to load from
  114135. */
  114136. constructor(
  114137. /**
  114138. * Defines the name of the task
  114139. */
  114140. name: string,
  114141. /**
  114142. * Defines the list of mesh's names you want to load
  114143. */
  114144. meshesNames: any,
  114145. /**
  114146. * Defines the root url to use as a base to load your meshes and associated resources
  114147. */
  114148. rootUrl: string,
  114149. /**
  114150. * Defines the filename of the scene to load from
  114151. */
  114152. sceneFilename: string);
  114153. /**
  114154. * Execute the current task
  114155. * @param scene defines the scene where you want your assets to be loaded
  114156. * @param onSuccess is a callback called when the task is successfully executed
  114157. * @param onError is a callback called if an error occurs
  114158. */
  114159. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114160. }
  114161. /**
  114162. * Define a task used by AssetsManager to load text content
  114163. */
  114164. export class TextFileAssetTask extends AbstractAssetTask {
  114165. /**
  114166. * Defines the name of the task
  114167. */
  114168. name: string;
  114169. /**
  114170. * Defines the location of the file to load
  114171. */
  114172. url: string;
  114173. /**
  114174. * Gets the loaded text string
  114175. */
  114176. text: string;
  114177. /**
  114178. * Callback called when the task is successful
  114179. */
  114180. onSuccess: (task: TextFileAssetTask) => void;
  114181. /**
  114182. * Callback called when the task is successful
  114183. */
  114184. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  114185. /**
  114186. * Creates a new TextFileAssetTask object
  114187. * @param name defines the name of the task
  114188. * @param url defines the location of the file to load
  114189. */
  114190. constructor(
  114191. /**
  114192. * Defines the name of the task
  114193. */
  114194. name: string,
  114195. /**
  114196. * Defines the location of the file to load
  114197. */
  114198. url: string);
  114199. /**
  114200. * Execute the current task
  114201. * @param scene defines the scene where you want your assets to be loaded
  114202. * @param onSuccess is a callback called when the task is successfully executed
  114203. * @param onError is a callback called if an error occurs
  114204. */
  114205. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114206. }
  114207. /**
  114208. * Define a task used by AssetsManager to load binary data
  114209. */
  114210. export class BinaryFileAssetTask extends AbstractAssetTask {
  114211. /**
  114212. * Defines the name of the task
  114213. */
  114214. name: string;
  114215. /**
  114216. * Defines the location of the file to load
  114217. */
  114218. url: string;
  114219. /**
  114220. * Gets the lodaded data (as an array buffer)
  114221. */
  114222. data: ArrayBuffer;
  114223. /**
  114224. * Callback called when the task is successful
  114225. */
  114226. onSuccess: (task: BinaryFileAssetTask) => void;
  114227. /**
  114228. * Callback called when the task is successful
  114229. */
  114230. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  114231. /**
  114232. * Creates a new BinaryFileAssetTask object
  114233. * @param name defines the name of the new task
  114234. * @param url defines the location of the file to load
  114235. */
  114236. constructor(
  114237. /**
  114238. * Defines the name of the task
  114239. */
  114240. name: string,
  114241. /**
  114242. * Defines the location of the file to load
  114243. */
  114244. url: string);
  114245. /**
  114246. * Execute the current task
  114247. * @param scene defines the scene where you want your assets to be loaded
  114248. * @param onSuccess is a callback called when the task is successfully executed
  114249. * @param onError is a callback called if an error occurs
  114250. */
  114251. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114252. }
  114253. /**
  114254. * Define a task used by AssetsManager to load images
  114255. */
  114256. export class ImageAssetTask extends AbstractAssetTask {
  114257. /**
  114258. * Defines the name of the task
  114259. */
  114260. name: string;
  114261. /**
  114262. * Defines the location of the image to load
  114263. */
  114264. url: string;
  114265. /**
  114266. * Gets the loaded images
  114267. */
  114268. image: HTMLImageElement;
  114269. /**
  114270. * Callback called when the task is successful
  114271. */
  114272. onSuccess: (task: ImageAssetTask) => void;
  114273. /**
  114274. * Callback called when the task is successful
  114275. */
  114276. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  114277. /**
  114278. * Creates a new ImageAssetTask
  114279. * @param name defines the name of the task
  114280. * @param url defines the location of the image to load
  114281. */
  114282. constructor(
  114283. /**
  114284. * Defines the name of the task
  114285. */
  114286. name: string,
  114287. /**
  114288. * Defines the location of the image to load
  114289. */
  114290. url: string);
  114291. /**
  114292. * Execute the current task
  114293. * @param scene defines the scene where you want your assets to be loaded
  114294. * @param onSuccess is a callback called when the task is successfully executed
  114295. * @param onError is a callback called if an error occurs
  114296. */
  114297. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114298. }
  114299. /**
  114300. * Defines the interface used by texture loading tasks
  114301. */
  114302. export interface ITextureAssetTask<TEX extends BaseTexture> {
  114303. /**
  114304. * Gets the loaded texture
  114305. */
  114306. texture: TEX;
  114307. }
  114308. /**
  114309. * Define a task used by AssetsManager to load 2D textures
  114310. */
  114311. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  114312. /**
  114313. * Defines the name of the task
  114314. */
  114315. name: string;
  114316. /**
  114317. * Defines the location of the file to load
  114318. */
  114319. url: string;
  114320. /**
  114321. * Defines if mipmap should not be generated (default is false)
  114322. */
  114323. noMipmap?: boolean | undefined;
  114324. /**
  114325. * Defines if texture must be inverted on Y axis (default is false)
  114326. */
  114327. invertY?: boolean | undefined;
  114328. /**
  114329. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  114330. */
  114331. samplingMode: number;
  114332. /**
  114333. * Gets the loaded texture
  114334. */
  114335. texture: Texture;
  114336. /**
  114337. * Callback called when the task is successful
  114338. */
  114339. onSuccess: (task: TextureAssetTask) => void;
  114340. /**
  114341. * Callback called when the task is successful
  114342. */
  114343. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  114344. /**
  114345. * Creates a new TextureAssetTask object
  114346. * @param name defines the name of the task
  114347. * @param url defines the location of the file to load
  114348. * @param noMipmap defines if mipmap should not be generated (default is false)
  114349. * @param invertY defines if texture must be inverted on Y axis (default is false)
  114350. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  114351. */
  114352. constructor(
  114353. /**
  114354. * Defines the name of the task
  114355. */
  114356. name: string,
  114357. /**
  114358. * Defines the location of the file to load
  114359. */
  114360. url: string,
  114361. /**
  114362. * Defines if mipmap should not be generated (default is false)
  114363. */
  114364. noMipmap?: boolean | undefined,
  114365. /**
  114366. * Defines if texture must be inverted on Y axis (default is false)
  114367. */
  114368. invertY?: boolean | undefined,
  114369. /**
  114370. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  114371. */
  114372. samplingMode?: number);
  114373. /**
  114374. * Execute the current task
  114375. * @param scene defines the scene where you want your assets to be loaded
  114376. * @param onSuccess is a callback called when the task is successfully executed
  114377. * @param onError is a callback called if an error occurs
  114378. */
  114379. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114380. }
  114381. /**
  114382. * Define a task used by AssetsManager to load cube textures
  114383. */
  114384. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  114385. /**
  114386. * Defines the name of the task
  114387. */
  114388. name: string;
  114389. /**
  114390. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  114391. */
  114392. url: string;
  114393. /**
  114394. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  114395. */
  114396. extensions?: string[] | undefined;
  114397. /**
  114398. * Defines if mipmaps should not be generated (default is false)
  114399. */
  114400. noMipmap?: boolean | undefined;
  114401. /**
  114402. * Defines the explicit list of files (undefined by default)
  114403. */
  114404. files?: string[] | undefined;
  114405. /**
  114406. * Gets the loaded texture
  114407. */
  114408. texture: CubeTexture;
  114409. /**
  114410. * Callback called when the task is successful
  114411. */
  114412. onSuccess: (task: CubeTextureAssetTask) => void;
  114413. /**
  114414. * Callback called when the task is successful
  114415. */
  114416. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  114417. /**
  114418. * Creates a new CubeTextureAssetTask
  114419. * @param name defines the name of the task
  114420. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  114421. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  114422. * @param noMipmap defines if mipmaps should not be generated (default is false)
  114423. * @param files defines the explicit list of files (undefined by default)
  114424. */
  114425. constructor(
  114426. /**
  114427. * Defines the name of the task
  114428. */
  114429. name: string,
  114430. /**
  114431. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  114432. */
  114433. url: string,
  114434. /**
  114435. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  114436. */
  114437. extensions?: string[] | undefined,
  114438. /**
  114439. * Defines if mipmaps should not be generated (default is false)
  114440. */
  114441. noMipmap?: boolean | undefined,
  114442. /**
  114443. * Defines the explicit list of files (undefined by default)
  114444. */
  114445. files?: string[] | undefined);
  114446. /**
  114447. * Execute the current task
  114448. * @param scene defines the scene where you want your assets to be loaded
  114449. * @param onSuccess is a callback called when the task is successfully executed
  114450. * @param onError is a callback called if an error occurs
  114451. */
  114452. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114453. }
  114454. /**
  114455. * Define a task used by AssetsManager to load HDR cube textures
  114456. */
  114457. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  114458. /**
  114459. * Defines the name of the task
  114460. */
  114461. name: string;
  114462. /**
  114463. * Defines the location of the file to load
  114464. */
  114465. url: string;
  114466. /**
  114467. * Defines the desired size (the more it increases the longer the generation will be)
  114468. */
  114469. size: number;
  114470. /**
  114471. * Defines if mipmaps should not be generated (default is false)
  114472. */
  114473. noMipmap: boolean;
  114474. /**
  114475. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  114476. */
  114477. generateHarmonics: boolean;
  114478. /**
  114479. * 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)
  114480. */
  114481. gammaSpace: boolean;
  114482. /**
  114483. * Internal Use Only
  114484. */
  114485. reserved: boolean;
  114486. /**
  114487. * Gets the loaded texture
  114488. */
  114489. texture: HDRCubeTexture;
  114490. /**
  114491. * Callback called when the task is successful
  114492. */
  114493. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  114494. /**
  114495. * Callback called when the task is successful
  114496. */
  114497. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  114498. /**
  114499. * Creates a new HDRCubeTextureAssetTask object
  114500. * @param name defines the name of the task
  114501. * @param url defines the location of the file to load
  114502. * @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.
  114503. * @param noMipmap defines if mipmaps should not be generated (default is false)
  114504. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  114505. * @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)
  114506. * @param reserved Internal use only
  114507. */
  114508. constructor(
  114509. /**
  114510. * Defines the name of the task
  114511. */
  114512. name: string,
  114513. /**
  114514. * Defines the location of the file to load
  114515. */
  114516. url: string,
  114517. /**
  114518. * Defines the desired size (the more it increases the longer the generation will be)
  114519. */
  114520. size: number,
  114521. /**
  114522. * Defines if mipmaps should not be generated (default is false)
  114523. */
  114524. noMipmap?: boolean,
  114525. /**
  114526. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  114527. */
  114528. generateHarmonics?: boolean,
  114529. /**
  114530. * 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)
  114531. */
  114532. gammaSpace?: boolean,
  114533. /**
  114534. * Internal Use Only
  114535. */
  114536. reserved?: boolean);
  114537. /**
  114538. * Execute the current task
  114539. * @param scene defines the scene where you want your assets to be loaded
  114540. * @param onSuccess is a callback called when the task is successfully executed
  114541. * @param onError is a callback called if an error occurs
  114542. */
  114543. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114544. }
  114545. /**
  114546. * Define a task used by AssetsManager to load Equirectangular cube textures
  114547. */
  114548. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  114549. /**
  114550. * Defines the name of the task
  114551. */
  114552. name: string;
  114553. /**
  114554. * Defines the location of the file to load
  114555. */
  114556. url: string;
  114557. /**
  114558. * Defines the desired size (the more it increases the longer the generation will be)
  114559. */
  114560. size: number;
  114561. /**
  114562. * Defines if mipmaps should not be generated (default is false)
  114563. */
  114564. noMipmap: boolean;
  114565. /**
  114566. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  114567. * but the standard material would require them in Gamma space) (default is true)
  114568. */
  114569. gammaSpace: boolean;
  114570. /**
  114571. * Gets the loaded texture
  114572. */
  114573. texture: EquiRectangularCubeTexture;
  114574. /**
  114575. * Callback called when the task is successful
  114576. */
  114577. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  114578. /**
  114579. * Callback called when the task is successful
  114580. */
  114581. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  114582. /**
  114583. * Creates a new EquiRectangularCubeTextureAssetTask object
  114584. * @param name defines the name of the task
  114585. * @param url defines the location of the file to load
  114586. * @param size defines the desired size (the more it increases the longer the generation will be)
  114587. * If the size is omitted this implies you are using a preprocessed cubemap.
  114588. * @param noMipmap defines if mipmaps should not be generated (default is false)
  114589. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  114590. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  114591. * (default is true)
  114592. */
  114593. constructor(
  114594. /**
  114595. * Defines the name of the task
  114596. */
  114597. name: string,
  114598. /**
  114599. * Defines the location of the file to load
  114600. */
  114601. url: string,
  114602. /**
  114603. * Defines the desired size (the more it increases the longer the generation will be)
  114604. */
  114605. size: number,
  114606. /**
  114607. * Defines if mipmaps should not be generated (default is false)
  114608. */
  114609. noMipmap?: boolean,
  114610. /**
  114611. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  114612. * but the standard material would require them in Gamma space) (default is true)
  114613. */
  114614. gammaSpace?: boolean);
  114615. /**
  114616. * Execute the current task
  114617. * @param scene defines the scene where you want your assets to be loaded
  114618. * @param onSuccess is a callback called when the task is successfully executed
  114619. * @param onError is a callback called if an error occurs
  114620. */
  114621. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114622. }
  114623. /**
  114624. * This class can be used to easily import assets into a scene
  114625. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  114626. */
  114627. export class AssetsManager {
  114628. private _scene;
  114629. private _isLoading;
  114630. protected _tasks: AbstractAssetTask[];
  114631. protected _waitingTasksCount: number;
  114632. protected _totalTasksCount: number;
  114633. /**
  114634. * Callback called when all tasks are processed
  114635. */
  114636. onFinish: (tasks: AbstractAssetTask[]) => void;
  114637. /**
  114638. * Callback called when a task is successful
  114639. */
  114640. onTaskSuccess: (task: AbstractAssetTask) => void;
  114641. /**
  114642. * Callback called when a task had an error
  114643. */
  114644. onTaskError: (task: AbstractAssetTask) => void;
  114645. /**
  114646. * Callback called when a task is done (whatever the result is)
  114647. */
  114648. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  114649. /**
  114650. * Observable called when all tasks are processed
  114651. */
  114652. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  114653. /**
  114654. * Observable called when a task had an error
  114655. */
  114656. onTaskErrorObservable: Observable<AbstractAssetTask>;
  114657. /**
  114658. * Observable called when all tasks were executed
  114659. */
  114660. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  114661. /**
  114662. * Observable called when a task is done (whatever the result is)
  114663. */
  114664. onProgressObservable: Observable<IAssetsProgressEvent>;
  114665. /**
  114666. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  114667. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114668. */
  114669. useDefaultLoadingScreen: boolean;
  114670. /**
  114671. * Creates a new AssetsManager
  114672. * @param scene defines the scene to work on
  114673. */
  114674. constructor(scene: Scene);
  114675. /**
  114676. * Add a MeshAssetTask to the list of active tasks
  114677. * @param taskName defines the name of the new task
  114678. * @param meshesNames defines the name of meshes to load
  114679. * @param rootUrl defines the root url to use to locate files
  114680. * @param sceneFilename defines the filename of the scene file
  114681. * @returns a new MeshAssetTask object
  114682. */
  114683. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  114684. /**
  114685. * Add a TextFileAssetTask to the list of active tasks
  114686. * @param taskName defines the name of the new task
  114687. * @param url defines the url of the file to load
  114688. * @returns a new TextFileAssetTask object
  114689. */
  114690. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  114691. /**
  114692. * Add a BinaryFileAssetTask to the list of active tasks
  114693. * @param taskName defines the name of the new task
  114694. * @param url defines the url of the file to load
  114695. * @returns a new BinaryFileAssetTask object
  114696. */
  114697. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  114698. /**
  114699. * Add a ImageAssetTask to the list of active tasks
  114700. * @param taskName defines the name of the new task
  114701. * @param url defines the url of the file to load
  114702. * @returns a new ImageAssetTask object
  114703. */
  114704. addImageTask(taskName: string, url: string): ImageAssetTask;
  114705. /**
  114706. * Add a TextureAssetTask to the list of active tasks
  114707. * @param taskName defines the name of the new task
  114708. * @param url defines the url of the file to load
  114709. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  114710. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  114711. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  114712. * @returns a new TextureAssetTask object
  114713. */
  114714. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  114715. /**
  114716. * Add a CubeTextureAssetTask to the list of active tasks
  114717. * @param taskName defines the name of the new task
  114718. * @param url defines the url of the file to load
  114719. * @param extensions defines the extension to use to load the cube map (can be null)
  114720. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  114721. * @param files defines the list of files to load (can be null)
  114722. * @returns a new CubeTextureAssetTask object
  114723. */
  114724. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  114725. /**
  114726. *
  114727. * Add a HDRCubeTextureAssetTask to the list of active tasks
  114728. * @param taskName defines the name of the new task
  114729. * @param url defines the url of the file to load
  114730. * @param size defines the size you want for the cubemap (can be null)
  114731. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  114732. * @param generateHarmonics defines if you want to automatically generate (true by default)
  114733. * @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)
  114734. * @param reserved Internal use only
  114735. * @returns a new HDRCubeTextureAssetTask object
  114736. */
  114737. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  114738. /**
  114739. *
  114740. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  114741. * @param taskName defines the name of the new task
  114742. * @param url defines the url of the file to load
  114743. * @param size defines the size you want for the cubemap (can be null)
  114744. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  114745. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  114746. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  114747. * @returns a new EquiRectangularCubeTextureAssetTask object
  114748. */
  114749. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  114750. /**
  114751. * Remove a task from the assets manager.
  114752. * @param task the task to remove
  114753. */
  114754. removeTask(task: AbstractAssetTask): void;
  114755. private _decreaseWaitingTasksCount;
  114756. private _runTask;
  114757. /**
  114758. * Reset the AssetsManager and remove all tasks
  114759. * @return the current instance of the AssetsManager
  114760. */
  114761. reset(): AssetsManager;
  114762. /**
  114763. * Start the loading process
  114764. * @return the current instance of the AssetsManager
  114765. */
  114766. load(): AssetsManager;
  114767. /**
  114768. * Start the loading process as an async operation
  114769. * @return a promise returning the list of failed tasks
  114770. */
  114771. loadAsync(): Promise<void>;
  114772. }
  114773. }
  114774. declare module BABYLON {
  114775. /**
  114776. * Wrapper class for promise with external resolve and reject.
  114777. */
  114778. export class Deferred<T> {
  114779. /**
  114780. * The promise associated with this deferred object.
  114781. */
  114782. readonly promise: Promise<T>;
  114783. private _resolve;
  114784. private _reject;
  114785. /**
  114786. * The resolve method of the promise associated with this deferred object.
  114787. */
  114788. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  114789. /**
  114790. * The reject method of the promise associated with this deferred object.
  114791. */
  114792. readonly reject: (reason?: any) => void;
  114793. /**
  114794. * Constructor for this deferred object.
  114795. */
  114796. constructor();
  114797. }
  114798. }
  114799. declare module BABYLON {
  114800. /**
  114801. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  114802. */
  114803. export class MeshExploder {
  114804. private _centerMesh;
  114805. private _meshes;
  114806. private _meshesOrigins;
  114807. private _toCenterVectors;
  114808. private _scaledDirection;
  114809. private _newPosition;
  114810. private _centerPosition;
  114811. /**
  114812. * Explodes meshes from a center mesh.
  114813. * @param meshes The meshes to explode.
  114814. * @param centerMesh The mesh to be center of explosion.
  114815. */
  114816. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  114817. private _setCenterMesh;
  114818. /**
  114819. * Get class name
  114820. * @returns "MeshExploder"
  114821. */
  114822. getClassName(): string;
  114823. /**
  114824. * "Exploded meshes"
  114825. * @returns Array of meshes with the centerMesh at index 0.
  114826. */
  114827. getMeshes(): Array<Mesh>;
  114828. /**
  114829. * Explodes meshes giving a specific direction
  114830. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  114831. */
  114832. explode(direction?: number): void;
  114833. }
  114834. }
  114835. declare module BABYLON {
  114836. /**
  114837. * Class used to help managing file picking and drag'n'drop
  114838. */
  114839. export class FilesInput {
  114840. /**
  114841. * List of files ready to be loaded
  114842. */
  114843. static readonly FilesToLoad: {
  114844. [key: string]: File;
  114845. };
  114846. /**
  114847. * Callback called when a file is processed
  114848. */
  114849. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  114850. private _engine;
  114851. private _currentScene;
  114852. private _sceneLoadedCallback;
  114853. private _progressCallback;
  114854. private _additionalRenderLoopLogicCallback;
  114855. private _textureLoadingCallback;
  114856. private _startingProcessingFilesCallback;
  114857. private _onReloadCallback;
  114858. private _errorCallback;
  114859. private _elementToMonitor;
  114860. private _sceneFileToLoad;
  114861. private _filesToLoad;
  114862. /**
  114863. * Creates a new FilesInput
  114864. * @param engine defines the rendering engine
  114865. * @param scene defines the hosting scene
  114866. * @param sceneLoadedCallback callback called when scene is loaded
  114867. * @param progressCallback callback called to track progress
  114868. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  114869. * @param textureLoadingCallback callback called when a texture is loading
  114870. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  114871. * @param onReloadCallback callback called when a reload is requested
  114872. * @param errorCallback callback call if an error occurs
  114873. */
  114874. 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);
  114875. private _dragEnterHandler;
  114876. private _dragOverHandler;
  114877. private _dropHandler;
  114878. /**
  114879. * Calls this function to listen to drag'n'drop events on a specific DOM element
  114880. * @param elementToMonitor defines the DOM element to track
  114881. */
  114882. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  114883. /**
  114884. * Release all associated resources
  114885. */
  114886. dispose(): void;
  114887. private renderFunction;
  114888. private drag;
  114889. private drop;
  114890. private _traverseFolder;
  114891. private _processFiles;
  114892. /**
  114893. * Load files from a drop event
  114894. * @param event defines the drop event to use as source
  114895. */
  114896. loadFiles(event: any): void;
  114897. private _processReload;
  114898. /**
  114899. * Reload the current scene from the loaded files
  114900. */
  114901. reload(): void;
  114902. }
  114903. }
  114904. declare module BABYLON {
  114905. /**
  114906. * Defines the root class used to create scene optimization to use with SceneOptimizer
  114907. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114908. */
  114909. export class SceneOptimization {
  114910. /**
  114911. * Defines the priority of this optimization (0 by default which means first in the list)
  114912. */
  114913. priority: number;
  114914. /**
  114915. * Gets a string describing the action executed by the current optimization
  114916. * @returns description string
  114917. */
  114918. getDescription(): string;
  114919. /**
  114920. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114921. * @param scene defines the current scene where to apply this optimization
  114922. * @param optimizer defines the current optimizer
  114923. * @returns true if everything that can be done was applied
  114924. */
  114925. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114926. /**
  114927. * Creates the SceneOptimization object
  114928. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  114929. * @param desc defines the description associated with the optimization
  114930. */
  114931. constructor(
  114932. /**
  114933. * Defines the priority of this optimization (0 by default which means first in the list)
  114934. */
  114935. priority?: number);
  114936. }
  114937. /**
  114938. * Defines an optimization used to reduce the size of render target textures
  114939. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114940. */
  114941. export class TextureOptimization extends SceneOptimization {
  114942. /**
  114943. * Defines the priority of this optimization (0 by default which means first in the list)
  114944. */
  114945. priority: number;
  114946. /**
  114947. * 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
  114948. */
  114949. maximumSize: number;
  114950. /**
  114951. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  114952. */
  114953. step: number;
  114954. /**
  114955. * Gets a string describing the action executed by the current optimization
  114956. * @returns description string
  114957. */
  114958. getDescription(): string;
  114959. /**
  114960. * Creates the TextureOptimization object
  114961. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  114962. * @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
  114963. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  114964. */
  114965. constructor(
  114966. /**
  114967. * Defines the priority of this optimization (0 by default which means first in the list)
  114968. */
  114969. priority?: number,
  114970. /**
  114971. * 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
  114972. */
  114973. maximumSize?: number,
  114974. /**
  114975. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  114976. */
  114977. step?: number);
  114978. /**
  114979. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114980. * @param scene defines the current scene where to apply this optimization
  114981. * @param optimizer defines the current optimizer
  114982. * @returns true if everything that can be done was applied
  114983. */
  114984. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114985. }
  114986. /**
  114987. * Defines an optimization used to increase or decrease the rendering resolution
  114988. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114989. */
  114990. export class HardwareScalingOptimization extends SceneOptimization {
  114991. /**
  114992. * Defines the priority of this optimization (0 by default which means first in the list)
  114993. */
  114994. priority: number;
  114995. /**
  114996. * Defines the maximum scale to use (2 by default)
  114997. */
  114998. maximumScale: number;
  114999. /**
  115000. * Defines the step to use between two passes (0.5 by default)
  115001. */
  115002. step: number;
  115003. private _currentScale;
  115004. private _directionOffset;
  115005. /**
  115006. * Gets a string describing the action executed by the current optimization
  115007. * @return description string
  115008. */
  115009. getDescription(): string;
  115010. /**
  115011. * Creates the HardwareScalingOptimization object
  115012. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  115013. * @param maximumScale defines the maximum scale to use (2 by default)
  115014. * @param step defines the step to use between two passes (0.5 by default)
  115015. */
  115016. constructor(
  115017. /**
  115018. * Defines the priority of this optimization (0 by default which means first in the list)
  115019. */
  115020. priority?: number,
  115021. /**
  115022. * Defines the maximum scale to use (2 by default)
  115023. */
  115024. maximumScale?: number,
  115025. /**
  115026. * Defines the step to use between two passes (0.5 by default)
  115027. */
  115028. step?: number);
  115029. /**
  115030. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115031. * @param scene defines the current scene where to apply this optimization
  115032. * @param optimizer defines the current optimizer
  115033. * @returns true if everything that can be done was applied
  115034. */
  115035. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115036. }
  115037. /**
  115038. * Defines an optimization used to remove shadows
  115039. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115040. */
  115041. export class ShadowsOptimization extends SceneOptimization {
  115042. /**
  115043. * Gets a string describing the action executed by the current optimization
  115044. * @return description string
  115045. */
  115046. getDescription(): string;
  115047. /**
  115048. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115049. * @param scene defines the current scene where to apply this optimization
  115050. * @param optimizer defines the current optimizer
  115051. * @returns true if everything that can be done was applied
  115052. */
  115053. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115054. }
  115055. /**
  115056. * Defines an optimization used to turn post-processes off
  115057. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115058. */
  115059. export class PostProcessesOptimization extends SceneOptimization {
  115060. /**
  115061. * Gets a string describing the action executed by the current optimization
  115062. * @return description string
  115063. */
  115064. getDescription(): string;
  115065. /**
  115066. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115067. * @param scene defines the current scene where to apply this optimization
  115068. * @param optimizer defines the current optimizer
  115069. * @returns true if everything that can be done was applied
  115070. */
  115071. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115072. }
  115073. /**
  115074. * Defines an optimization used to turn lens flares off
  115075. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115076. */
  115077. export class LensFlaresOptimization extends SceneOptimization {
  115078. /**
  115079. * Gets a string describing the action executed by the current optimization
  115080. * @return description string
  115081. */
  115082. getDescription(): string;
  115083. /**
  115084. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115085. * @param scene defines the current scene where to apply this optimization
  115086. * @param optimizer defines the current optimizer
  115087. * @returns true if everything that can be done was applied
  115088. */
  115089. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115090. }
  115091. /**
  115092. * Defines an optimization based on user defined callback.
  115093. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115094. */
  115095. export class CustomOptimization extends SceneOptimization {
  115096. /**
  115097. * Callback called to apply the custom optimization.
  115098. */
  115099. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  115100. /**
  115101. * Callback called to get custom description
  115102. */
  115103. onGetDescription: () => string;
  115104. /**
  115105. * Gets a string describing the action executed by the current optimization
  115106. * @returns description string
  115107. */
  115108. getDescription(): string;
  115109. /**
  115110. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115111. * @param scene defines the current scene where to apply this optimization
  115112. * @param optimizer defines the current optimizer
  115113. * @returns true if everything that can be done was applied
  115114. */
  115115. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115116. }
  115117. /**
  115118. * Defines an optimization used to turn particles off
  115119. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115120. */
  115121. export class ParticlesOptimization extends SceneOptimization {
  115122. /**
  115123. * Gets a string describing the action executed by the current optimization
  115124. * @return description string
  115125. */
  115126. getDescription(): string;
  115127. /**
  115128. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115129. * @param scene defines the current scene where to apply this optimization
  115130. * @param optimizer defines the current optimizer
  115131. * @returns true if everything that can be done was applied
  115132. */
  115133. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115134. }
  115135. /**
  115136. * Defines an optimization used to turn render targets off
  115137. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115138. */
  115139. export class RenderTargetsOptimization extends SceneOptimization {
  115140. /**
  115141. * Gets a string describing the action executed by the current optimization
  115142. * @return description string
  115143. */
  115144. getDescription(): string;
  115145. /**
  115146. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115147. * @param scene defines the current scene where to apply this optimization
  115148. * @param optimizer defines the current optimizer
  115149. * @returns true if everything that can be done was applied
  115150. */
  115151. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115152. }
  115153. /**
  115154. * Defines an optimization used to merge meshes with compatible materials
  115155. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115156. */
  115157. export class MergeMeshesOptimization extends SceneOptimization {
  115158. private static _UpdateSelectionTree;
  115159. /**
  115160. * Gets or sets a boolean which defines if optimization octree has to be updated
  115161. */
  115162. /**
  115163. * Gets or sets a boolean which defines if optimization octree has to be updated
  115164. */
  115165. static UpdateSelectionTree: boolean;
  115166. /**
  115167. * Gets a string describing the action executed by the current optimization
  115168. * @return description string
  115169. */
  115170. getDescription(): string;
  115171. private _canBeMerged;
  115172. /**
  115173. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115174. * @param scene defines the current scene where to apply this optimization
  115175. * @param optimizer defines the current optimizer
  115176. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  115177. * @returns true if everything that can be done was applied
  115178. */
  115179. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  115180. }
  115181. /**
  115182. * Defines a list of options used by SceneOptimizer
  115183. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115184. */
  115185. export class SceneOptimizerOptions {
  115186. /**
  115187. * Defines the target frame rate to reach (60 by default)
  115188. */
  115189. targetFrameRate: number;
  115190. /**
  115191. * Defines the interval between two checkes (2000ms by default)
  115192. */
  115193. trackerDuration: number;
  115194. /**
  115195. * Gets the list of optimizations to apply
  115196. */
  115197. optimizations: SceneOptimization[];
  115198. /**
  115199. * Creates a new list of options used by SceneOptimizer
  115200. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  115201. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  115202. */
  115203. constructor(
  115204. /**
  115205. * Defines the target frame rate to reach (60 by default)
  115206. */
  115207. targetFrameRate?: number,
  115208. /**
  115209. * Defines the interval between two checkes (2000ms by default)
  115210. */
  115211. trackerDuration?: number);
  115212. /**
  115213. * Add a new optimization
  115214. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  115215. * @returns the current SceneOptimizerOptions
  115216. */
  115217. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  115218. /**
  115219. * Add a new custom optimization
  115220. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  115221. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  115222. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  115223. * @returns the current SceneOptimizerOptions
  115224. */
  115225. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  115226. /**
  115227. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  115228. * @param targetFrameRate defines the target frame rate (60 by default)
  115229. * @returns a SceneOptimizerOptions object
  115230. */
  115231. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  115232. /**
  115233. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  115234. * @param targetFrameRate defines the target frame rate (60 by default)
  115235. * @returns a SceneOptimizerOptions object
  115236. */
  115237. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  115238. /**
  115239. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  115240. * @param targetFrameRate defines the target frame rate (60 by default)
  115241. * @returns a SceneOptimizerOptions object
  115242. */
  115243. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  115244. }
  115245. /**
  115246. * Class used to run optimizations in order to reach a target frame rate
  115247. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115248. */
  115249. export class SceneOptimizer implements IDisposable {
  115250. private _isRunning;
  115251. private _options;
  115252. private _scene;
  115253. private _currentPriorityLevel;
  115254. private _targetFrameRate;
  115255. private _trackerDuration;
  115256. private _currentFrameRate;
  115257. private _sceneDisposeObserver;
  115258. private _improvementMode;
  115259. /**
  115260. * Defines an observable called when the optimizer reaches the target frame rate
  115261. */
  115262. onSuccessObservable: Observable<SceneOptimizer>;
  115263. /**
  115264. * Defines an observable called when the optimizer enables an optimization
  115265. */
  115266. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  115267. /**
  115268. * Defines an observable called when the optimizer is not able to reach the target frame rate
  115269. */
  115270. onFailureObservable: Observable<SceneOptimizer>;
  115271. /**
  115272. * Gets a boolean indicating if the optimizer is in improvement mode
  115273. */
  115274. readonly isInImprovementMode: boolean;
  115275. /**
  115276. * Gets the current priority level (0 at start)
  115277. */
  115278. readonly currentPriorityLevel: number;
  115279. /**
  115280. * Gets the current frame rate checked by the SceneOptimizer
  115281. */
  115282. readonly currentFrameRate: number;
  115283. /**
  115284. * Gets or sets the current target frame rate (60 by default)
  115285. */
  115286. /**
  115287. * Gets or sets the current target frame rate (60 by default)
  115288. */
  115289. targetFrameRate: number;
  115290. /**
  115291. * Gets or sets the current interval between two checks (every 2000ms by default)
  115292. */
  115293. /**
  115294. * Gets or sets the current interval between two checks (every 2000ms by default)
  115295. */
  115296. trackerDuration: number;
  115297. /**
  115298. * Gets the list of active optimizations
  115299. */
  115300. readonly optimizations: SceneOptimization[];
  115301. /**
  115302. * Creates a new SceneOptimizer
  115303. * @param scene defines the scene to work on
  115304. * @param options defines the options to use with the SceneOptimizer
  115305. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  115306. * @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)
  115307. */
  115308. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  115309. /**
  115310. * Stops the current optimizer
  115311. */
  115312. stop(): void;
  115313. /**
  115314. * Reset the optimizer to initial step (current priority level = 0)
  115315. */
  115316. reset(): void;
  115317. /**
  115318. * Start the optimizer. By default it will try to reach a specific framerate
  115319. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  115320. */
  115321. start(): void;
  115322. private _checkCurrentState;
  115323. /**
  115324. * Release all resources
  115325. */
  115326. dispose(): void;
  115327. /**
  115328. * Helper function to create a SceneOptimizer with one single line of code
  115329. * @param scene defines the scene to work on
  115330. * @param options defines the options to use with the SceneOptimizer
  115331. * @param onSuccess defines a callback to call on success
  115332. * @param onFailure defines a callback to call on failure
  115333. * @returns the new SceneOptimizer object
  115334. */
  115335. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  115336. }
  115337. }
  115338. declare module BABYLON {
  115339. /**
  115340. * Class used to serialize a scene into a string
  115341. */
  115342. export class SceneSerializer {
  115343. /**
  115344. * Clear cache used by a previous serialization
  115345. */
  115346. static ClearCache(): void;
  115347. /**
  115348. * Serialize a scene into a JSON compatible object
  115349. * @param scene defines the scene to serialize
  115350. * @returns a JSON compatible object
  115351. */
  115352. static Serialize(scene: Scene): any;
  115353. /**
  115354. * Serialize a mesh into a JSON compatible object
  115355. * @param toSerialize defines the mesh to serialize
  115356. * @param withParents defines if parents must be serialized as well
  115357. * @param withChildren defines if children must be serialized as well
  115358. * @returns a JSON compatible object
  115359. */
  115360. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  115361. }
  115362. }
  115363. declare module BABYLON {
  115364. /**
  115365. * Class used to host texture specific utilities
  115366. */
  115367. export class TextureTools {
  115368. /**
  115369. * Uses the GPU to create a copy texture rescaled at a given size
  115370. * @param texture Texture to copy from
  115371. * @param width defines the desired width
  115372. * @param height defines the desired height
  115373. * @param useBilinearMode defines if bilinear mode has to be used
  115374. * @return the generated texture
  115375. */
  115376. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  115377. }
  115378. }
  115379. declare module BABYLON {
  115380. /**
  115381. * This represents the different options avilable for the video capture.
  115382. */
  115383. export interface VideoRecorderOptions {
  115384. /** Defines the mime type of the video */
  115385. mimeType: string;
  115386. /** Defines the video the video should be recorded at */
  115387. fps: number;
  115388. /** Defines the chunk size for the recording data */
  115389. recordChunckSize: number;
  115390. /** The audio tracks to attach to the record */
  115391. audioTracks?: MediaStreamTrack[];
  115392. }
  115393. /**
  115394. * This can helps recording videos from BabylonJS.
  115395. * This is based on the available WebRTC functionalities of the browser.
  115396. *
  115397. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  115398. */
  115399. export class VideoRecorder {
  115400. private static readonly _defaultOptions;
  115401. /**
  115402. * Returns wehther or not the VideoRecorder is available in your browser.
  115403. * @param engine Defines the Babylon Engine to check the support for
  115404. * @returns true if supported otherwise false
  115405. */
  115406. static IsSupported(engine: Engine): boolean;
  115407. private readonly _options;
  115408. private _canvas;
  115409. private _mediaRecorder;
  115410. private _recordedChunks;
  115411. private _fileName;
  115412. private _resolve;
  115413. private _reject;
  115414. /**
  115415. * True wether a recording is already in progress.
  115416. */
  115417. readonly isRecording: boolean;
  115418. /**
  115419. * Create a new VideoCapture object which can help converting what you see in Babylon to
  115420. * a video file.
  115421. * @param engine Defines the BabylonJS Engine you wish to record
  115422. * @param options Defines options that can be used to customized the capture
  115423. */
  115424. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  115425. /**
  115426. * Stops the current recording before the default capture timeout passed in the startRecording
  115427. * functions.
  115428. */
  115429. stopRecording(): void;
  115430. /**
  115431. * Starts recording the canvas for a max duration specified in parameters.
  115432. * @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.
  115433. * @param maxDuration Defines the maximum recording time in seconds.
  115434. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  115435. * @return a promise callback at the end of the recording with the video data in Blob.
  115436. */
  115437. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  115438. /**
  115439. * Releases internal resources used during the recording.
  115440. */
  115441. dispose(): void;
  115442. private _handleDataAvailable;
  115443. private _handleError;
  115444. private _handleStop;
  115445. }
  115446. }
  115447. declare module BABYLON {
  115448. /**
  115449. * Class containing a set of static utilities functions for screenshots
  115450. */
  115451. export class ScreenshotTools {
  115452. /**
  115453. * Captures a screenshot of the current rendering
  115454. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  115455. * @param engine defines the rendering engine
  115456. * @param camera defines the source camera
  115457. * @param size This parameter can be set to a single number or to an object with the
  115458. * following (optional) properties: precision, width, height. If a single number is passed,
  115459. * it will be used for both width and height. If an object is passed, the screenshot size
  115460. * will be derived from the parameters. The precision property is a multiplier allowing
  115461. * rendering at a higher or lower resolution
  115462. * @param successCallback defines the callback receives a single parameter which contains the
  115463. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  115464. * src parameter of an <img> to display it
  115465. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  115466. * Check your browser for supported MIME types
  115467. */
  115468. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  115469. /**
  115470. * Generates an image screenshot from the specified camera.
  115471. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  115472. * @param engine The engine to use for rendering
  115473. * @param camera The camera to use for rendering
  115474. * @param size This parameter can be set to a single number or to an object with the
  115475. * following (optional) properties: precision, width, height. If a single number is passed,
  115476. * it will be used for both width and height. If an object is passed, the screenshot size
  115477. * will be derived from the parameters. The precision property is a multiplier allowing
  115478. * rendering at a higher or lower resolution
  115479. * @param successCallback The callback receives a single parameter which contains the
  115480. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  115481. * src parameter of an <img> to display it
  115482. * @param mimeType The MIME type of the screenshot image (default: image/png).
  115483. * Check your browser for supported MIME types
  115484. * @param samples Texture samples (default: 1)
  115485. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  115486. * @param fileName A name for for the downloaded file.
  115487. */
  115488. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  115489. }
  115490. }
  115491. declare module BABYLON {
  115492. /**
  115493. * A cursor which tracks a point on a path
  115494. */
  115495. export class PathCursor {
  115496. private path;
  115497. /**
  115498. * Stores path cursor callbacks for when an onchange event is triggered
  115499. */
  115500. private _onchange;
  115501. /**
  115502. * The value of the path cursor
  115503. */
  115504. value: number;
  115505. /**
  115506. * The animation array of the path cursor
  115507. */
  115508. animations: Animation[];
  115509. /**
  115510. * Initializes the path cursor
  115511. * @param path The path to track
  115512. */
  115513. constructor(path: Path2);
  115514. /**
  115515. * Gets the cursor point on the path
  115516. * @returns A point on the path cursor at the cursor location
  115517. */
  115518. getPoint(): Vector3;
  115519. /**
  115520. * Moves the cursor ahead by the step amount
  115521. * @param step The amount to move the cursor forward
  115522. * @returns This path cursor
  115523. */
  115524. moveAhead(step?: number): PathCursor;
  115525. /**
  115526. * Moves the cursor behind by the step amount
  115527. * @param step The amount to move the cursor back
  115528. * @returns This path cursor
  115529. */
  115530. moveBack(step?: number): PathCursor;
  115531. /**
  115532. * Moves the cursor by the step amount
  115533. * If the step amount is greater than one, an exception is thrown
  115534. * @param step The amount to move the cursor
  115535. * @returns This path cursor
  115536. */
  115537. move(step: number): PathCursor;
  115538. /**
  115539. * Ensures that the value is limited between zero and one
  115540. * @returns This path cursor
  115541. */
  115542. private ensureLimits;
  115543. /**
  115544. * Runs onchange callbacks on change (used by the animation engine)
  115545. * @returns This path cursor
  115546. */
  115547. private raiseOnChange;
  115548. /**
  115549. * Executes a function on change
  115550. * @param f A path cursor onchange callback
  115551. * @returns This path cursor
  115552. */
  115553. onchange(f: (cursor: PathCursor) => void): PathCursor;
  115554. }
  115555. }
  115556. declare module BABYLON {
  115557. /** @hidden */
  115558. export var blurPixelShader: {
  115559. name: string;
  115560. shader: string;
  115561. };
  115562. }
  115563. declare module BABYLON {
  115564. /** @hidden */
  115565. export var bones300Declaration: {
  115566. name: string;
  115567. shader: string;
  115568. };
  115569. }
  115570. declare module BABYLON {
  115571. /** @hidden */
  115572. export var instances300Declaration: {
  115573. name: string;
  115574. shader: string;
  115575. };
  115576. }
  115577. declare module BABYLON {
  115578. /** @hidden */
  115579. export var pointCloudVertexDeclaration: {
  115580. name: string;
  115581. shader: string;
  115582. };
  115583. }
  115584. // Mixins
  115585. interface Window {
  115586. mozIndexedDB: IDBFactory;
  115587. webkitIndexedDB: IDBFactory;
  115588. msIndexedDB: IDBFactory;
  115589. webkitURL: typeof URL;
  115590. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  115591. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  115592. WebGLRenderingContext: WebGLRenderingContext;
  115593. MSGesture: MSGesture;
  115594. CANNON: any;
  115595. AudioContext: AudioContext;
  115596. webkitAudioContext: AudioContext;
  115597. PointerEvent: any;
  115598. Math: Math;
  115599. Uint8Array: Uint8ArrayConstructor;
  115600. Float32Array: Float32ArrayConstructor;
  115601. mozURL: typeof URL;
  115602. msURL: typeof URL;
  115603. VRFrameData: any; // WebVR, from specs 1.1
  115604. DracoDecoderModule: any;
  115605. setImmediate(handler: (...args: any[]) => void): number;
  115606. }
  115607. interface HTMLCanvasElement {
  115608. requestPointerLock(): void;
  115609. msRequestPointerLock?(): void;
  115610. mozRequestPointerLock?(): void;
  115611. webkitRequestPointerLock?(): void;
  115612. /** Track wether a record is in progress */
  115613. isRecording: boolean;
  115614. /** Capture Stream method defined by some browsers */
  115615. captureStream(fps?: number): MediaStream;
  115616. }
  115617. interface CanvasRenderingContext2D {
  115618. msImageSmoothingEnabled: boolean;
  115619. }
  115620. interface MouseEvent {
  115621. mozMovementX: number;
  115622. mozMovementY: number;
  115623. webkitMovementX: number;
  115624. webkitMovementY: number;
  115625. msMovementX: number;
  115626. msMovementY: number;
  115627. }
  115628. interface Navigator {
  115629. mozGetVRDevices: (any: any) => any;
  115630. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  115631. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  115632. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  115633. webkitGetGamepads(): Gamepad[];
  115634. msGetGamepads(): Gamepad[];
  115635. webkitGamepads(): Gamepad[];
  115636. }
  115637. interface HTMLVideoElement {
  115638. mozSrcObject: any;
  115639. }
  115640. interface Math {
  115641. fround(x: number): number;
  115642. imul(a: number, b: number): number;
  115643. }
  115644. interface WebGLProgram {
  115645. context?: WebGLRenderingContext;
  115646. vertexShader?: WebGLShader;
  115647. fragmentShader?: WebGLShader;
  115648. isParallelCompiled: boolean;
  115649. onCompiled?: () => void;
  115650. }
  115651. interface WebGLRenderingContext {
  115652. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  115653. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  115654. vertexAttribDivisor(index: number, divisor: number): void;
  115655. createVertexArray(): any;
  115656. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  115657. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  115658. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  115659. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  115660. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  115661. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  115662. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  115663. // Queries
  115664. createQuery(): WebGLQuery;
  115665. deleteQuery(query: WebGLQuery): void;
  115666. beginQuery(target: number, query: WebGLQuery): void;
  115667. endQuery(target: number): void;
  115668. getQueryParameter(query: WebGLQuery, pname: number): any;
  115669. getQuery(target: number, pname: number): any;
  115670. MAX_SAMPLES: number;
  115671. RGBA8: number;
  115672. READ_FRAMEBUFFER: number;
  115673. DRAW_FRAMEBUFFER: number;
  115674. UNIFORM_BUFFER: number;
  115675. HALF_FLOAT_OES: number;
  115676. RGBA16F: number;
  115677. RGBA32F: number;
  115678. R32F: number;
  115679. RG32F: number;
  115680. RGB32F: number;
  115681. R16F: number;
  115682. RG16F: number;
  115683. RGB16F: number;
  115684. RED: number;
  115685. RG: number;
  115686. R8: number;
  115687. RG8: number;
  115688. UNSIGNED_INT_24_8: number;
  115689. DEPTH24_STENCIL8: number;
  115690. /* Multiple Render Targets */
  115691. drawBuffers(buffers: number[]): void;
  115692. readBuffer(src: number): void;
  115693. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  115694. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  115695. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  115696. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  115697. // Occlusion Query
  115698. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  115699. ANY_SAMPLES_PASSED: number;
  115700. QUERY_RESULT_AVAILABLE: number;
  115701. QUERY_RESULT: number;
  115702. }
  115703. interface WebGLBuffer {
  115704. references: number;
  115705. capacity: number;
  115706. is32Bits: boolean;
  115707. }
  115708. interface WebGLProgram {
  115709. transformFeedback?: WebGLTransformFeedback | null;
  115710. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  115711. }
  115712. interface EXT_disjoint_timer_query {
  115713. QUERY_COUNTER_BITS_EXT: number;
  115714. TIME_ELAPSED_EXT: number;
  115715. TIMESTAMP_EXT: number;
  115716. GPU_DISJOINT_EXT: number;
  115717. QUERY_RESULT_EXT: number;
  115718. QUERY_RESULT_AVAILABLE_EXT: number;
  115719. queryCounterEXT(query: WebGLQuery, target: number): void;
  115720. createQueryEXT(): WebGLQuery;
  115721. beginQueryEXT(target: number, query: WebGLQuery): void;
  115722. endQueryEXT(target: number): void;
  115723. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  115724. deleteQueryEXT(query: WebGLQuery): void;
  115725. }
  115726. interface WebGLUniformLocation {
  115727. _currentState: any;
  115728. }
  115729. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  115730. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  115731. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  115732. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  115733. interface WebGLRenderingContext {
  115734. readonly RASTERIZER_DISCARD: number;
  115735. readonly DEPTH_COMPONENT24: number;
  115736. readonly TEXTURE_3D: number;
  115737. readonly TEXTURE_2D_ARRAY: number;
  115738. readonly TEXTURE_COMPARE_FUNC: number;
  115739. readonly TEXTURE_COMPARE_MODE: number;
  115740. readonly COMPARE_REF_TO_TEXTURE: number;
  115741. readonly TEXTURE_WRAP_R: number;
  115742. readonly HALF_FLOAT: number;
  115743. readonly RGB8: number;
  115744. readonly RED_INTEGER: number;
  115745. readonly RG_INTEGER: number;
  115746. readonly RGB_INTEGER: number;
  115747. readonly RGBA_INTEGER: number;
  115748. readonly R8_SNORM: number;
  115749. readonly RG8_SNORM: number;
  115750. readonly RGB8_SNORM: number;
  115751. readonly RGBA8_SNORM: number;
  115752. readonly R8I: number;
  115753. readonly RG8I: number;
  115754. readonly RGB8I: number;
  115755. readonly RGBA8I: number;
  115756. readonly R8UI: number;
  115757. readonly RG8UI: number;
  115758. readonly RGB8UI: number;
  115759. readonly RGBA8UI: number;
  115760. readonly R16I: number;
  115761. readonly RG16I: number;
  115762. readonly RGB16I: number;
  115763. readonly RGBA16I: number;
  115764. readonly R16UI: number;
  115765. readonly RG16UI: number;
  115766. readonly RGB16UI: number;
  115767. readonly RGBA16UI: number;
  115768. readonly R32I: number;
  115769. readonly RG32I: number;
  115770. readonly RGB32I: number;
  115771. readonly RGBA32I: number;
  115772. readonly R32UI: number;
  115773. readonly RG32UI: number;
  115774. readonly RGB32UI: number;
  115775. readonly RGBA32UI: number;
  115776. readonly RGB10_A2UI: number;
  115777. readonly R11F_G11F_B10F: number;
  115778. readonly RGB9_E5: number;
  115779. readonly RGB10_A2: number;
  115780. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  115781. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  115782. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  115783. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  115784. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  115785. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  115786. 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;
  115787. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  115788. readonly TRANSFORM_FEEDBACK: number;
  115789. readonly INTERLEAVED_ATTRIBS: number;
  115790. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  115791. createTransformFeedback(): WebGLTransformFeedback;
  115792. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  115793. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  115794. beginTransformFeedback(primitiveMode: number): void;
  115795. endTransformFeedback(): void;
  115796. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  115797. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  115798. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  115799. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  115800. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  115801. }
  115802. interface ImageBitmap {
  115803. readonly width: number;
  115804. readonly height: number;
  115805. close(): void;
  115806. }
  115807. interface WebGLQuery extends WebGLObject {
  115808. }
  115809. declare var WebGLQuery: {
  115810. prototype: WebGLQuery;
  115811. new(): WebGLQuery;
  115812. };
  115813. interface WebGLSampler extends WebGLObject {
  115814. }
  115815. declare var WebGLSampler: {
  115816. prototype: WebGLSampler;
  115817. new(): WebGLSampler;
  115818. };
  115819. interface WebGLSync extends WebGLObject {
  115820. }
  115821. declare var WebGLSync: {
  115822. prototype: WebGLSync;
  115823. new(): WebGLSync;
  115824. };
  115825. interface WebGLTransformFeedback extends WebGLObject {
  115826. }
  115827. declare var WebGLTransformFeedback: {
  115828. prototype: WebGLTransformFeedback;
  115829. new(): WebGLTransformFeedback;
  115830. };
  115831. interface WebGLVertexArrayObject extends WebGLObject {
  115832. }
  115833. declare var WebGLVertexArrayObject: {
  115834. prototype: WebGLVertexArrayObject;
  115835. new(): WebGLVertexArrayObject;
  115836. };
  115837. // Type definitions for WebVR API
  115838. // Project: https://w3c.github.io/webvr/
  115839. // Definitions by: six a <https://github.com/lostfictions>
  115840. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  115841. interface VRDisplay extends EventTarget {
  115842. /**
  115843. * Dictionary of capabilities describing the VRDisplay.
  115844. */
  115845. readonly capabilities: VRDisplayCapabilities;
  115846. /**
  115847. * z-depth defining the far plane of the eye view frustum
  115848. * enables mapping of values in the render target depth
  115849. * attachment to scene coordinates. Initially set to 10000.0.
  115850. */
  115851. depthFar: number;
  115852. /**
  115853. * z-depth defining the near plane of the eye view frustum
  115854. * enables mapping of values in the render target depth
  115855. * attachment to scene coordinates. Initially set to 0.01.
  115856. */
  115857. depthNear: number;
  115858. /**
  115859. * An identifier for this distinct VRDisplay. Used as an
  115860. * association point in the Gamepad API.
  115861. */
  115862. readonly displayId: number;
  115863. /**
  115864. * A display name, a user-readable name identifying it.
  115865. */
  115866. readonly displayName: string;
  115867. readonly isConnected: boolean;
  115868. readonly isPresenting: boolean;
  115869. /**
  115870. * If this VRDisplay supports room-scale experiences, the optional
  115871. * stage attribute contains details on the room-scale parameters.
  115872. */
  115873. readonly stageParameters: VRStageParameters | null;
  115874. /**
  115875. * Passing the value returned by `requestAnimationFrame` to
  115876. * `cancelAnimationFrame` will unregister the callback.
  115877. * @param handle Define the hanle of the request to cancel
  115878. */
  115879. cancelAnimationFrame(handle: number): void;
  115880. /**
  115881. * Stops presenting to the VRDisplay.
  115882. * @returns a promise to know when it stopped
  115883. */
  115884. exitPresent(): Promise<void>;
  115885. /**
  115886. * Return the current VREyeParameters for the given eye.
  115887. * @param whichEye Define the eye we want the parameter for
  115888. * @returns the eye parameters
  115889. */
  115890. getEyeParameters(whichEye: string): VREyeParameters;
  115891. /**
  115892. * Populates the passed VRFrameData with the information required to render
  115893. * the current frame.
  115894. * @param frameData Define the data structure to populate
  115895. * @returns true if ok otherwise false
  115896. */
  115897. getFrameData(frameData: VRFrameData): boolean;
  115898. /**
  115899. * Get the layers currently being presented.
  115900. * @returns the list of VR layers
  115901. */
  115902. getLayers(): VRLayer[];
  115903. /**
  115904. * Return a VRPose containing the future predicted pose of the VRDisplay
  115905. * when the current frame will be presented. The value returned will not
  115906. * change until JavaScript has returned control to the browser.
  115907. *
  115908. * The VRPose will contain the position, orientation, velocity,
  115909. * and acceleration of each of these properties.
  115910. * @returns the pose object
  115911. */
  115912. getPose(): VRPose;
  115913. /**
  115914. * Return the current instantaneous pose of the VRDisplay, with no
  115915. * prediction applied.
  115916. * @returns the current instantaneous pose
  115917. */
  115918. getImmediatePose(): VRPose;
  115919. /**
  115920. * The callback passed to `requestAnimationFrame` will be called
  115921. * any time a new frame should be rendered. When the VRDisplay is
  115922. * presenting the callback will be called at the native refresh
  115923. * rate of the HMD. When not presenting this function acts
  115924. * identically to how window.requestAnimationFrame acts. Content should
  115925. * make no assumptions of frame rate or vsync behavior as the HMD runs
  115926. * asynchronously from other displays and at differing refresh rates.
  115927. * @param callback Define the eaction to run next frame
  115928. * @returns the request handle it
  115929. */
  115930. requestAnimationFrame(callback: FrameRequestCallback): number;
  115931. /**
  115932. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  115933. * Repeat calls while already presenting will update the VRLayers being displayed.
  115934. * @param layers Define the list of layer to present
  115935. * @returns a promise to know when the request has been fulfilled
  115936. */
  115937. requestPresent(layers: VRLayer[]): Promise<void>;
  115938. /**
  115939. * Reset the pose for this display, treating its current position and
  115940. * orientation as the "origin/zero" values. VRPose.position,
  115941. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  115942. * updated when calling resetPose(). This should be called in only
  115943. * sitting-space experiences.
  115944. */
  115945. resetPose(): void;
  115946. /**
  115947. * The VRLayer provided to the VRDisplay will be captured and presented
  115948. * in the HMD. Calling this function has the same effect on the source
  115949. * canvas as any other operation that uses its source image, and canvases
  115950. * created without preserveDrawingBuffer set to true will be cleared.
  115951. * @param pose Define the pose to submit
  115952. */
  115953. submitFrame(pose?: VRPose): void;
  115954. }
  115955. declare var VRDisplay: {
  115956. prototype: VRDisplay;
  115957. new(): VRDisplay;
  115958. };
  115959. interface VRLayer {
  115960. leftBounds?: number[] | Float32Array | null;
  115961. rightBounds?: number[] | Float32Array | null;
  115962. source?: HTMLCanvasElement | null;
  115963. }
  115964. interface VRDisplayCapabilities {
  115965. readonly canPresent: boolean;
  115966. readonly hasExternalDisplay: boolean;
  115967. readonly hasOrientation: boolean;
  115968. readonly hasPosition: boolean;
  115969. readonly maxLayers: number;
  115970. }
  115971. interface VREyeParameters {
  115972. /** @deprecated */
  115973. readonly fieldOfView: VRFieldOfView;
  115974. readonly offset: Float32Array;
  115975. readonly renderHeight: number;
  115976. readonly renderWidth: number;
  115977. }
  115978. interface VRFieldOfView {
  115979. readonly downDegrees: number;
  115980. readonly leftDegrees: number;
  115981. readonly rightDegrees: number;
  115982. readonly upDegrees: number;
  115983. }
  115984. interface VRFrameData {
  115985. readonly leftProjectionMatrix: Float32Array;
  115986. readonly leftViewMatrix: Float32Array;
  115987. readonly pose: VRPose;
  115988. readonly rightProjectionMatrix: Float32Array;
  115989. readonly rightViewMatrix: Float32Array;
  115990. readonly timestamp: number;
  115991. }
  115992. interface VRPose {
  115993. readonly angularAcceleration: Float32Array | null;
  115994. readonly angularVelocity: Float32Array | null;
  115995. readonly linearAcceleration: Float32Array | null;
  115996. readonly linearVelocity: Float32Array | null;
  115997. readonly orientation: Float32Array | null;
  115998. readonly position: Float32Array | null;
  115999. readonly timestamp: number;
  116000. }
  116001. interface VRStageParameters {
  116002. sittingToStandingTransform?: Float32Array;
  116003. sizeX?: number;
  116004. sizeY?: number;
  116005. }
  116006. interface Navigator {
  116007. getVRDisplays(): Promise<VRDisplay[]>;
  116008. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  116009. }
  116010. interface Window {
  116011. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  116012. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  116013. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  116014. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  116015. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  116016. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  116017. }
  116018. interface Gamepad {
  116019. readonly displayId: number;
  116020. }
  116021. interface XRDevice {
  116022. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  116023. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  116024. }
  116025. interface XRSession {
  116026. getInputSources(): Array<any>;
  116027. baseLayer: XRWebGLLayer;
  116028. requestFrameOfReference(type: string): Promise<void>;
  116029. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  116030. end(): Promise<void>;
  116031. requestAnimationFrame: Function;
  116032. addEventListener: Function;
  116033. }
  116034. interface XRSessionCreationOptions {
  116035. outputContext?: WebGLRenderingContext | null;
  116036. immersive?: boolean;
  116037. environmentIntegration?: boolean;
  116038. }
  116039. interface XRLayer {
  116040. getViewport: Function;
  116041. framebufferWidth: number;
  116042. framebufferHeight: number;
  116043. }
  116044. interface XRView {
  116045. projectionMatrix: Float32Array;
  116046. }
  116047. interface XRFrame {
  116048. getDevicePose: Function;
  116049. getInputPose: Function;
  116050. views: Array<XRView>;
  116051. baseLayer: XRLayer;
  116052. }
  116053. interface XRFrameOfReference {
  116054. }
  116055. interface XRWebGLLayer extends XRLayer {
  116056. framebuffer: WebGLFramebuffer;
  116057. }
  116058. declare var XRWebGLLayer: {
  116059. prototype: XRWebGLLayer;
  116060. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  116061. };